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
9f0914f7
Commit
9f0914f7
authored
Aug 19, 2016
by
Trevor Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add --set flag to `helm upgrade`
Fix #1070
parent
4dfcd6fc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
4 deletions
+33
-4
upgrade.go
cmd/helm/upgrade.go
+33
-4
No files found.
cmd/helm/upgrade.go
View file @
9f0914f7
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
main
import
(
"bytes"
"fmt"
"io"
"io/ioutil"
...
...
@@ -31,6 +32,9 @@ This command upgrades a release to a new version of a chart.
The upgrade arguments must be a release and a chart. The chart
argument can be a relative path to a packaged or unpackaged chart.
To override values in a chart, use either the '--values' flag and pass in a file
or use the '--set' flag and pass configuration from the command line.
`
type
upgradeCmd
struct
{
...
...
@@ -41,6 +45,7 @@ type upgradeCmd struct {
dryRun
bool
disableHooks
bool
valuesFile
string
values
*
values
}
func
newUpgradeCmd
(
client
helm
.
Interface
,
out
io
.
Writer
)
*
cobra
.
Command
{
...
...
@@ -48,6 +53,7 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command {
upgrade
:=
&
upgradeCmd
{
out
:
out
,
client
:
client
,
values
:
new
(
values
),
}
cmd
:=
&
cobra
.
Command
{
...
...
@@ -71,24 +77,47 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command {
f
:=
cmd
.
Flags
()
f
.
StringVarP
(
&
upgrade
.
valuesFile
,
"values"
,
"f"
,
""
,
"path to a values YAML file"
)
f
.
BoolVar
(
&
upgrade
.
dryRun
,
"dry-run"
,
false
,
"simulate an upgrade"
)
f
.
Var
(
upgrade
.
values
,
"set"
,
"set values on the command line. Separate values with commas: key1=val1,key2=val2"
)
f
.
BoolVar
(
&
upgrade
.
disableHooks
,
"disable-hooks"
,
false
,
"disable pre/post upgrade hooks"
)
return
cmd
}
func
(
u
*
upgradeCmd
)
vals
()
([]
byte
,
error
)
{
var
buffer
bytes
.
Buffer
// User specified a values file via -f/--values
if
u
.
valuesFile
!=
""
{
bytes
,
err
:=
ioutil
.
ReadFile
(
u
.
valuesFile
)
if
err
!=
nil
{
return
[]
byte
{},
err
}
buffer
.
Write
(
bytes
)
}
// User specified value pairs via --set
// These override any values in the specified file
if
len
(
u
.
values
.
pairs
)
>
0
{
bytes
,
err
:=
u
.
values
.
yaml
()
if
err
!=
nil
{
return
[]
byte
{},
err
}
buffer
.
Write
(
bytes
)
}
return
buffer
.
Bytes
(),
nil
}
func
(
u
*
upgradeCmd
)
run
()
error
{
chartPath
,
err
:=
locateChartPath
(
u
.
chart
)
if
err
!=
nil
{
return
err
}
rawVals
:=
[]
byte
{}
if
u
.
valuesFile
!=
""
{
rawVals
,
err
=
ioutil
.
ReadFile
(
u
.
valuesFile
)
rawVals
,
err
:=
u
.
vals
()
if
err
!=
nil
{
return
err
}
}
_
,
err
=
u
.
client
.
UpdateRelease
(
u
.
release
,
chartPath
,
helm
.
UpdateValueOverrides
(
rawVals
),
helm
.
UpgradeDryRun
(
u
.
dryRun
),
helm
.
UpgradeDisableHooks
(
u
.
disableHooks
))
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