Helm templating doesn't let me use dash in names

Viewed 20693

I am creating a helm chart for my app. In the templates directory, I have a config-map.yaml with this in it

{{- with Values.xyz }} 
  xyz.abc-def: {{ .abc-def }} 
{{- end }}

When I try to run helm install I get a

Error: parse error in "config-map.yaml": template:config-map.yaml:2: unexpected bad character U+002D '-' in command.

Is there a way to use dashes in the name and variable for helm?

2 Answers

Might be worth trying using index method:

xyz.abc-def: {{ index .Values.xyz "abc-def" }}

looks like it's still restricted by helm to allow hyphens in variable names (as well in subchart names) and index is a workaround

I faced the same issue because the resource defined had a '-' in its name:

resources:
            {{- with .Values.my-value }}

After I removed the '-', the error disappeared:

resources:
            {{- with .Values.myvalue }}
Related