Commit 609e72b3 authored by Sam Leavens's avatar Sam Leavens

fix(pkg/strvals): preserve leading zeros in vals

When passing values with "helm install --set" values with leading zeros are
preserved and not parsed as ints.

Closes #2693
parent e8d80729
...@@ -308,8 +308,11 @@ func typedVal(v []rune) interface{} { ...@@ -308,8 +308,11 @@ func typedVal(v []rune) interface{} {
return false return false
} }
if iv, err := strconv.ParseInt(val, 10, 64); err == nil { // If this value does not start with zero, try parsing it to an int
return iv if len(val) != 0 && val[0] != 48 {
if iv, err := strconv.ParseInt(val, 10, 64); err == nil {
return iv
}
} }
return val return val
......
...@@ -93,6 +93,10 @@ func TestParseSet(t *testing.T) { ...@@ -93,6 +93,10 @@ func TestParseSet(t *testing.T) {
str: "name1=,name2=value2", str: "name1=,name2=value2",
expect: map[string]interface{}{"name1": "", "name2": "value2"}, expect: map[string]interface{}{"name1": "", "name2": "value2"},
}, },
{
str: "leading_zeros=00009",
expect: map[string]interface{}{"leading_zeros": "00009"},
},
{ {
str: "name1,name2=", str: "name1,name2=",
err: true, err: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment