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
36699cc2
Commit
36699cc2
authored
Jul 17, 2016
by
Michelle Noorali
Committed by
migmartri-michelleN
Jul 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(helm): refactor cmd/upgrade for unit testing
parent
0fcd7fcc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
22 deletions
+44
-22
helm.go
cmd/helm/helm.go
+1
-0
upgrade.go
cmd/helm/upgrade.go
+43
-22
No files found.
cmd/helm/helm.go
View file @
36699cc2
...
...
@@ -90,6 +90,7 @@ func newRootCmd(out io.Writer) *cobra.Command {
newInstallCmd
(
nil
,
out
),
newDeleteCmd
(
nil
,
out
),
newInspectCmd
(
nil
,
out
),
newUpgradeCmd
(
nil
,
out
),
)
return
cmd
}
...
...
cmd/helm/upgrade.go
View file @
36699cc2
...
...
@@ -18,6 +18,7 @@ package main
import
(
"fmt"
"io"
"github.com/spf13/cobra"
...
...
@@ -31,14 +32,6 @@ The upgrade arguments must be a release and a chart. The chart
argument can be a relative path to a packaged or unpackaged chart.
`
var
upgradeCmd
=
&
cobra
.
Command
{
Use
:
"upgrade [RELEASE] [CHART]"
,
Short
:
"upgrade a release"
,
Long
:
upgradeDesc
,
RunE
:
runUpgrade
,
PersistentPreRunE
:
setupConnection
,
}
// upgrade flags
var
(
// upgradeDryRun performs a dry-run upgrade
...
...
@@ -47,20 +40,49 @@ var (
upgradeValues
string
)
func
init
()
{
f
:=
upgradeCmd
.
Flags
()
type
upgradeCmd
struct
{
release
string
chart
string
out
io
.
Writer
client
helm
.
Interface
}
func
newUpgradeCmd
(
client
helm
.
Interface
,
out
io
.
Writer
)
*
cobra
.
Command
{
upgrade
:=
&
upgradeCmd
{
out
:
out
,
client
:
client
,
}
cmd
:=
&
cobra
.
Command
{
Use
:
"upgrade [RELEASE] [CHART]"
,
Short
:
"upgrade a release"
,
Long
:
upgradeDesc
,
PersistentPreRunE
:
setupConnection
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
err
:=
checkArgsLength
(
2
,
len
(
args
),
"release name, chart path"
);
err
!=
nil
{
return
err
}
upgrade
.
release
=
args
[
0
]
upgrade
.
chart
=
args
[
1
]
if
upgrade
.
client
==
nil
{
upgrade
.
client
=
helm
.
NewClient
(
helm
.
HelmHost
(
helm
.
Config
.
ServAddr
))
}
return
upgrade
.
run
()
},
}
f
:=
cmd
.
Flags
()
f
.
StringVarP
(
&
upgradeValues
,
"values"
,
"f"
,
""
,
"path to a values YAML file"
)
f
.
BoolVar
(
&
upgradeDryRun
,
"dry-run"
,
false
,
"simulate an upgrade"
)
RootCommand
.
AddCommand
(
upgradeCmd
)
return
cmd
}
func
runUpgrade
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
err
:=
checkArgsLength
(
2
,
len
(
args
),
"release name, chart path"
);
err
!=
nil
{
return
err
}
chartPath
,
err
:=
locateChartPath
(
args
[
1
])
func
(
u
*
upgradeCmd
)
run
()
error
{
chartPath
,
err
:=
locateChartPath
(
u
.
chart
)
if
err
!=
nil
{
return
err
}
...
...
@@ -70,15 +92,14 @@ func runUpgrade(cmd *cobra.Command, args []string) error {
return
err
}
res
,
err
:=
helm
.
UpdateRelease
(
args
[
0
]
,
chartPath
,
rawVals
,
upgradeDryRun
)
_
,
err
=
helm
.
UpdateRelease
(
u
.
release
,
chartPath
,
rawVals
,
upgradeDryRun
)
if
err
!=
nil
{
return
prettyError
(
err
)
}
newVersion
:=
res
.
GetRelease
()
.
Version
fmt
.
Printf
(
"I know you want to upgrade your release to version %v.
\n
Hang tight. We're still working on the helm upgrade command."
,
newVersion
)
fmt
.
Println
(
"
\n
Coming soon to a Helm near YOU!"
)
fmt
.
Println
(
"
\n
It's not you. It's me."
)
fmt
.
Println
(
"Your upgrade looks valid but this command is still in progress.
\n
Hang tight.
\n
"
)
return
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