values.yaml
{{if (has 1 .Values.xs)}}
a: 42
{{ else }}
b: 1
c: 2
{{ end }}
template.yaml
xs:
- 1
- 2
- 3
I get an output of
b: 1
c: 2
How can I fix it so that I get an output of a: 42
since 1
is in [1,2,3]
?
{{if (has 1 .Values.xs)}}
a: 42
{{ else }}
b: 1
c: 2
{{ end }}
xs:
- 1
- 2
- 3
I get an output of
b: 1
c: 2
How can I fix it so that I get an output of a: 42
since 1
is in [1,2,3]
?
This is due to the types not matching.
{{ kindOf (first .Values.xs) }}
returnsfloat64
, while{{ kindOf (1) }}
returnsint
.An alternative is use
float64
, by either writing1.0
, or you can cast it:If converting to a
float64
isn't your idea of good, you can instead use strings on both the definition of the list and in your comparison.