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
7b58f21c
Commit
7b58f21c
authored
Oct 25, 2016
by
Michelle Noorali
Committed by
GitHub
Oct 25, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1451 from michelleN/set-types
fix(helm): correctly convert types on --set flag
parents
f5be296f
c62ff7ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
install.go
cmd/helm/install.go
+22
-1
install_test.go
cmd/helm/install_test.go
+7
-1
No files found.
cmd/helm/install.go
View file @
7b58f21c
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"path/filepath"
"strconv"
"strings"
"strings"
"text/template"
"text/template"
...
@@ -289,12 +290,32 @@ func (v *values) Set(data string) error {
...
@@ -289,12 +290,32 @@ func (v *values) Set(data string) error {
return
nil
return
nil
}
}
func
typedVal
(
val
string
)
interface
{}
{
if
strings
.
EqualFold
(
val
,
"true"
)
{
return
true
}
if
strings
.
EqualFold
(
val
,
"false"
)
{
return
false
}
if
iv
,
err
:=
strconv
.
ParseInt
(
val
,
10
,
64
);
err
==
nil
{
return
iv
}
if
fv
,
err
:=
strconv
.
ParseFloat
(
val
,
64
);
err
==
nil
{
return
fv
}
return
val
}
func
splitPair
(
item
string
)
(
name
string
,
value
interface
{})
{
func
splitPair
(
item
string
)
(
name
string
,
value
interface
{})
{
pair
:=
strings
.
SplitN
(
item
,
"="
,
2
)
pair
:=
strings
.
SplitN
(
item
,
"="
,
2
)
if
len
(
pair
)
==
1
{
if
len
(
pair
)
==
1
{
return
pair
[
0
],
true
return
pair
[
0
],
true
}
}
return
pair
[
0
],
pair
[
1
]
return
pair
[
0
],
typedVal
(
pair
[
1
])
}
}
// locateChartPath looks for a chart directory in known places, and returns either the full path or an error.
// locateChartPath looks for a chart directory in known places, and returns either the full path or an error.
...
...
cmd/helm/install_test.go
View file @
7b58f21c
...
@@ -100,7 +100,7 @@ func TestInstall(t *testing.T) {
...
@@ -100,7 +100,7 @@ func TestInstall(t *testing.T) {
}
}
func
TestValues
(
t
*
testing
.
T
)
{
func
TestValues
(
t
*
testing
.
T
)
{
args
:=
"sailor=sinbad,good,port.source=baghdad,port.destination=basrah"
args
:=
"sailor=sinbad,good,port.source=baghdad,port.destination=basrah
,success=True
"
vobj
:=
new
(
values
)
vobj
:=
new
(
values
)
vobj
.
Set
(
args
)
vobj
.
Set
(
args
)
...
@@ -113,6 +113,10 @@ func TestValues(t *testing.T) {
...
@@ -113,6 +113,10 @@ func TestValues(t *testing.T) {
t
.
Errorf
(
"Expected good to be true. Got %v"
,
vals
[
"good"
])
t
.
Errorf
(
"Expected good to be true. Got %v"
,
vals
[
"good"
])
}
}
if
!
vals
[
"success"
]
.
(
bool
)
{
t
.
Errorf
(
"Expected boolean true. Got %T, %v"
,
vals
[
"success"
],
vals
[
"success"
])
}
port
:=
vals
[
"port"
]
.
(
map
[
string
]
interface
{})
port
:=
vals
[
"port"
]
.
(
map
[
string
]
interface
{})
if
fmt
.
Sprint
(
port
[
"source"
])
!=
"baghdad"
{
if
fmt
.
Sprint
(
port
[
"source"
])
!=
"baghdad"
{
...
@@ -127,6 +131,7 @@ port:
...
@@ -127,6 +131,7 @@ port:
destination: basrah
destination: basrah
source: baghdad
source: baghdad
sailor: sinbad
sailor: sinbad
success: true
`
`
out
,
err
:=
vobj
.
yaml
()
out
,
err
:=
vobj
.
yaml
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -147,6 +152,7 @@ port:
...
@@ -147,6 +152,7 @@ port:
destination: basrah
destination: basrah
source: baghdad
source: baghdad
sailor: pisti
sailor: pisti
success: true
`
`
newOut
,
err
:=
vobj
.
yaml
()
newOut
,
err
:=
vobj
.
yaml
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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