Skip to content

Instantly share code, notes, and snippets.

@quiye
Last active April 21, 2024 23:25
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save quiye/25bfa781310b9a3409c2e4868237151c to your computer and use it in GitHub Desktop.
Save quiye/25bfa781310b9a3409c2e4868237151c to your computer and use it in GitHub Desktop.
yaml to jsonnet to yaml

Prepare

Do

yq read -j --prettyPrint input.yaml > output.json
bash -c "echo 'std.manifestYamlDoc(' && cat output.json && echo ')'" > output.jsonnet
jsonnetfmt -i --indent 2 --max-blank-lines 2 --sort-imports --string-style s --comment-style s output.jsonnet # fmt
# edit output.jsonnet file here
jsonnet -S output.jsonnet # outputs .yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment