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

How about a function toBool? #258

Open
felipecrs opened this issue Aug 22, 2020 · 7 comments · Fixed by go-sprout/sprout#33 · May be fixed by #307
Open

How about a function toBool? #258

felipecrs opened this issue Aug 22, 2020 · 7 comments · Fixed by go-sprout/sprout#33 · May be fixed by #307

Comments

@felipecrs
Copy link

felipecrs commented Aug 22, 2020

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 felipecrs changed the title How about a function ParseBool? How about a function toBool? Aug 22, 2020
@davidkarlsen
Copy link

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.

@nikgalushko
Copy link

nikgalushko commented Dec 5, 2021

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.

@davinkevin
Copy link

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…

@icy
Copy link

icy commented Jan 2, 2024

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

42atomys added a commit to go-sprout/sprout that referenced this issue May 10, 2024
## Description
This pull request introduces three new functions `toBool`, `toUint` and
`toUint64` to the conversion group

## Changes
- New functions: `toBool`, `toUint` and `toUint64`
- All conversion function are documented on
https://docs.atom.codes/sprout

## Fixes Masterminds#258,
Masterminds#307

## Checklist
- [x] I have read the **CONTRIBUTING.md** document.
- [x] My code follows the code style of this project.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] I have updated the documentation accordingly.
- [x] This change requires a change to the documentation on the website.
@42atomys
Copy link

Hello everyone 👋,

I wanted to let you know that this issue has been addressed in the fork of this project at go-sprout/sprout. The fix has been implemented starting from version v0.4.0.

For those looking for a solution, I recommend checking out the latest releases of the fork. This should help address the issue discussed in this thread.

Thank you!

@felipecrs
Copy link
Author

Thanks a lot, @42atomys. I hope sprout succeeds in replacing sprig!

@42atomys
Copy link

You are welcome @felipecrs 🙏

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