Search code examples
kubernetes-helm

Helm templating doesn't let me use dash in names


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?


Solution

  • 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