Sprig dict: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:
* http://masterminds.github.io/sprig/dicts.html
* http://masterminds.github.io/sprig/dicts.html
=Internal=
=Internal=
* [[sprig]]
* [[Helm_Templates#Storage|Helm Templates]]
* [[Helm_Templates#Storage|Helm Templates]]
* [[Helm_Named_Templates#Passing_Arguments_to_Sub-templates|Passing Arguments to Sub-templates]]
=Overview=
=Overview=
A dict instance is used as the [[Helm_Templates#Scope|root scope]] by Helm while rendering templates. dict instances can also be used to pass arguments to sub-templates: {{Internal|Helm_Named_Templates#Passing_Arguments_to_Sub-templates|Passing Arguments to Sub-templates}}
A dict instance is used as the [[Helm_Templates#Scope|root scope]] by Helm while rendering templates. dict instances can also be used to pass arguments to sub-templates: {{Internal|Helm_Named_Templates#Passing_Arguments_to_Sub-templates|Passing Arguments to Sub-templates}}
=Helm Patterns=
Creating a dict:
<syntaxhighlight lang='yaml'>
{{- $ExampleDict := dict -}}
</syntaxhighlight>
<syntaxhighlight lang='yaml'>
{{- $ExampleDict := dict "key1" "value1" "key2" $OtherVar -}}
</syntaxhighlight>
Adding a key/value pair:
<syntaxhighlight lang='yaml'>
{{- $_0 := set $ExampleDict "key2" "value3" -}}
{{- $_1 := set $ExampleDict "SomeList" (list "a" "b" "c") -}}
</syntaxhighlight>

Latest revision as of 22:36, 19 October 2020

External

Internal

Overview

A dict instance is used as the root scope by Helm while rendering templates. dict instances can also be used to pass arguments to sub-templates:

Passing Arguments to Sub-templates

Helm Patterns

Creating a dict:

{{- $ExampleDict := dict -}}
{{- $ExampleDict := dict "key1" "value1" "key2" $OtherVar -}}

Adding a key/value pair:

{{- $_0 := set $ExampleDict "key2" "value3" -}}
{{- $_1 := set $ExampleDict "SomeList" (list "a" "b" "c") -}}