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
e269b894
Unverified
Commit
e269b894
authored
Apr 17, 2018
by
Michelle Noorali
Committed by
GitHub
Apr 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3912 from michelleN/process-null
fix(pkg/strvals): evaluate "null" values
parents
870827c1
1850aead
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
parser.go
pkg/strvals/parser.go
+8
-0
parser_test.go
pkg/strvals/parser_test.go
+5
-0
No files found.
pkg/strvals/parser.go
View file @
e269b894
...
@@ -82,6 +82,10 @@ func ParseIntoString(s string, dest map[string]interface{}) error {
...
@@ -82,6 +82,10 @@ func ParseIntoString(s string, dest map[string]interface{}) error {
// parser is a simple parser that takes a strvals line and parses it into a
// parser is a simple parser that takes a strvals line and parses it into a
// map representation.
// map representation.
//
// where sc is the source of the original data being parsed
// where data is the final parsed data from the parses with correct types
// where st is a boolean to figure out if we're forcing it to parse values as string
type
parser
struct
{
type
parser
struct
{
sc
*
bytes
.
Buffer
sc
*
bytes
.
Buffer
data
map
[
string
]
interface
{}
data
map
[
string
]
interface
{}
...
@@ -329,6 +333,10 @@ func typedVal(v []rune, st bool) interface{} {
...
@@ -329,6 +333,10 @@ func typedVal(v []rune, st bool) interface{} {
return
false
return
false
}
}
if
strings
.
EqualFold
(
val
,
"null"
)
{
return
nil
}
// If this value does not start with zero, and not returnString, try parsing it to an int
// 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
!
st
&&
len
(
val
)
!=
0
&&
val
[
0
]
!=
'0'
{
if
iv
,
err
:=
strconv
.
ParseInt
(
val
,
10
,
64
);
err
==
nil
{
if
iv
,
err
:=
strconv
.
ParseInt
(
val
,
10
,
64
);
err
==
nil
{
...
...
pkg/strvals/parser_test.go
View file @
e269b894
...
@@ -81,6 +81,11 @@ func TestParseSet(t *testing.T) {
...
@@ -81,6 +81,11 @@ func TestParseSet(t *testing.T) {
expect
map
[
string
]
interface
{}
expect
map
[
string
]
interface
{}
err
bool
err
bool
}{
}{
{
"name1=null,f=false,t=true"
,
map
[
string
]
interface
{}{
"name1"
:
nil
,
"f"
:
false
,
"t"
:
true
},
false
,
},
{
{
"name1=value1"
,
"name1=value1"
,
map
[
string
]
interface
{}{
"name1"
:
"value1"
},
map
[
string
]
interface
{}{
"name1"
:
"value1"
},
...
...
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