sprig icon indicating copy to clipboard operation
sprig copied to clipboard

How about a function toBool?

Open felipecrs opened this issue 5 years ago • 7 comments

Currently, I have to do something like:

{{ not ( not (env "CODESPACES") ) }}
# or
{{ env "CODESPACES" | not | not }}

To convert a string to boolean.

I would be good if we had another function for the conversions such as toBool.

felipecrs avatar Aug 22 '20 19:08 felipecrs

This would be really useful for helm-charts too, a bit surprised it's not already included in sprig as there are all other conversions.

davidkarlsen avatar Jun 10 '21 22:06 davidkarlsen

Hi. I forked the sprig and improve it with some useful functions. Your suggestion is implemented in my project. You can replace sprig to thixo as is. Thixo doesn't have any breaking changes.

nikgalushko avatar Dec 05 '21 07:12 nikgalushko

not | not is not a possible solution if you are trying to support old helm versions like 3.5-ish.

"false" | not | not returns true 😓.

My solution is then to use eq "false" other_value instead…

davinkevin avatar Feb 10 '23 15:02 davinkevin

argocd generattor has some limitation, possibly because of this boolean feature: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/GoTemplate/#limitations

icy avatar Jan 02 '24 10:01 icy