Helm Template If/Else: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 38: | Line 38: | ||
# Do something else | # Do something else | ||
{{ end }} | {{ end }} | ||
</syntaxhighlight> | |||
=Organizatorium= | |||
==Testing the Existence of Two Configuration Elements in the Same Expression== | |||
<syntaxhighlight lang='yaml'> | |||
{{- if or .Values.myApp.config.local .Values.myApp.config.nfs }} | |||
... | |||
{{- end }} | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 16:38, 21 January 2020
External
Internal
Overview
if/else can be used to create conditional blocks.
The if control structures evaluate pipelines, not just values (values are a special case of a pipeline):
{{ if PIPELINE }}
# Do something
{{ else if OTHER_PIPELINE }}
# Do something else
{{ else }}
# Default case
{{ end }}
A pipeline evaluates to false
if the result of the pipeline, or the value, is:
- a boolean false
- a numeric zero
- an empty string
- a
nil
(empty or null) - an empty collection (map, slice, tuple, dict, array).
In any other case, the condition is evaluated to true.
Example:
{{ if .Values.debug }}
# Do something
{{ else }}
# Do something else
{{ end }}
Organizatorium
Testing the Existence of Two Configuration Elements in the Same Expression
{{- if or .Values.myApp.config.local .Values.myApp.config.nfs }}
...
{{- end }}