sprig
sprig copied to clipboard
Add safeEmpty, safeDefault, and safeCoalesce functions which don't consider 0 or false to be empty
As explained in #111, the current implementation of empty, and therefore default and coalesce, fails when attempting to use booleans or certain integers. However, there are many cases where an override value may be a legitimate 'false' or '0'.
For example, in helm charts, a paradigm such as follows is common:
values.yaml
global:
doThing: true
doThingOverride: null
deployment.yaml
{{- if .Values.doThingOverride | default .Values.global.doThing }}
In this case, even if doThingOverride is set to false, the global.doThing will always be used.
Adding a new set of functions would allow this paradigm to work without unfortunate workarounds like {{- if eq (coalesce (.Values.enableIngressOverride | quote) (.Values.global.enableIngress | quote)) (true | quote) }} and maintain backwards-compatabiity
Is this still open? Can I pick this?
Is this still open? Can I pick this?
Sure, glad to see something done with this!