Skip to content

Instantly share code, notes, and snippets.

@pivotaljohn
Last active April 19, 2023 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pivotaljohn/7adda56da6e48970027453916b33029e to your computer and use it in GitHub Desktop.
Save pivotaljohn/7adda56da6e48970027453916b33029e to your computer and use it in GitHub Desktop.
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:toml", "toml")
#@ def app_config_secret():
kind: Secret
metedata:
name: app-config
#@ end
#@ def add_locale(conf_str):
#@ # parse to Starlark `dict`s and `list`s:
#@ conf = toml.decode(conf_str)
#@
#@ conf["Global"]["locale"] = "Amsterdam"
#@
#@ # create a new section by adding an empty dictionary
#@ conf["Locales"] = {}
#@ conf["Locales"]["Amsterdam"] = {}
#@ conf["Locales"]["Amsterdam"]["max_instances"] = 15
#@ conf["Locales"]["Amsterdam"]["min_instances"] = 4
#@
#@ # encode to TOML-formatted string
#@ return toml.encode(conf)
#@ end
#@overlay/match by=overlay.subset(app_config_secret())
---
stringData:
#@overlay/replace via=lambda old, new: add_locale(old)
app.conf:
kind: Secret
metedata:
name: app-config
stringData:
app.conf: |
[Global]
user = "FOO\\bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment