Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Seriously. I’ve lost at least 100 hours of my life debugging whitespace in templated yaml. I shudder to think about the total engineering time wasted since yaml’s invention.


You blame YAML but I blame helm. I can build a dict in Python and dump it as YAML. I've painlessly templated many k8s resources like this. Why can't we build helm charts in a DSL or more sensible syntax and then dump k8s manifests as YAML? Using Go templating to build YAML is idiocy and the root of the issue here.

There's lots of advice on StackOverflow against building your own JSON strings instead of using a library. But helm wants us to build our own YAML with Go templating. Make it make sense.


I 100% agree. It’s not so much the yaml as it is the templating. I originally wanted to say “since the invention of yaml/jinja” in the parent comment because that’s what I’ve gotten most of my gray hairs from (saltstack templating). Go templates are not jinja but fundamentally the same thing - they have no syntax awareness and effectively are just string formatters.

I took out the part about templating because I thought it made my comment too wordy, but ended up oversimplifying.


This is more or less the approach Apple's "pkl" takes.

You define your data in the "pkl language", then it outputs it as yaml, json, xml, apple property list, or other formats.

You feed in something like:

    apiVersion = "apps/v1"
    kind = "Deployment"
    metadata {
     name = "my-deployment"
     labels {
      ["app.kubernetes.io/name"] = "my-deployment"
      ["app.kubernetes.io/instance"] = "prod"
     }
    }
    spec {
     replicas = 3
     template {
      containers {
       new {
        name = "nginx"
       }
       new {
        name = "backend"
       }
      }
     }
    }
And then you `pkl eval myfile.pkl -f yaml` and get back:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: my-deployment
      labels:
        app.kubernetes.io/name: my-deployment
        app.kubernetes.io/instance: prod
    spec:
      replicas: 3
      template:
        containers:
        - name: nginx
        - name: backend
The language supports templating (structurally, not textually), reuse/inheritance, typed properties with validation, and a bunch of other fun stuff.

They also have built in package management, and have a generated package that provides resources for simplifying/validating most kubernetes objects and generating manifests.

There's even a relatively easy path to converting existing YAML/JSON into pkl. Or the option to read an external YAML file and include it/pull values from it/etc (as data, not as text) within your pkl so you don't need to rebuild everything from the ground up day 1.

Aaaaand there's bindings for a bunch of languages so you can read pkl directly as the config for your app if you want rather than doing a round trip through YAML.

Aaaaand there's a full LSP available. Or a vscode extension. Or a neovim extension. Or an intellij extension.

The documentation leaves a bit to be desired, and the user base seems to be fairly small so examples are not the easiest to come by... but as far as I've used it so far it's a pretty huge improvement over helm.


Yaml wouldn't be so bad if they made the templates and editors indent-aware.

Which is a thing with some Python IDEs, but it's maddening to work on anything that can't do this.


    autocmd FileType yaml setlocal et ts=2 ai sw=2 nu sts=0
I'm sure Emacs and others have something similar




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: