News for hackers. Stuff that matters.
Re:Validating Kubernetes YAML for best practice and policies by jasonlotito on Sunday August 09, 2020 @09:12AM (#24099393)
You are using YAML already. How much do you care about best practices.

Only partially kidding here.

Re:Validating Kubernetes YAML for best practice and policies by EdwardDiego on Sunday August 09, 2020 @10:06AM (#24099718)
You're currently being downvoted, but I agree, YAML is kinda terrible, not sure why anyone thought Python's syntactically relevant whitespace was ideal for a config file.

Classic example:

  - containerPort: 7173
    name: http
I think that's an object in a list? But it's not overly clear.And if I indented any of those lines wrong...
Re:Validating Kubernetes YAML for best practice and policies by pydry on Sunday August 09, 2020 @10:36AM (#24099887)
>not sure why anyone thought Python's syntactically relevant whitespace was ideal for a config file.

Because it reduces syntactic noise and increases informational density.

Most other serialization formats end up putting in indentation anyway to make them readable (JSON, TOML).

Re:Validating Kubernetes YAML for best practice and policies by dmitriid on Sunday August 09, 2020 @10:21AM (#24099814)
Don't forget the plethora of truthy values that put Javascript to shame.

   - country: NO
Of course it's boolean
Re:Validating Kubernetes YAML for best practice and policies by riffraff on Sunday August 09, 2020 @02:16PM (#24101641)
that was changed in YAML 1.2[0], which I think is many years old, but people don't specify a version on config files anyway and I'm not even sure most parsers respect it, so it keeps popping up, which is sad.

[0] https://yaml.org/spec/1.2/spec.html#id2803629

Re:Validating Kubernetes YAML for best practice and policies by dmitriid on Monday August 10, 2020 @02:30AM (#24106221)
That's the problem with bad formats: they live forever. They and any number of parsers for any version between version 0 and now.
Re:Validating Kubernetes YAML for best practice and policies by aliswe on Sunday August 09, 2020 @10:58AM (#24100010)
That's a map as a list element, iirc the terminology. But check out this.

When studying the Yaml spec I discovered that a map property (key: value) can have not only a string as its key, but any value. Even a list. (cue screams)

Re:Validating Kubernetes YAML for best practice and policies by shahsyed on Sunday August 09, 2020 @11:03AM (#24100034)
Here's another reason why YAML is bad:

the fact that I have to read the spec to figure out what's going on.

It should have been fairly simple to do this.

Why do I have to know the difference between ":" and "=" ...?

Re:Validating Kubernetes YAML for best practice and policies by Already__Taken on Sunday August 09, 2020 @11:58AM (#24100440)
Why didn't anyone learn from CSS when we all made pre-processors like stylus, less and sass that added white-space sensitivity. It's not great.

I thought HCL was one of the best attempts at a terse config language. Shortening foo { bar { bazz {} }} to foo bar baz{} cleans up plenty.

Re:Validating Kubernetes YAML for best practice and policies by corty on Sunday August 09, 2020 @10:17AM (#24099785)
also, keywords of the underlying software mechanisms are decoupled, so uncheckable for plain YAML tooling. Whereas with XML you can at least infer a lot about the desired structure and keywords from the schema. Deeper checks are only possible with "real" programming languages, preferrably statically typed ones. I'm wondering when that wisdom trickles down to configuration languages.
Re:Validating Kubernetes YAML for best practice and policies by corty on Sunday August 09, 2020 @10:07AM (#24099727)
YAML is unusable without a sufficiently capable linter. Syntax is very fragile and completely decoupled from function.
Re:Validating Kubernetes YAML for best practice and policies by shahsyed on Sunday August 09, 2020 @11:01AM (#24100028)
You're partially kidding but you're 100% right.

Someone in another thread mentioned using some LISP or LISP-like language to solve this problem.

Would something like TOML make things better here?

What would have been the solution?

Re:Validating Kubernetes YAML for best practice and policies by rgoulter on Sunday August 09, 2020 @12:53PM (#24100903)
Dhall is an example of a configuration language. Its programs must terminate. It aims for safety, claiming that it can support safe evaluation of untrusted code. https://dhall-lang.org/

TBH, I have no experience with it. But, it sounds like if you need a configuration language with programmatic features, it would be more suited to the job than a general purpose programming language.

Re:Validating Kubernetes YAML for best practice and policies by pjmlp on Sunday August 09, 2020 @11:18AM (#24100107)
XML, but I guess I won't get many friends for asserting that.
Re:Validating Kubernetes YAML for best practice and policies by juped on Sunday August 09, 2020 @01:48PM (#24101374)
I really regret disliking XML all those years ago, now that I've seen the alternative.
Re:Validating Kubernetes YAML for best practice and policies by secondcoming on Sunday August 09, 2020 @11:38AM (#24100277)
Nope. Json has schema validation too, and every language has a json parser
Re:Validating Kubernetes YAML for best practice and policies by pjmlp on Sunday August 09, 2020 @11:44AM (#24100320)
JSON doesn't do comments.
Re:Validating Kubernetes YAML for best practice and policies by secondcoming on Sunday August 09, 2020 @12:16PM (#24100605)
Not officially, but it's fakeable
Re:Validating Kubernetes YAML for best practice and policies by pjmlp on Sunday August 09, 2020 @12:28PM (#24100694)
Which for me is a design smell, why bother with workarounds when XML already offers me all the best tooling out of the box.
Re:Validating Kubernetes YAML for best practice and policies by secondcoming on Sunday August 09, 2020 @09:23PM (#24104554)
For me, xml is just too much, and when working with C or C++ (not t sure about rust) it's just a pain. Can your json schema file not serve as the documentation?
Re:Validating Kubernetes YAML for best practice and policies by pjmlp on Monday August 10, 2020 @01:42AM (#24105938)
Why should it be a pain? Parsing XML is no different than parsing JSON, there are plenty of robust parsers available since around 2000.

Mature libraries with plenty of experience deploying into production.

Plus for small enough stuff, like configuration files, one can just plug XPATH as well, making the search for items even easier.

Re:Validating Kubernetes YAML for best practice and policies by jayd16 on Sunday August 09, 2020 @01:08PM (#24101027)
If something like k8s implemented comments as specific comment fields that would actually be pretty useful. The fields could be parsed and show in GUIs.
Re:Validating Kubernetes YAML for best practice and policies by secondcoming on Sunday August 09, 2020 @09:12PM (#24104487)
That is the workaround, just add it as "comment":"comment text". Having one comment for each field in an object would get unwieldy though. Anther place for them is possibly in the json schema file.
Re:Validating Kubernetes YAML for best practice and policies by jiangplus on Sunday August 09, 2020 @12:41PM (#24100798)
Then use HTML and extend the functionality with JSX
Re:Validating Kubernetes YAML for best practice and policies by pjmlp on Sunday August 09, 2020 @01:13PM (#24101064)
Useless work when XML already has all the tooling available and battle tested in production.