Difference between revisions of "Helm Template If/Else"

From NovaOrdis Knowledge Base
Jump to: navigation, search
(Overview)
 
Line 30: Line 30:
  
 
In any other case, the condition is evaluated to true.
 
In any other case, the condition is evaluated to true.
 +
 +
Example:
 +
<syntaxhighlight lang='yaml'>
 +
{{ if .Values.debug }}
 +
  # Do something
 +
{{ else }}
 +
  # Do something else
 +
{{ end }}
 +
</syntaxhighlight>

Latest revision as of 23:41, 9 October 2019

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 }}