upsert-resource

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

upsert-resource

Overview

Insert a resource, or if the resource already exists, update the existing resource.

FunctionConfig

Upsert is an operation that adds resources(uniquely identified by Group, Kind, Name, Namespace and Path) if they do not already exist, or replaces them if they already exist in the input list of resources. upsert-resource function offers a safe way to upsert a resources to the list of input resources.

Examples
Replace an existing resource

Let's start with the list of resources in a package:

apiVersion: v1
kind: Service
metadata:
  name: myService
  namespace: mySpace
spec:
  selector:
    app: foo
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myDeployment
  namespace: mySpace
spec:
  replicas: 3

Resource to upsert:

apiVersion: v1
kind: Service
metadata:
  name: myService
  namespace: mySpace
spec:
  selector:
    app: bar

Invoking upsert-resource function replaces the resource with name myService:

apiVersion: v1
kind: Service
metadata:
  name: myService
  namespace: mySpace
spec:
  selector:
    app: bar
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myDeployment
  namespace: mySpace
spec:
  replicas: 3
Add a new resource

For the same input resource list above, pass the following resource to upsert. Note that the name of the resource is myService2.

apiVersion: v1
kind: Service
metadata:
  name: myService2
  namespace: mySpace
spec:
  selector:
    app: bar

Invoking upsert-resource function adds the input resource to the package.

apiVersion: v1
kind: Service
metadata:
  name: myService
  namespace: mySpace
spec:
  selector:
    app: foo
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myDeployment
  namespace: mySpace
spec:
  replicas: 3
---
apiVersion: v1
kind: Service
metadata:
  name: myService2
  namespace: mySpace
spec:
  selector:
    app: bar

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Code generated by "mdtogo"; DO NOT EDIT.
Code generated by "mdtogo"; DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL