0
votes

I am trying to pull values out of a kubernetes helm chart values.yaml that has a number as one of the keys and I'm getting a parse error unexpected ".1" in operand. How can I access values that contain a number in its path?

Let's say my values.yaml looks like this:

global:
  foo:
    bar1: 1
  1:
    bar2: 2

Using helm charts, I can access bar1 by typing: {{ .Values.global.foo.bar1 }}.

If I try to do the same with accessing bar2 by typing: {{ .Values.global.1.bar2 }} I receive a parse error. It doesn't get better if I try to use brackets {{ .Values.global[1].bar2 }}, quotes {{ .Values.global."1".bar2 }}, or brackets and quotes: {{ .Values.global["1"].bar2 }}.

I know that helm charts utilize golang templates under the hood, is there some kind of template I could create to extract this information?

Thanks so much!

1

1 Answers

2
votes

The easy option is to just quote it in your values file so it's a string but:

{{ index .Values.globals 1 "bar2"}}

is probably what you want.