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

In the Kubernetes and Ansible/Salt world it's frequently templatized, and then you need to worry about indentation that you place or your template engine places. Every day I pray that Helm will incorporate support for jsonnet so I never need to touch YAML again.


I made a script for expressing similar deployments (ie homepage-en, homepage-de) in a variety of contexts (test, prod) and their permutations in a single, succinct json file.

It's a bash script though.

Example json:

  {
  "deployments": [
    {
      "name": "site-en",
      "env": {
        "hello": "world"
      }
    }
  ],
  "targets": [
    {
      "name": "dev",
      "context": "aks-dev",
      "env": {
        "ipsum": "dolor"
      }
    }
  ]
  }


You should look into Kustomize. It's built into Kubectl, and lets you do something like this in a much more modular way.


I agree with, and have felt the same pain as you here. But this isn't YAML's fault, IMO, it is that the templaters, like Helm, aren't safe, and don't escape their outputs.

If have a string, and I use that in the middle of a YAML template, I expect a string — I don't expect "300" to become (integer) 300; give me a function for that conversion.

Any HTML templating system that behaved this way would be frowned upon due to the potential for XSS. There's little risk of XSS here, but it's still annoying to get the wrong results.


Why not parse the YAML- manipulate it like you would any other data structure in your language of choice, and then generate the YAML from there?

I don't understand why you would want to directly edit markup language without parsing it. YAML's goal is to represent a data structure so that a human can interact with it. It accomplishes that goal well. If you want to edit that data structure programmatically- no markup language makes sense to use, represent the data structure using your programming language's native representations.




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

Search: