Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
272d9bc6
Commit
272d9bc6
authored
May 29, 2018
by
Elmar Ritsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse booleans and null as string values with --set-string flag
parent
1c259297
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
parser.go
pkg/strvals/parser.go
+7
-2
parser_test.go
pkg/strvals/parser_test.go
+9
-0
No files found.
pkg/strvals/parser.go
View file @
272d9bc6
...
...
@@ -325,6 +325,11 @@ func inMap(k rune, m map[rune]bool) bool {
func
typedVal
(
v
[]
rune
,
st
bool
)
interface
{}
{
val
:=
string
(
v
)
if
st
{
return
val
}
if
strings
.
EqualFold
(
val
,
"true"
)
{
return
true
}
...
...
@@ -337,8 +342,8 @@ func typedVal(v []rune, st bool) interface{} {
return
nil
}
// If this value does not start with zero,
and not returnString,
try parsing it to an int
if
!
st
&&
len
(
val
)
!=
0
&&
val
[
0
]
!=
'0'
{
// If this value does not start with zero, try parsing it to an int
if
len
(
val
)
!=
0
&&
val
[
0
]
!=
'0'
{
if
iv
,
err
:=
strconv
.
ParseInt
(
val
,
10
,
64
);
err
==
nil
{
return
iv
}
...
...
pkg/strvals/parser_test.go
View file @
272d9bc6
...
...
@@ -75,6 +75,11 @@ func TestParseSet(t *testing.T) {
expect
:
map
[
string
]
interface
{}{
"long_int_string"
:
"1234567890"
},
err
:
false
,
},
{
str
:
"boolean=true"
,
expect
:
map
[
string
]
interface
{}{
"boolean"
:
"true"
},
err
:
false
,
},
}
tests
:=
[]
struct
{
str
string
...
...
@@ -117,6 +122,10 @@ func TestParseSet(t *testing.T) {
str
:
"long_int=1234567890"
,
expect
:
map
[
string
]
interface
{}{
"long_int"
:
1234567890
},
},
{
str
:
"boolean=true"
,
expect
:
map
[
string
]
interface
{}{
"boolean"
:
true
},
},
{
str
:
"name1,name2="
,
err
:
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment