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

Typecasting? #49

Open
lukeschlather opened this issue Jul 8, 2021 · 1 comment
Open

Typecasting? #49

lukeschlather opened this issue Jul 8, 2021 · 1 comment

Comments

@lukeschlather
Copy link

lukeschlather commented Jul 8, 2021

I ran into an issue where I was trying to make a kubernetes manifest for a volumeMount and I wanted to make it configurable whether or not the volume was readOnly. I'm just using --include-env which means that when I provide the environment variable false it gets turned into the string 'false'.

I ended up doing

!Defaults
read_only_bool: !Op [!Var read_only, eq, 'true']

But it seems like it would be nice to have like a

read_only_bool: !Coerce [Boolean, !Var read_only]

That could apply standard yaml type guessing to the string and throw an error if it wasn't right (e.g. if you provided read_only=5 that would be a number and so would throw an error, or if you Coerced to numeric then you would end up with an error if you provided the string 'false'.)

@japsu
Copy link
Collaborator

japsu commented Jul 11, 2021

Thank you for your suggestion.

We're likely to implement this as a !ToX family of tags (eg. !ToString 3.14, !ToInt value: "C0FFEE", radix: 16 etc.) as we already have !IsString etc.

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

No branches or pull requests

2 participants