Skip to content

Instantly share code, notes, and snippets.

@cari-lynn
Created May 8, 2020 21:43
Show Gist options
  • Save cari-lynn/abcc8bffa86c1813b9eb893072246f49 to your computer and use it in GitHub Desktop.
Save cari-lynn/abcc8bffa86c1813b9eb893072246f49 to your computer and use it in GitHub Desktop.
Append to a string as yaml
#@ load("@ytt:data", "data")
---
#! Input
apiVersion: v1
kind: Secret
metadata:
name: secret
stringData:
longYaml: |
---
first: [a, b, c]
second:
foo: bar
ree: baz
third: true
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:yaml", "yaml")
#@ def applyToYamlString(left, right):
#@ leftYaml = yaml.decode(left)
#@ new = overlay.apply(leftYaml, right)
#@ return yaml.encode(new)
#@ end
#@overlay/match by=overlay.subset({"kind": "Secret", "metadata": {"name": "secret"}})
---
stringData:
#@overlay/replace via=applyToYamlString
longYaml:
#@overlay/match missing_ok=True
fourth:
blah: dee
doo: bee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment