"helm check if key exist and then evaluate if it's value is true on single line condition" In Helm version 3.10 will the following condition below work as intended or I can achieve it in some other way?

{{- if and (hasKey .Values.enableJsConfigMap) (eq .Values.enableJsConfigMap.enabled true) }}

1 Answer 1


This wouldn't work. The second condition will be evaluated regardless of the first. So if the key is not defined there will be an error. Use default instead:

{{- if eq (default .Values.enableJsConfigMap false) true }}
# Do something if enableJsConfigMap exists and its value is true
{{- end }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.