Sprig list: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * http://masterminds.github.io/sprig/lists.html =Internal= * sprig")
 
 
(6 intermediate revisions by the same user not shown)
Line 3: Line 3:
=Internal=
=Internal=
* [[sprig#Subjects|sprig]]
* [[sprig#Subjects|sprig]]
=Helm Patterns=
Creating a list:
<syntaxhighlight lang='yaml'>
{{- $ExampleList := list -}}
</syntaxhighlight>
<syntaxhighlight lang='yaml'>
{{- $ExampleList := list "element1" "element2" $OtherVar -}}
</syntaxhighlight>
Appending an element:
<syntaxhighlight lang='yaml'>
{{- $_0 := append $ExampleList "element3" -}}
</syntaxhighlight>
=Use Cases=
A sprig list can be used directly in a Helm manifest as value for a path that expects a list:
<syntaxhighlight lang='yaml'>
apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
        - name: example
          args: {{ .Args.CommandArgList }}
          ...
</syntaxhighlight>
=Functions=
==join==
{{External|http://masterminds.github.io/sprig/string_slice.html}}
<syntaxhighlight lang='yaml'>
{{ .Values.aList | join ',' }}
</syntaxhighlight>

Latest revision as of 01:01, 9 October 2020

External

Internal

Helm Patterns

Creating a list:

{{- $ExampleList := list -}}
{{- $ExampleList := list "element1" "element2" $OtherVar -}}

Appending an element:

{{- $_0 := append $ExampleList "element3" -}}

Use Cases

A sprig list can be used directly in a Helm manifest as value for a path that expects a list:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
        - name: example
          args: {{ .Args.CommandArgList }}
          ...

Functions

join

http://masterminds.github.io/sprig/string_slice.html
{{ .Values.aList | join ',' }}