How to use the third variable in range?

Viewed 21

There are variables in values.yaml of my Helm Chart:

stand: dev-gfdz-loader
ingress1:
  entrypoints: pdu

In Helm Chart I have:

      {{- range $key, $value := $.Values.secretObjects }}
      - secretKey: {{ $key | quote}}
        objectName: {{ $value | quote }}
        secretPath: "pdu/data/dev-gfdz-loader"
      {{- end }}

This example is working.

In the line "pdu/data/dev-gfdz-loader" I need: replace pdu with ingress1.entrypoints and replace dev-gfdz-loader with stand

Finally, if I do this:

      {{- range $key, $value := $.Values.secretObjects }}
      - secretKey: {{ $key | quote}}
        objectName: {{ $value | quote }}
        secretPath: "{{ .Values.ingress1.entrypoints }}/data/{{ .Values.stand }}"
      {{- end }}

Then I get an error:

 Error: template: app/charts/rr/templates/secretproviderclass.yaml:23:31: executing "app/charts/rr/templates/secretproviderclass.yaml" at <.Values.ingress1.entrypoints>: can't evaluate field Values in type interface {} Use --debug flag to render out invalid YAML
1 Answers

My solution:

      {{- $entrypoints := .Values.ingress1.entrypoints -}}
      {{- $stand := .Values.stand -}}
      {{- range $key, $value := $.Values.secretObjects }}
      - secretKey: "{{ $key }}"
        objectName: "{{ $value }}"
        secretPath: "{{ $entrypoints }}/data/{{ $stand }}"
      {{- end }}
Related