-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Treat config values that start with '0' as strings #4393
Conversation
When setting structured config values using `--path`, we automatically treat values that can be converted into an integer via `strconv.Atoi` as an integer, rather than as a string. However, this ends up converting values like "0123456" into the integer 123456, stripping the leading 0, which isn't desirable for values like commit SHAs, etc., where you want to keep the 0 (and keep it a string). This change makes it so that values starting with 0 are not implicitly converted to an integer; instead such values will remain a string.
Out of curiosity, does this fix it for all SDKs? I see only changes to the |
Yes. This code isn't specific to any SDK. We recently reorganized the repo to support go modules. The implementation lives under |
@justinvp Should I open another issue for the confusion, because it doesn't really make sense when you read the README in |
@nesl247 Suggestions and improvements are welcome! What do you think would help reduce the confusion here? |
I think that everything in |
There are multiple cases where this creates issues. For example, setting a firewall destinationPort like '1433'. It should be a string but comes in as a number like 1433. In this case, using '01433' and substring(1) to remove the 0. Another example would be an IP address like '10.0.0.1'. Comes in as as number instead of a string. In this case, '010.0.0.1' does not make it a string but rather still a number. Using "r10.0.0.1" makes it a string and still works with substring(1). We really need some structured control over this. Terraform uses 'type=' in their variable blocks to provide this control. We need a flag like --type with values like string, bool and number so that we can control what we need our values to be. |
Project level config does give the tools to solve this now, it's just not quite plumbed into the |
When setting structured config values using
--path
, we automatically treat values that can be converted into an integer (viastrconv.Atoi
) as an integer, rather than as a string.However, this ends up converting values like "0123456" into the integer 123456, stripping the leading 0, which isn't desirable for values like commit SHAs, etc., where you want to keep the 0 (and keep it a string).
This change makes it so that values starting with 0 are not implicitly converted to an integer; instead such values will remain a string.
Fixes #4295