0

How can I get .Values.someVal from values.yaml file or passed through cli inside a {{ range .Values.smtg }} loop?

for eg.

spec:
      containers:
      {{ range $k, $v := .Values.smtg }}
      - name: {{ $k }}
        image: {{ printf "%s:%s" (required "no img" $v) (required "no tag" .Values.someVal) | quote }}   <<<--- how can I get .Values.someVal from values.yaml or cli? 
      {{- end }}

If I try to get them with .Values.smtg I will got : ... at <.Values.someVal>: nil pointer evaluating interface {}

David Maze
  • 130,717
  • 29
  • 175
  • 215
Padi
  • 711
  • 9
  • 18

1 Answers1

4

Use $.Values.someVal. The $ will always point to the root context:

spec:
  containers:
  {{ range $k, $v := $.Values.smtg }}
  - name: {{ $k }}
    image: {{ printf "%s:%s" (required "no img" $v) (required "no tag" $.Values.someVal) | quote }} 
  {{- end }}
chresse
  • 5,486
  • 3
  • 30
  • 47