Helm Notable Values: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 34: Line 34:
returns <code>float64</code>
returns <code>float64</code>


==Distinguishing between Zero and Empty String=
==Distinguishing between Zero and Empty String==
<syntaxhighlight lang='yaml'>
<syntaxhighlight lang='yaml'>
{{- if kindIs "float64" .Values.myValue -}}
{{- if kindIs "float64" .Values.myValue -}}

Revision as of 09:26, 5 January 2021

Internal

Numeric Zero

For a numeric zero declared as:

myValue: 0

the following expressions evaluate to false:

Evaluates to false:

{{ if .Values.myValue }}

the following expressions evaluate to true:

{{ if empty .Values.myValue }}
{{ if (eq 0 (int .Values.myValue)) }}
{{ printf "%T" .Values.myValue }}

returns float64

{{ typeOf .Values.myValue }}

returns float64

Distinguishing between Zero and Empty String

{{- if kindIs "float64" .Values.myValue -}}
    {{- if .Values.myValue -}}
        {{- .Values.myValue -}}
    {{- else -}}
        0
    {{- end -}}
{{- end -}}

Boolean True

Boolean False

Empty Value (nil)

myValue:
{{ printf "%T" .Values.myValue }}

returns <nil>

{{ typeOf .Values.myValue }}

returns <nil>

Empty String