4 ms·
> Templating yaml is a terrible, terrible idea I've had a good time using ytt: https://carvel.dev/ytt/ https://carvel.dev/ytt/. It implements language-aware te
by haileys 4y ago
> Templating yaml is a terrible, terrible idea
I've had a good time using ytt: https://carvel.dev/ytt/ https://carvel.dev/ytt/. It implements language-aware templating, which is IMO the only reasonable way to do it.
- kevincox 4y agoLanguage aware is definitely important. But honestly I've usually found it easier to use a "real programming language" to generate the structures. You can read and write as normal. Then you can just serialize them to YAML at the end. Helm is so bad. It has a `| quote` function that is almost always wrong. People use it to escape strings into YAML strings but it just adds quotes around the values. It doesn't actually escape to YAML. I had a surprising hard time convincing people that they should be using `| toJson` and ideally be doing it for every interpolation. But really working with text is just an inconvenience here. You can imagine how much better everything would work if your base template was `console.log(JSON.stringify({ /* your config here */ }))`