Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safeEmpty, safeDefault, and safeCoalesce functions which don't consider 0 or false to be empty #250

Open
tculp opened this issue Jun 3, 2020 · 2 comments · May be fixed by #385
Open

Comments

@tculp
Copy link

tculp commented Jun 3, 2020

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

@tculp tculp changed the title Add safeEmpty and safeDefault functions which don't consider 0 or false to be empty Add safeEmpty, safeDefault, and safeCoalesce functions which don't consider 0 or false to be empty Jun 3, 2020
@govindbalaji-s
Copy link

Is this still open? Can I pick this?

@tculp
Copy link
Author

tculp commented Oct 23, 2023

Is this still open? Can I pick this?

Sure, glad to see something done with this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants