Worse yet, in some places (CI/CD) YAML becomes nearly a programming language. A very verbose, unintuitive, badly specified and vendor-specific one as well.
Why are we templating YAML? (2019)
41–50 of 667 posts
Re: Why are we templating YAML? (2019)
#42I am really sad that jsonnet / ksonnet never really took off. It’s a great way to template, but has a bit of a learning curve in my experience. I suspect that is why it’s niche. If you like what is presented in this article, take a look at Grafana Tanka ( https://tanka.dev ).
The fact that it's a purely functional programming language with lazy evaluation is really powerful but steepens the learning curve for devs who haven't worked with functional languages. The stdlib is also pretty sparse, missing some commonly required functions.
does it really though? what part do they struggle with?
Re: Why are we templating YAML? (2019)
#43Re: Why are we templating YAML? (2019)
#44Worse yet, in some places (CI/CD) YAML becomes nearly a programming language. A very verbose, unintuitive, badly specified and vendor-specific one as well.
YAML becomes a programming language because vendors need a DSL for their system, and they need to present it in a form which every other language can mostly handle the AST for, which means it's easiest if it just lives atop a data transfer format.
Re: Why are we templating YAML? (2019)
#45- Not turing complete yet sufficiently expressive to DRY
- Define schema and data with the same language, in a separate or same file. With union types.
- Generate YAML or JSON. Can validate itself, or a YAML or JSON file.
The biggest drawback being the only implementation is currently in go, meaning you may have to subprocess of ffi.
Re: Why are we templating YAML? (2019)
#46Re: Why are we templating YAML? (2019)
#47Indeed why? However the conclusion I have is not to use JSON but to use a type safe configuration language that can express my intent much better making illegal states impossible. One example of such lang is Dhall. https://dhall-lang.org/
CDK over Cloudformation.
Don't hand craft configuration files, these aren't new lessons. I remember being first introduced to Troposphere, which was pretty awesome.
Re: Why are we templating YAML? (2019)
#48I just knew this would be about Kubernetes when I saw the title. The Kubernetes API is fairly straightforward, and has a well-defined (JSON) schema, people should be spending a bulk of their time learning k8s understanding how to use the API, but instead they spend it working out how to use a Helm chart. I don't think Jsonnet, Ksonnet, Nu, or CUE ever gained that much traction. I'm convinced most people just use Kust…
Re: Why are we templating YAML? (2019)
#49Why do we need a special purpose language for this? Just for the slightly nicer syntax? Is that worth learning a completely new language?
- It requires discipline for devs to keep the conf declarative. Discipline is not automatically enforceable, so it's prone to failure.
- No guarantee of reproducibility.
- You need a Python VM (or a starlark interpreter if that's what you like). It's a big constrain.
- If you are a Saas provider, accepting Python as input is really hard to secure.
Re: Why are we templating YAML? (2019)
#50Yes, it can be unsafe if you're not careful, but if you need to bang out a quick prototype it's the best tool there is. It's part of POSIX, and so it will always be available, the language is dead simple, and you can generate any text you want with it.
I wouldn't use it with YAML, but I would probably never template YAML in the first case: just generate JSON and feed it through `yq -y` if you need a quick YAML generator.