How can I reference a helm array parameter with index

2/7/2020

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
kubernetes-helm
yaml

1 Answer

2/10/2020

try

{{ with index .Values.spec.containers 0 }}
containerReference: {{ .name | quote }}
{{ end }}
-- Yuri G.
Source: StackOverflow