Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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}}
like image 336
Greg Avatar asked Jun 14 '26 18:06

Greg


1 Answers

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 }}
like image 59
David Maze Avatar answered Jun 17 '26 21:06

David Maze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!