Documentation ¶
Overview ¶
Package patch implements a simple patching mechanism for k8s resources. Paths are specified in the form a.b.c.[key:value].d.[list_entry_value], where:
- [key:value] selects a list entry in list c which contains an entry with key:value
- [list_entry_value] selects a list entry in list d which is a regex match of list_entry_value.
Some examples are given below. Given a resource:
kind: Deployment metadata:
name: istio-citadel namespace: istio-system
a:
b: - name: n1 value: v1 - name: n2 list: - "vv1" - vv2=foo
values and list entries can be added, modifed or deleted.
MODIFY ¶
1. set v1 to v1new
path: a.b.[name:n1].value value: v1
2. set vv1 to vv3
// Note the lack of quotes around vv1 (see NOTES below). path: a.b.[name:n2].list.[vv1] value: vv3
3. set vv2=foo to vv2=bar (using regex match)
path: a.b.[name:n2].list.[vv2] value: vv2=bar
DELETE ¶
1. Delete container with name: n1
path: a.b.[name:n1]
2. Delete list value vv1
path: a.b.[name:n2].list.[vv1]
ADD ¶
1. Add vv3 to list
path: a.b.[name:n2].list value: vv3
2. Add new key:value to container name: n1
path: a.b.[name:n1] value: new_attr: v3
*NOTES* - Due to loss of string quoting during unmarshaling, keys and values should not be string quoted, even if they appear that way in the object being patched. - [key:value] treats ':' as a special separator character. Any ':' in the key or value string must be escaped as \:.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func YAMLManifestPatch ¶
func YAMLManifestPatch(baseYAML string, namespace string, overlays []*v1alpha2.K8SObjectOverlay) (string, error)
YAMLManifestPatch patches a base YAML in the given namespace with a list of overlays. Each overlay has the format described in the K8SObjectOverlay definition. It returns the patched manifest YAML.
Types ¶
This section is empty.