Repository navigation
fix(pkg/strvals): preserve leading zeros in vals - #2729
Merged
Merged
Conversation
When passing values with "helm install --set" values with leading zeros are preserved and not parsed as ints. Closes #2693
| if iv, err := strconv.ParseInt(val, 10, 64); err == nil { | ||
| return iv | ||
| // If this value does not start with zero, try parsing it to an int | ||
| if len(val) != 0 && val[0] != 48 { |
Member
There was a problem hiding this comment.
out of curiosity/lack of understanding, what does 48 translate to in this situation?
Contributor
Author
There was a problem hiding this comment.
48 is the ASCII value for 0. Thanks for pointing this out, this prompted me to learn more about runes and I found out that a better implementation would be to use a rune literal '0' instead which better communicates the intent of the code.
When checking that a value begins with zero use a rune literal instead of the ASCII code for zero.
thomastaylor312
approved these changes
Aug 8, 2017
thomastaylor312
left a comment
Contributor
There was a problem hiding this comment.
Tested this and it looks good to go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When passing values with "helm install --set" values with leading zeros are
preserved and not parsed as ints.
Closes #2693