Difference between revisions of "Helm Template range"

From NovaOrdis Knowledge Base
Jump to: navigation, search
(Created page with "=External= * https://helm.sh/docs/chart_template_guide/#looping-with-the-range-action =Internal= * Helm Templates =Overview= <tt>range</tt> provi...")
 
(5 intermediate revisions by the same user not shown)
Line 9: Line 9:
 
=Overview=
 
=Overview=
  
<tt>range</tt> provides a "for each" loop.
+
<tt>range</tt> provides a "for each" loop. The simples way to access the current iteration element is with {{ . }}. [[Helm_Templates#Template_Variables|Variables]] can also be used.
  
<font color=darkgray>TODO.</font>
+
=Iterating over an In-Line List=
 +
<syntaxhighlight lang='yaml'>
 +
env:
 +
{{- range list "blue" "red" "green" }}
 +
- name: {{ . | upper | printf "COLOR_%s" }}
 +
  value: {{ . -}}
 +
{{ end }}
 +
</syntaxhighlight>
 +
 
 +
=Iterating over a .Values List=
 +
 
 +
=Iterating over a Map=
 +
 
 +
=Numeric Iteration Variable=

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