Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Ijaz Ahmad
ksonnet
Commits
90a2f348
Unverified
Commit
90a2f348
authored
Feb 26, 2018
by
Jess
Committed by
GitHub
Feb 26, 2018
Browse files
Merge pull request #331 from jessicayuen/consistent-params
Set param boolean types as strings
parents
6edb7b93
daf10a0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
pkg/kubecfg/param.go
pkg/kubecfg/param.go
+0
-4
pkg/kubecfg/param_test.go
pkg/kubecfg/param_test.go
+32
-0
No files found.
pkg/kubecfg/param.go
View file @
90a2f348
...
...
@@ -94,10 +94,6 @@ func (c *ParamSetCmd) Run() error {
// sanitizeParamValue does a best effort to identify value types. It will put
// quotes around values which it categorizes as strings.
func
sanitizeParamValue
(
value
string
)
string
{
// boolean
if
value
==
"true"
||
value
==
"false"
{
return
value
}
// numeric
if
_
,
err
:=
strconv
.
ParseFloat
(
value
,
64
);
err
==
nil
{
return
value
...
...
pkg/kubecfg/param_test.go
View file @
90a2f348
...
...
@@ -82,3 +82,35 @@ func TestDiffParams(t *testing.T) {
}
}
}
func
TestSanitizeParamValue
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
value
string
expected
string
}{
// numbers
{
value
:
"64.5"
,
expected
:
"64.5"
,
},
{
value
:
"64"
,
expected
:
"64"
,
},
// boolean
{
value
:
"false"
,
expected
:
`"false"`
,
},
// string
{
value
:
"my string"
,
expected
:
`"my string"`
,
},
}
for
_
,
te
:=
range
tests
{
got
:=
sanitizeParamValue
(
te
.
value
)
require
.
Equal
(
t
,
got
,
te
.
expected
,
"Unexpected sanitized param value"
)
}
}
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