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
f0af7d60
Commit
f0af7d60
authored
Jun 29, 2017
by
Matt Butcher
Committed by
GitHub
Jun 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2592 from raisemarketplace/compare
ref(helm): consolidate vars() function
parents
6931a238
9e62777a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
36 deletions
+7
-36
install.go
cmd/helm/install.go
+6
-4
upgrade.go
cmd/helm/upgrade.go
+1
-32
No files found.
cmd/helm/install.go
View file @
f0af7d60
...
@@ -204,7 +204,7 @@ func (i *installCmd) run() error {
...
@@ -204,7 +204,7 @@ func (i *installCmd) run() error {
i
.
namespace
=
defaultNamespace
()
i
.
namespace
=
defaultNamespace
()
}
}
rawVals
,
err
:=
i
.
vals
(
)
rawVals
,
err
:=
vals
(
i
.
valueFiles
,
i
.
values
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -302,11 +302,13 @@ func mergeValues(dest map[string]interface{}, src map[string]interface{}) map[st
...
@@ -302,11 +302,13 @@ func mergeValues(dest map[string]interface{}, src map[string]interface{}) map[st
return
dest
return
dest
}
}
func
(
i
*
installCmd
)
vals
()
([]
byte
,
error
)
{
// vals merges values from files specified via -f/--values and
// directly via --set, marshaling them to YAML
func
vals
(
valueFiles
valueFiles
,
values
[]
string
)
([]
byte
,
error
)
{
base
:=
map
[
string
]
interface
{}{}
base
:=
map
[
string
]
interface
{}{}
// User specified a values files via -f/--values
// User specified a values files via -f/--values
for
_
,
filePath
:=
range
i
.
valueFiles
{
for
_
,
filePath
:=
range
valueFiles
{
currentMap
:=
map
[
string
]
interface
{}{}
currentMap
:=
map
[
string
]
interface
{}{}
bytes
,
err
:=
ioutil
.
ReadFile
(
filePath
)
bytes
,
err
:=
ioutil
.
ReadFile
(
filePath
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -321,7 +323,7 @@ func (i *installCmd) vals() ([]byte, error) {
...
@@ -321,7 +323,7 @@ func (i *installCmd) vals() ([]byte, error) {
}
}
// User specified a value via --set
// User specified a value via --set
for
_
,
value
:=
range
i
.
values
{
for
_
,
value
:=
range
values
{
if
err
:=
strvals
.
ParseInto
(
value
,
base
);
err
!=
nil
{
if
err
:=
strvals
.
ParseInto
(
value
,
base
);
err
!=
nil
{
return
[]
byte
{},
fmt
.
Errorf
(
"failed parsing --set data: %s"
,
err
)
return
[]
byte
{},
fmt
.
Errorf
(
"failed parsing --set data: %s"
,
err
)
}
}
...
...
cmd/helm/upgrade.go
View file @
f0af7d60
...
@@ -19,16 +19,13 @@ package main
...
@@ -19,16 +19,13 @@ package main
import
(
import
(
"fmt"
"fmt"
"io"
"io"
"io/ioutil"
"strings"
"strings"
"github.com/ghodss/yaml"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/strvals"
)
)
const
upgradeDesc
=
`
const
upgradeDesc
=
`
...
@@ -176,7 +173,7 @@ func (u *upgradeCmd) run() error {
...
@@ -176,7 +173,7 @@ func (u *upgradeCmd) run() error {
}
}
}
}
rawVals
,
err
:=
u
.
vals
(
)
rawVals
,
err
:=
vals
(
u
.
valueFiles
,
u
.
values
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -225,31 +222,3 @@ func (u *upgradeCmd) run() error {
...
@@ -225,31 +222,3 @@ func (u *upgradeCmd) run() error {
return
nil
return
nil
}
}
func
(
u
*
upgradeCmd
)
vals
()
([]
byte
,
error
)
{
base
:=
map
[
string
]
interface
{}{}
// User specified a values files via -f/--values
for
_
,
filePath
:=
range
u
.
valueFiles
{
currentMap
:=
map
[
string
]
interface
{}{}
bytes
,
err
:=
ioutil
.
ReadFile
(
filePath
)
if
err
!=
nil
{
return
[]
byte
{},
err
}
if
err
:=
yaml
.
Unmarshal
(
bytes
,
&
currentMap
);
err
!=
nil
{
return
[]
byte
{},
fmt
.
Errorf
(
"failed to parse %s: %s"
,
filePath
,
err
)
}
// Merge with the previous map
base
=
mergeValues
(
base
,
currentMap
)
}
// User specified a value via --set
for
_
,
value
:=
range
u
.
values
{
if
err
:=
strvals
.
ParseInto
(
value
,
base
);
err
!=
nil
{
return
[]
byte
{},
fmt
.
Errorf
(
"failed parsing --set data: %s"
,
err
)
}
}
return
yaml
.
Marshal
(
base
)
}
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