For some reason I cannot get list values to be preserved in helm template:
job.yaml:
args: {{ .Values.args }}
values.yaml:
args: ["-c","echo 'test'; sleep 5"]
helm template --debug:
args: [-c echo 'test'; sleep 5]
What am I missing ?
When you do {{ .Values.args }}
, you get the value from the values file as go data structure, so that you may use it in different ways.
In your case, this is a slice. If you print a slice in go, it will look like this [a b c]
, no commas or quotes, for example. That's what you see here.
The usual technique is using toJson
or toYaml
.
args: {{- .Values.args | toYaml | nindent 2 }}
args: {{ .Values.args | toJson }}
Note, the value for nindent
depends on where in your template you use this. 2 is probably not correct, it should be at least 2 more indented than args is in your template.