Greg
Greg

Reputation: 432

Helm simple for loop

I can not find a way to just iterate over a simple range, 10 -> 20 using helm templating.

{{range 10 until 20 }}
    - port: {{ . }}
      targetPort: {{ . }}
      protocol: TCP
      name: brick-{{ . }}
{{end}}

Upvotes: 8

Views: 12966

Answers (1)

David Maze
David Maze

Reputation: 159495

Helm uses the standard Go text/template system for rendering templates, plus (most of) the Sprig extension library, plus a couple more things. In particular, Sprig includes until and untilStep functions to generate lists of numbers, which you can then range over. So you should be able to:

{{- range untilStep 10 20 1 }}
    - port: {{ . }}
      ...
{{- end }}

Upvotes: 13

Related Questions