News for hackers. Stuff that matters.
Re:Jsonnet – A data templating language by moltar on Saturday April 13, 2019 @09:33PM (#19656973)
Exactly my thoughts. I don’t see how it’s better than JS or TypeScript. I can render any object into JSON.

This is in fact how I manage Kubernetes manifests.

I use this package: https://www.npmjs.com/package/kubernetes-models

Then I write normal TypeScript code to create Kubernetes objects/resources.

Then I render it to JSON and feed to kubectl.

The beauty of this solution is that it’s OOP and DRY.

Re:Jsonnet – A data templating language by atombender on Saturday April 13, 2019 @11:47PM (#19657498)
You're assuming that all code can be trusted. Jsonnet is much easier to make secure than JS, since it can be statically guaranteed to be safe and side-effect-free (e.g. can't access the file system). This permits evaluating arbitrary untrusted data, which can be a boon to systems like CI servers, databases, or even Kubernetes (think Helm charts).
Re:Jsonnet – A data templating language by CraftThatBlock on Sunday April 14, 2019 @12:41AM (#19657642)
He is producing JSON, just as you said. Not sure you understood him.

He has a TS script that outputs JSON, which he is using as config.

Re:Jsonnet – A data templating language by atombender on Sunday April 14, 2019 @01:16AM (#19657722)
The script to generate that JSON is code. Jsonnet also generates JSON. So his script is filling the same role as Jsonnet would. The point stands.

He might trust his code, but I was highlighting reasons why this is not true everywhere, and indeed the ability to evaluate untrusted code can open up previously unavailable avenues. For example, storing server-side Jsonnet that can be safely evaluated by a multitenant backend.