#23
in
JSON
#39
in
Kubernetes
Templating yaml with a text templating language like Helm's templating language is a terrible idea. Templating objects and serializing them to Yaml (with input also being Yaml) I find quite nice: https://github.com/con2/emrichen
It isn’t clear whether they already use Racket.
If Racket was added for this purpose then here are a couple boring[0] solutions that could have lower operational costs.
Generate OpenAPI specifications from your service code.
Use a YAML preprocessor/template engine such as [1]. I have used a similar technique to generate SQL queries.
I'd rephrase the question: "Why are we templating YAML with text-based templating tools?"
I and @akx wrote a templating tool called Emrichen that's specifically designed for producing YAML and JSON from YAML templates:
https://github.com/con2/emrichen
In contrast to other template systems, Emrichen templates are not just "based on YAML", they _are_ YAML. YAML tags like "!Var varname" are used to perform things like variable substitution, loops etc. Variables can be of any JSON type, not just strings, and the template is evaluated top–down.