I want to use an AND operator to check multiple conditions and produce a boolean as a value without an if statement.
# template.yaml
- name: VARIABLE_NAME
value: {{ and (.Values.boolValue) (.Values.stringValue) }}
# values.yaml
boolValue: true
stringValue: "value"
The above example produces the following template.
- name: VARIABLE_NAME
value: "value"
Can the return value be casted to a boolean so that the result is the following?
- name:
value: true
Logical operators do not convert non-boolean values to booleans. Without an if statement, the non-boolean values are passed through to the result. Strings specifically can be casted to a boolean with the empty function which will check for null
and empty string.
# template.yaml
- name: VARIABLE_NAME
value: {{ and (.Values.boolValue) (not (.Values.stringValue | empty)) }}