Hacker News new | ask | show | jobs
by jsmith45 1167 days ago
It is really just arrays of objects/dicts that get complicated with TOML. For dictionary properties not inside an array, you can either fully specify the path `foor.bar.baz = 7`, or use a header like `[foo.bar]` and specify `baz=7`.

Also if I was handwriting that I would probably make more use of doted property names implying dictionaries like so, which though it has a little bit more repetition in property names, seems easier to read:

    apiVersion = "v1"
    current-context = ""
    kind = "Config"

    [[clusters]]
    name = "my-cluster"
    cluster.certificate-authority-data = "LS0tL..."
    cluster.server = "https://example.com"

    [[contexts]]
    name = "context0"
    context.cluster = "my-cluster"
    context.user = "my-user"

    [[contexts]]
    name = "context1"
    context.cluster = "my-cluster"
    context.user = "my-user"

    [[users]]
    name = "my-user"
    user.exec.apiVersion = "client.authentication.k8s.io/v1beta1"
    user.exec.args = ["eks", "get-token"]
    user.exec.command = "aws"
If k8s was designed with TOML in mind, it probably have been structured differently, such that "Contexts" for example might be just a dictionary mapping names to an object that has the values from the "context" property (The existing pattern of an array of objects where each object has a name, but store most of their properties in a property whose name matches the object's type is already weird, but doesn't look terrible in yaml.)

Such a redesigned to be a more TOML friendly schema would then look like this:

    apiVersion = "v1"
    current-context = ""
    kind = "Config"

    [clusters.my-cluster]
    certificate-authority-data = "LS0tL..."
    server = "https://example.com"

    [contexts.context0]
    cluster = "my-cluster"
    user = "my-user"

    [contexts.context1]
    cluster = "my-cluster"
    user = "my-user"

    [users.my-user.exec]
    apiVersion = "client.authentication.k8s.io/v1beta1"
    args = ["eks", "get-token"]
    command = "aws"