
YAML templating tool that works on YAML structure instead of text - alexellisuk
https://github.com/k14s/ytt
======
birchb
These days devops workers often have no choice but to write scads of YAML for
tools like GoCD, Concourse, K8s etc etc. To be efficient we turn to tools like
Helm. But I recommend everyone write their own TC YAML tool - it does not take
long and it's fun. If you don't have time, you can use mine.

I wrote two 'macro processor's for YAML. Yamp (in Python,
[https://github.com/birchb1024/yamp](https://github.com/birchb1024/yamp)) and
GoYamp (GoLang,
[https://github.com/birchb1024/goyamp](https://github.com/birchb1024/goyamp)).
GoYamp is fast. Some of my users have generated thousands of YAML files with
them.

IMO ytt is not as good because it seems to embed its syntax in comments. You
can use tools like m4 and Jinja2 but you'll be counting indentations all day.
Yamp and GoYamp are 100% YAML so indentation just works. Start here:
[https://github.com/birchb1024/goyamp](https://github.com/birchb1024/goyamp) !

~~~
brigandish
TC?

~~~
birchb
Turing Complete

------
Spivak
How did we get to the point of templating YAML files when it’s a superset of
JSON? Why not just generate a JSON object?

At what point do we get so deep into templates that we just admit that
anything short of a programming language just isn’t expressive enough for a
config file? I mean that probably wouldn’t solve it either — people would just
template the script.

~~~
jacques_chester
> _At what point do we get so deep into templates that we just admit that
> anything short of a programming language just isn’t expressive enough for a
> config file?_

At the point where I'm debugging configuration instead of declaring it.

There is no sweeping answer, because the scope of configuration varies
according to the tool. Systems like Kubernetes or Concourse accept _records_
rather than configuration per se. At least conceptually, these are projections
of an underlying model. They are not the model itself and won't be the most
compact representation.

Because they are projections, they will inevitably fail to fulfill some degree
of schematic normalisation. This means repetition, which for most engineers is
interpreted as "I need a loop" instead of "I need a set notation".

I prefer ytt to most alternatives I've seen because it's at least trying to
avoid introducing unwanted Turing completeness. Where possible, your
configuration language shouldn't be an attack vector.

I'd prefer a more relational or logical style of configuration (I expect CUE
folks will be here shortly), but given the continuing efforts to disguise and
hide even SQL from programmers, I'm not going to hold my breath.

------
jacques_chester
I think a more useful link is [https://get-ytt.io/](https://get-ytt.io/),
which includes an interactive playground.

