Helm Notable Values: Difference between revisions
Jump to navigation
Jump to search
Line 33: | Line 33: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
returns <code>float64</code> | returns <code>float64</code> | ||
==Distinguishing between Zero and Empty String= | |||
<syntaxhighlight lang='yaml'> | |||
{{- if kindIs "float64" .Values.myValue -}} | |||
{{- if .Values.myValue -}} | |||
{{- .Values.myValue -}} | |||
{{- else -}} | |||
0 | |||
{{- end -}} | |||
{{- end -}} | |||
</syntaxhighlight> | |||
=Boolean True= | =Boolean True= |
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>