2

I have this helm parameters in a values.yaml file.

spec:
   containers: 
     - name: mycontainer
       image: my.image.url

I would like to reference the name and image parameters from another kubernetes-resource.yaml file with index.

I tried

containerReference: {{ index .Values.spec.containers[0].name | quote }} 

and

containerReference: {{ (index .Values.spec.containers 0).name | quote }} 

But I get: bad character U+002D '-'

voutsasg
  • 43
  • 1
  • 6
  • Can you give a little more complete example? What command are you running that produces that error? (There's almost no `-` in what you've shown.) – David Maze Feb 07 '20 at 11:59
  • kubernetes-resource.yaml is a k8s resource yaml in templates directory. The values.yaml is the standard helm values.yam. The error is triggered with helm install – voutsasg Feb 07 '20 at 12:05
  • Are you able to access other values? I am wondering because I think it should be `.Values` instead of `.Value`. – brass monkey Feb 07 '20 at 12:25
  • This is a typo, I am fixing right now – voutsasg Feb 07 '20 at 12:26

1 Answers1

7

try

{{ with index .Values.spec.containers 0 }}
containerReference: {{ .name | quote }}
{{ end }}
Yuri G.
  • 4,323
  • 1
  • 17
  • 32