Jsonnet – The Data Templating Language

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • kubecfg

    A tool for managing complex enterprise Kubernetes environments as code. (by kubecfg)

  • kubecfg does add some features, like https:// imports, oci:// imports (oci bundles in OCI registries, transitively bundling all imported files with jsonnet-deps).

    But yes, I strive to keep the "one file, one target, import whatever you need but explicitly" as much as possible.

    I'm pouring some more time into the project and trying to implement some ideas I had for a long time but never managed to get them out. For example "Flags From Files" (https://github.com/kubecfg/kubecfg/blob/flagspec/docs/rfcs/r...) or "Caching + optional vendoring of immutable external deps".

  • cue

    The home of the CUE language! Validate and define text-based and dynamic configuration

  • We've been using Jsonnet to generate Pods for our complex DAGs at Opsgenie, wrote a similar one using Tekton: https://mustafaakin.dev/posts/2020-04-26-using-jsonnet-to-ge...

    But if I was doing it again now, I would just use https://cuelang.org/ or https://dagger.io Jsonnet is really hard to debug.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • aperture

    Rate limiting, caching, and request prioritization for modern workloads

  • - Blueprints are implemented using Jsonnet bindings. The users generate policies from blueprints by providing configuration in yaml (using aperturectl CLI) or via jsonnet mixin.

    Relevant links:

    - Aperture Blueprints (Jsonnet): https://github.com/fluxninja/aperture/tree/main/blueprints

  • jsonnet

    Jsonnet - The data templating language

  • nix

    Nix, the purely functional package manager

  • The nix language, albeit for a package manager, is really similar. You get json-like "attrsets" and can have variables and functions. Then of course you can export it to different formats as well.

    https://nixos.org

  • grafonnet-lib

    Discontinued Jsonnet library for generating Grafana dashboard files.

  • I honestly... don't know. I have been using Jsonnet to programatically generate Grafana dashboards, because AFAIK the only official library to generate them is written in Jsonnet [1].

    In my experience, it works, but it doesn't really give me any distinct advantage. Maybe for things that look almost like JSON it'd be helpful, but the moment you start dealing with more complex generations you start finding lack of typing, lack of IDE support, lack of easy debugging, etc, fairly problematic. For example, something I really dislike is that due to how the expressions are evaluated, the only way to add debug/trace statements is to use them to "transform" a value you're going to use, if you don't use the result of the trace in the final output, the trace does not appear.

    1: https://github.com/grafana/grafonnet-lib

  • github-desktop

    A version of GitHub Desktop packaged with Conveyor

  • Yes that's a common problem with config languages. They're torn between competing priorities:

    1. Fast to parse with a small engine, good error messages, safe to evaluate.

    2. Powerful, can express config with arbitrary logic.

    In Conveyor we try an alternative approach. The config is HOCON, which is a superset of JSON syntax designed for human readability/writability/convenience first and foremost, so it's got a very nice and clean feel to it. You can see an example here:

    https://github.com/hydraulic-software/github-desktop/blob/co...

    It can be parsed with a normal-sized config library and the errors you get are reasonable.

    But then what if you hit the limits of what it can express? We added support for "hashbang includes":

        include "#!script.js"

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  • dagger

    Application Delivery as Code that Runs Anywhere (by dagger)

  • We've been using Jsonnet to generate Pods for our complex DAGs at Opsgenie, wrote a similar one using Tekton: https://mustafaakin.dev/posts/2020-04-26-using-jsonnet-to-ge...

    But if I was doing it again now, I would just use https://cuelang.org/ or https://dagger.io Jsonnet is really hard to debug.

  • sprig

    Useful template functions for Go templates.

  • The discoverability of golang templates is terrible, IMHO, since it's missing a "dir(locals())" equivalent and every execution environment gets to make its own rules about what pipelines/functions are exposed

    Look at helm as an example: https://helm.sh/docs/chart_template_guide/function_list/ is some of them, https://helm.sh/docs/chart_template_guide/accessing_files/#p... are some others, but they also glued in some version of https://masterminds.github.io/sprig/ So, short of (a) knowing that's the case (b) having 3+ bookmarks in your favorite browser to refer to those reference pages, how would anyone know what pipelines are available?

    Separately, I dooooo nooooooot understand why every joker has to invent their own new thing when we have like 50 or so templating languages already. Golang may be an outlier in that competition due to the Google Promotion Packet Effect(tm) but how they came up with `{{ range }}{{ end }}` as sane syntax is some true facepalm, to say nothing of the same landmine that ansible stepped on by not switching jinja2's default characters: `{{` is not _yaml safe_

  • isopod

    An expressive DSL and framework for Kubernetes configuration without YAML

  • Tried it[0], worked reasonably well. Be prepared for strong opposition from traditional “devops” folks “who don’t mind yaml” and will drag everyone down.

    [0] - https://github.com/cruise-automation/isopod

  • hof

    Framework that joins data models, schemas, code generation, and a task engine. Language and technology agnostic.

  • kubectl-neat-diff

    De-clutter your kubectl diff output using kubectl-neat

  • Original creator of both of those here. I recommend just generating things out straight with the `jsonnet -m` command, and then doing `kubectl diff` on a PR and apply on merge. Scaled huge amount of infra this way and it’s easily understandable and extensible.

    To clean up the diff a bit I recommend using: https://github.com/sh0rez/kubectl-neat-diff

    Hope it’s helpful!

  • rules_jsonnet

    Jsonnet rules for Bazel

  • I can definitely sympathize here - in every context, just straight JSON/YAML configuration seems never expressive enough, but the tooling created in response always seems to come with sharp edges.

    Here are some of the things I appreciate about Jsonnet:

    - It evals to JSON, so even though the semantics of the language are confusing, it is reasonably easy to eval and iterate on some Jsonnet until it emits what one is expecting - and after that, it's easy to create some validation tests so that regressions don't occur.

    - It takes advantage of the fact that JSON is a lowest-common-denominator for many data serialization formats. YAML is technically a superset of JSON, so valid JSON is also valid YAML. Proto3 messages have a canonical JSON representation, so JSON can also adhere to protobuf schemas. This covers most "serialized data structure" use-cases I typically encounter (TOML and HCL are outliers, but many tools that accept those also accept equivalent JSON). This means that with a little bit of build-tool duct-taping, Jsonnet can be used to generate configurations for a wide variety of tooling.

    - Jsonnet is itself a superset of JSON - so those more willing to write verbose JSON than learn Jsonnet can still write JSON that someone else can import/use elsewhere. Using Jsonnet does not preclude falling back to JSON.

    - The tooling works well - installing the Jsonnet VSCode plugin brings in a code formatter that does an excellent job, and rules_jsonnet[0] provides good bazel integration, if that's your thing.

    I'm excited about Jsonnet because now as long as other tool authors decide to consume JSON, I can more easily abstract away their verbosity without writing a purpose-built tool (looking at you, Kubernetes) without resorting to text templating (ahem Helm). Jsonnet might just be my "one JSON-generation language to rule them all"!

    ---

    Though if Starlark is your thing, do checkout out skycfg[1]

    [0] - https://github.com/bazelbuild/rules_jsonnet

    [1] - https://github.com/stripe/skycfg

  • skycfg

    Skycfg is an extension library for the Starlark language that adds support for constructing Protocol Buffer messages.

  • I can definitely sympathize here - in every context, just straight JSON/YAML configuration seems never expressive enough, but the tooling created in response always seems to come with sharp edges.

    Here are some of the things I appreciate about Jsonnet:

    - It evals to JSON, so even though the semantics of the language are confusing, it is reasonably easy to eval and iterate on some Jsonnet until it emits what one is expecting - and after that, it's easy to create some validation tests so that regressions don't occur.

    - It takes advantage of the fact that JSON is a lowest-common-denominator for many data serialization formats. YAML is technically a superset of JSON, so valid JSON is also valid YAML. Proto3 messages have a canonical JSON representation, so JSON can also adhere to protobuf schemas. This covers most "serialized data structure" use-cases I typically encounter (TOML and HCL are outliers, but many tools that accept those also accept equivalent JSON). This means that with a little bit of build-tool duct-taping, Jsonnet can be used to generate configurations for a wide variety of tooling.

    - Jsonnet is itself a superset of JSON - so those more willing to write verbose JSON than learn Jsonnet can still write JSON that someone else can import/use elsewhere. Using Jsonnet does not preclude falling back to JSON.

    - The tooling works well - installing the Jsonnet VSCode plugin brings in a code formatter that does an excellent job, and rules_jsonnet[0] provides good bazel integration, if that's your thing.

    I'm excited about Jsonnet because now as long as other tool authors decide to consume JSON, I can more easily abstract away their verbosity without writing a purpose-built tool (looking at you, Kubernetes) without resorting to text templating (ahem Helm). Jsonnet might just be my "one JSON-generation language to rule them all"!

    ---

    Though if Starlark is your thing, do checkout out skycfg[1]

    [0] - https://github.com/bazelbuild/rules_jsonnet

    [1] - https://github.com/stripe/skycfg

  • nickel

    Better configuration for less

  • relevant: https://github.com/tweag/nickel#comparison-with-other-config...

    FWIW, "YAML Typing = None" is for sure wrong, that's what the `!!map` annotations (https://yaml.org/spec/1.1/#tag/syntax) are for, and a very common RCE vector for dynamic languages since they can cause execution when the parser instantiates the types

  • jk

    Configuration as Code with ECMAScript

  • ursonnet

    experimental ur-cause tracer for jsonnet

  • The tool lives in https://github.com/mkmik/ursonnet . I got the basics working but it doesn't work on my larger codebases due to some bug I didn't have yet time hunting down. Having some interest/feedback/help from the community would help making this a reality.

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • What Is Wrong with TOML?

    15 projects | news.ycombinator.com | 13 Sep 2023
  • Show HN: Keep – GitHub Actions for your monitoring tools

    5 projects | news.ycombinator.com | 4 Sep 2023
  • What is the most common approach to configure a backend app?

    4 projects | /r/golang | 5 Jun 2023
  • Kubernetes Enthusiasts: Share Your Ideas for Future Dev Tools

    8 projects | news.ycombinator.com | 24 May 2023
  • Should i migrate from Kustomize to Helm?

    6 projects | /r/devops | 25 Nov 2022