Helm Template range: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 13: Line 13:
=Iterating over an In-Line List=
=Iterating over an In-Line List=
<syntaxhighlight lang='yaml'>
<syntaxhighlight lang='yaml'>
      env:
env:
      {{- range list "blue" "red" "green" }}
{{- range list "blue" "red" "green" }}
      - name: {{ . | upper | printf "COLOR_%s" }}
- name: {{ . | upper | printf "COLOR_%s" }}
        value: {{ . -}}
  value: {{ . -}}
      {{ end }}
{{ end }}
</syntaxhighlight>
</syntaxhighlight>



Revision as of 00:09, 10 October 2019

External

Internal

Overview

range provides a "for each" loop. The simples way to access the current iteration element is with {{ . }}. Variables can also be used.

Iterating over an In-Line List

env:
{{- range list "blue" "red" "green" }}
- name: {{ . | upper | printf "COLOR_%s" }}
  value: {{ . -}}
{{ end }}

Iterating over a .Values List

Iterating over a Map

Numeric Iteration Variable