3 ms·
Yeah. It’s a pretty sweet tool. What’s also pretty awesome about it is that its interpreters (one C++ and one Go implementation) can also easily be embedded int
by EdSchouten 7y ago
Yeah. It’s a pretty sweet tool. What’s also pretty awesome about it is that its interpreters (one C++ and one Go implementation) can also easily be embedded into custom applications.
For an Open Source project of mine (https://github.com/buildbarn https://github.com/buildbarn, a remote build cluster implementation for the Bazel build system), we are using go-jsonnet as the config file parser library. This means that people can use JSON, but if they need something that’s more flexible, they can add Jsonnet statements immediately. It’s also possible to have that as a preprocessing stage (init scripts), but in a containerized world it’s easier to have it embedded.
One of the nice things about doing that is that I also don’t need to write code to load TLS certificate data from disk. People can either embed their secrets directly into the config file, or they can use Jsonnet’s ‘importstr’ keyword to load separate PEM files from disk.
Somewhat related to that: Jsonnet also allows people to write libraries for constructing more complex JSON files. For example, the Grafana folks have released a library (https://github.com/grafana/grafonnet-lib https://github.com/grafana/grafonnet-lib) that allows you to easily build Grafana dashboards from code.
- iudqnolq 7y ago> This means that people can use JSON, but if they need something that’s more flexible, they can add Jsonnet statements immediately. That sounds awesome. I'd expect it's worth it just to have self and $. And not only that, jsonnet can also produce yaml and ini files. I might try using it to configure my whole machine...