1

I have a template file like the one below.

{{- $appName := include "template-name.camelcase" . }}
{{- range $versions := .Values.domain.$appName }}
---
apiVersion: networking.k8s.io/v1beta1
kind:Ingress
metadata:
  name: {{ $appName }}-{{ $versions.environment }}
---
{{- end }}

It doesn't seem to take the $appName variable that I've appended to .Values.domain. If I replace $appName with a hardcoded value that contains a list of values then helm will build the template. Is there a different syntax or way I should go about passing the list to the range operation?

Joe
  • 11
  • 1
  • 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) – David Maze May 02 '21 at 16:18
  • 1
    Use `index .Values.domain $appName` to do the dynamic lookup (as the expression part of the `range` statement). – David Maze May 02 '21 at 16:19
  • 1
    This `{{- range $versions := index .Values.domain $appName }}` ended up working for me – Joe May 04 '21 at 18:43

0 Answers0