0
{{- with .Values.environment.staging }}
    value: {{ .baseUrl }}
{{- end }}

I want to set the environment value staging dynamically based on the key value pair stored in podAnnotations.

{{- $envValue := .Values.podAnnotations.environment }}

The above two expressions work independently but not when combined as following:

{{- with .Values.environment "." $envValue }}
    value: {{ .baseUrl }}
{{- end }}

I'm not exactly sure how to concatenate a local variable within the with statement in helm. Solution to fix the problem or any links to documentation would be useful.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
DhiwaTdG
  • 748
  • 1
  • 10
  • 26
  • Does this answer your question? https://stackoverflow.com/a/41614235/13860 – Jonathan Hall May 18 '21 at 12:48
  • I'm not an expert in go templating but the link you have suggested returns a string. Whereas in my case in need to access the values object (or map i guess). – DhiwaTdG May 18 '21 at 12:56
  • Maybe this is what you need: https://stackoverflow.com/q/26152088/13860 – Jonathan Hall May 18 '21 at 13:19
  • 1
    @Flimzy That's exactly what i've been looking for. Thanks a ton!!! :-) – DhiwaTdG May 18 '21 at 15:48
  • Does this answer your question? [Access a map value using a variable key in a Go template](https://stackoverflow.com/questions/26152088/access-a-map-value-using-a-variable-key-in-a-go-template) – Jonathan Hall May 18 '21 at 17:08

0 Answers0