diff --git a/pkg/strvals/parser.go b/pkg/strvals/parser.go index 842f36c24..b945b0a34 100644 --- a/pkg/strvals/parser.go +++ b/pkg/strvals/parser.go @@ -308,8 +308,11 @@ func typedVal(v []rune) interface{} { return false } - 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 { + if iv, err := strconv.ParseInt(val, 10, 64); err == nil { + return iv + } } return val diff --git a/pkg/strvals/parser_test.go b/pkg/strvals/parser_test.go index 061de0a13..a3f6e4207 100644 --- a/pkg/strvals/parser_test.go +++ b/pkg/strvals/parser_test.go @@ -93,6 +93,10 @@ func TestParseSet(t *testing.T) { str: "name1=,name2=value2", expect: map[string]interface{}{"name1": "", "name2": "value2"}, }, + { + str: "leading_zeros=00009", + expect: map[string]interface{}{"leading_zeros": "00009"}, + }, { str: "name1,name2=", err: true,