We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Allow parsing a string as a number
When using output from other actions, or command-line parameter they will be presented as string type
An template expression like this: --flag=${var.x * 2} would then result in the error
--flag=${var.x * 2}
Invalid template string (--flag=${var.x * 2}) at path ...: Both terms need to be numbers for * operator (got string and number).
parse strings as numbers using a template helper function; Example --flag=${number(var.x) * 2}
--flag=${number(var.x) * 2}
Makes it easier to write glue code
We can add a helper function similar to the existing string() function, that parses the number.
string()
Open question: What should the function do with floating point and integers that are not base 10?
It's possible to (ab)use the jsonDecode helper like so: ${string(jsonDecode("2") * 4)} This expression will resolve to the number 8.
jsonDecode
${string(jsonDecode("2") * 4)}
8
🌹 It’s a nice to have, but nice things are nice 🙂
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Feature Request
Allow parsing a string as a number
Background / Motivation
When using output from other actions, or command-line parameter they will be presented as string type
An template expression like this:
--flag=${var.x * 2}
would then result in the errorWhat should the user be able to do?
parse strings as numbers using a template helper function; Example
--flag=${number(var.x) * 2}
Why do they want to do this? What problem does it solve?
Makes it easier to write glue code
Suggested Implementation(s)
We can add a helper function similar to the existing
string()
function, that parses the number.Open question: What should the function do with floating point and integers that are not base 10?
Workaround
It's possible to (ab)use the
jsonDecode
helper like so:${string(jsonDecode("2") * 4)}
This expression will resolve to the number
8
.How important is this feature for you/your team?
🌹 It’s a nice to have, but nice things are nice 🙂
The text was updated successfully, but these errors were encountered: