helmfile icon indicating copy to clipboard operation
helmfile copied to clipboard

feat: Support YAML dotfile notation for helmfile

Open themanifold opened this issue 5 years ago • 11 comments

Looks like the yaml package you use (https://godoc.org/gopkg.in/yaml.v2) doesn't explicitly support dot file notation in your YAML. What I mean is:

a.b.c: "foo"

Instead of

a:
  b:
    c: "foo"

In some cases, when I want to access a deeply nested YAML structure, this would be great. It's also a shortcut supported in helm itself, so we should probably support it too.

As a small aside, it looks like helm uses sigs.k8s.io/yaml - we could just leverage that right? That supports dotfile notation.

themanifold avatar Nov 06 '19 08:11 themanifold

@themanifold Hey! This sounds good. The only concern is that - how can you include dot in the key name if that's what you want?

In other words, does sigs.k8s.io/yaml allows you to differentiate a.b.c: foo for {"a":{"b":{"c":"foo"}}} and {"a.b.c": "foo"}?

mumoshu avatar Nov 07 '19 12:11 mumoshu

No, I think you need to escape the dots if you want them to actually be part of a key.

This is an example: https://stackoverflow.com/questions/49522776/helm-how-to-override-value-with-periods-in-name

themanifold avatar Nov 08 '19 09:11 themanifold

@themanifold Thanks!

Okay, that makes sense for me, but it might be a breaking change for existing users who relies on that we don't need escaping dots in the key today.

Is there anyone relies it?

@osterman @gtaylor @sstarcher @bitsofinfo Does any of your helmfile modules use a.b.c-styled keys in values?

mumoshu avatar Nov 09 '19 00:11 mumoshu

Dots in keys is very common for Kubernetes annotations. We use them all over the place. E.g. Kiam, external dns, cert-manager, nginx-ingress elb settings, etc. annotations are passed in the values.

I think this optimization to Helmfile will cause more problems than it’s worth, unless there is backwards compatibility somehow.

osterman avatar Nov 09 '19 05:11 osterman

@osterman Thanks! That's a great point.

mumoshu avatar Nov 11 '19 09:11 mumoshu

@themanifold To make this backward-compatible, we're likely to need another configuration field than values: that supports it. But honestly I'm not sure if that's worth the complexity gain.

Alternatively, can we consider this as a part of #869? That is, there's another config language that supports a shorthand syntax for declaring a deeply nested yaml dict. In CUE specifically, a b c: "foo" works.

I won't say Helmfile is committed to support e.g. CUE, but the more use-cases one config language gets(jsonnet, lua, cue) the more likely it is being integrated into helmfile.

mumoshu avatar Nov 11 '19 09:11 mumoshu

@mumoshu I think supporting it in CUE is fine, but whatever you decide, we should make it clear. Because this project dealt with helm charts, I was under the false impression that it would support similar features to helm charts.

So just a note to say we don't support the dot file syntax is fine (and easier).

themanifold avatar Nov 11 '19 10:11 themanifold

I sometimes use literal keys w/ dots (i.e. think k8s labels are common usage of this) "some.label.name": "label-value" but I do have cases where i needed to set (via --set-values) a representation of a.b.c on the cmd line where c is a child of b is a child of a etc; but I don't reference it that way (i.e. flattened a.b.c: value in any YAML file directly, its always declared in a nested/indented child fashion.

recall: https://github.com/roboll/helmfile/issues/773

bitsofinfo avatar Nov 11 '19 14:11 bitsofinfo

Has anything happened regarding this proposal?

norman-zon avatar Apr 12 '22 12:04 norman-zon

@norman-zon Nothing. I believe this would add more problems than benefits.

mumoshu avatar Apr 12 '22 23:04 mumoshu

BTW- Does Helm support this dots-in-yaml-dict-keys-as-separators? Isn't it just that Helm supports dotted notations in --set?

mumoshu avatar Apr 12 '22 23:04 mumoshu