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
6860c47d
Commit
6860c47d
authored
Sep 28, 2016
by
Adam Reese
Committed by
GitHub
Sep 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1248 from adamreese/feat/rollback-version
feat(*): add rollback to a release version
parents
47e425ba
1db7bd64
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
64 additions
and
13 deletions
+64
-13
tiller.proto
_proto/hapi/services/tiller.proto
+2
-1
get.go
cmd/helm/get.go
+2
-2
get_test.go
cmd/helm/get_test.go
+1
-1
list.go
cmd/helm/list.go
+1
-1
list_test.go
cmd/helm/list_test.go
+1
-1
rollback.go
cmd/helm/rollback.go
+10
-3
rollback_test.go
cmd/helm/rollback_test.go
+6
-1
status.go
cmd/helm/status.go
+1
-1
release_server.go
cmd/tiller/release_server.go
+11
-1
release_server_test.go
cmd/tiller/release_server_test.go
+21
-0
option.go
pkg/helm/option.go
+8
-1
tiller.pb.go
pkg/proto/hapi/services/tiller.pb.go
+0
-0
No files found.
_proto/hapi/services/tiller.proto
View file @
6860c47d
...
...
@@ -183,7 +183,6 @@ message UpdateReleaseRequest {
hapi.chart.Config
values
=
3
;
// dry_run, if true, will run through the release logic, but neither create
bool
dry_run
=
4
;
// DisableHooks causes the server to skip running any hooks for the upgrade.
bool
disable_hooks
=
5
;
}
...
...
@@ -200,6 +199,8 @@ message RollbackReleaseRequest {
bool
dry_run
=
2
;
// DisableHooks causes the server to skip running any hooks for the rollback
bool
disable_hooks
=
3
;
// Version is the version of the release to deploy.
int32
version
=
4
;
}
// RollbackReleaseResponse is the response to an update request.
...
...
cmd/helm/get.go
View file @
6860c47d
...
...
@@ -73,7 +73,7 @@ func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command {
},
}
cmd
.
PersistentFlags
()
.
Int32Var
(
&
get
.
version
,
"
version"
,
0
,
"get the named release with ver
sion"
)
cmd
.
PersistentFlags
()
.
Int32Var
(
&
get
.
version
,
"
revision"
,
0
,
"get the named release with revi
sion"
)
cmd
.
AddCommand
(
newGetValuesCmd
(
nil
,
out
))
cmd
.
AddCommand
(
newGetManifestCmd
(
nil
,
out
))
...
...
@@ -81,7 +81,7 @@ func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command {
return
cmd
}
var
getTemplate
=
`
VER
SION: {{.Release.Version}}
var
getTemplate
=
`
REVI
SION: {{.Release.Version}}
RELEASED: {{.ReleaseDate}}
CHART: {{.Release.Chart.Metadata.Name}}-{{.Release.Chart.Metadata.Version}}
USER-SUPPLIED VALUES:
...
...
cmd/helm/get_test.go
View file @
6860c47d
...
...
@@ -29,7 +29,7 @@ func TestGetCmd(t *testing.T) {
name
:
"get with a release"
,
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"thomas-guide"
}),
args
:
[]
string
{
"thomas-guide"
},
expected
:
"
VER
SION: 1
\n
RELEASED: (.*)
\n
CHART: foo-0.1.0-beta.1
\n
USER-SUPPLIED VALUES:
\n
name:
\"
value
\"\n
COMPUTED VALUES:
\n
name: value
\n\n
HOOKS:
\n
---
\n
# pre-install-hook
\n
"
+
mockHookTemplate
+
"
\n
MANIFEST:"
,
expected
:
"
REVI
SION: 1
\n
RELEASED: (.*)
\n
CHART: foo-0.1.0-beta.1
\n
USER-SUPPLIED VALUES:
\n
name:
\"
value
\"\n
COMPUTED VALUES:
\n
name: value
\n\n
HOOKS:
\n
---
\n
# pre-install-hook
\n
"
+
mockHookTemplate
+
"
\n
MANIFEST:"
,
},
{
name
:
"get requires release name arg"
,
...
...
cmd/helm/list.go
View file @
6860c47d
...
...
@@ -191,7 +191,7 @@ func (l *listCmd) statusCodes() []release.Status_Code {
func
formatList
(
rels
[]
*
release
.
Release
)
string
{
table
:=
uitable
.
New
()
table
.
MaxColWidth
=
30
table
.
AddRow
(
"NAME"
,
"
VER
SION"
,
"UPDATED"
,
"STATUS"
,
"CHART"
)
table
.
AddRow
(
"NAME"
,
"
REVI
SION"
,
"UPDATED"
,
"STATUS"
,
"CHART"
)
for
_
,
r
:=
range
rels
{
c
:=
fmt
.
Sprintf
(
"%s-%s"
,
r
.
Chart
.
Metadata
.
Name
,
r
.
Chart
.
Metadata
.
Version
)
t
:=
timeconv
.
String
(
r
.
Info
.
LastDeployed
)
...
...
cmd/helm/list_test.go
View file @
6860c47d
...
...
@@ -45,7 +45,7 @@ func TestListCmd(t *testing.T) {
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"atlas"
}),
},
expected
:
"NAME
\t
VERSION
\t
UPDATED
\t
STATUS
\t
CHART
\n
atlas
\t
1
\t
(.*)
\t
DEPLOYED
\t
foo-0.1.0-beta.1
\n
"
,
expected
:
"NAME
\t
REVISION
\t
UPDATED
\t
STATUS
\t
CHART
\n
atlas
\t
1
\t
(.*)
\t
DEPLOYED
\t
foo-0.1.0-beta.1
\n
"
,
},
{
name
:
"with a release, multiple flags"
,
...
...
cmd/helm/rollback.go
View file @
6860c47d
...
...
@@ -26,12 +26,13 @@ import (
)
const
rollbackDesc
=
`
This command rolls back a release to the previous
ver
sion.
This command rolls back a release to the previous
revi
sion.
The argument of the rollback command is the name of a release.
`
type
rollbackCmd
struct
{
name
string
version
int32
dryRun
bool
disableHooks
bool
out
io
.
Writer
...
...
@@ -46,7 +47,7 @@ func newRollbackCmd(c helm.Interface, out io.Writer) *cobra.Command {
cmd
:=
&
cobra
.
Command
{
Use
:
"rollback [RELEASE]"
,
Short
:
"roll back a release to
the previous ver
sion"
,
Short
:
"roll back a release to
a previous revi
sion"
,
Long
:
rollbackDesc
,
PersistentPreRunE
:
setupConnection
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
...
...
@@ -60,13 +61,19 @@ func newRollbackCmd(c helm.Interface, out io.Writer) *cobra.Command {
}
f
:=
cmd
.
Flags
()
f
.
Int32Var
(
&
rollback
.
version
,
"revision"
,
0
,
"revision to deploy"
)
f
.
BoolVar
(
&
rollback
.
dryRun
,
"dry-run"
,
false
,
"simulate a rollback"
)
f
.
BoolVar
(
&
rollback
.
disableHooks
,
"no-hooks"
,
false
,
"prevent hooks from running during rollback"
)
return
cmd
}
func
(
r
*
rollbackCmd
)
run
()
error
{
_
,
err
:=
r
.
client
.
RollbackRelease
(
r
.
name
,
helm
.
RollbackDryRun
(
r
.
dryRun
),
helm
.
RollbackDisableHooks
(
r
.
disableHooks
))
_
,
err
:=
r
.
client
.
RollbackRelease
(
r
.
name
,
helm
.
RollbackDryRun
(
r
.
dryRun
),
helm
.
RollbackDisableHooks
(
r
.
disableHooks
),
helm
.
RollbackVersion
(
r
.
version
),
)
if
err
!=
nil
{
return
prettyError
(
err
)
}
...
...
cmd/helm/rollback_test.go
View file @
6860c47d
...
...
@@ -29,7 +29,12 @@ func TestRollbackCmd(t *testing.T) {
{
name
:
"rollback a release"
,
args
:
[]
string
{
"funny-honey"
},
resp
:
nil
,
flags
:
[]
string
{
"revision"
,
"1"
},
expected
:
"Rollback was a success! Happy Helming!"
,
},
{
name
:
"rollback a release without version"
,
args
:
[]
string
{
"funny-honey"
},
expected
:
"Rollback was a success! Happy Helming!"
,
},
}
...
...
cmd/helm/status.go
View file @
6860c47d
...
...
@@ -60,7 +60,7 @@ func newStatusCmd(client helm.Interface, out io.Writer) *cobra.Command {
},
}
cmd
.
PersistentFlags
()
.
Int32Var
(
&
status
.
version
,
"
version"
,
0
,
"If set, display the status of the named release with ver
sion"
)
cmd
.
PersistentFlags
()
.
Int32Var
(
&
status
.
version
,
"
revision"
,
0
,
"If set, display the status of the named release with revi
sion"
)
return
cmd
}
...
...
cmd/tiller/release_server.go
View file @
6860c47d
...
...
@@ -461,7 +461,17 @@ func (s *releaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
return
nil
,
nil
,
err
}
previousRelease
,
err
:=
s
.
env
.
Releases
.
Get
(
req
.
Name
,
currentRelease
.
Version
-
1
)
v
:=
req
.
Version
if
v
==
0
{
v
=
currentRelease
.
Version
-
1
}
if
v
<
1
{
return
nil
,
nil
,
errors
.
New
(
"cannot rollback to version < 1"
)
}
log
.
Printf
(
"rolling back %s to version %d"
,
req
.
Name
,
v
)
previousRelease
,
err
:=
s
.
env
.
Releases
.
Get
(
req
.
Name
,
v
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
cmd/tiller/release_server_test.go
View file @
6860c47d
...
...
@@ -664,6 +664,27 @@ func TestRollbackReleaseNoHooks(t *testing.T) {
}
}
func
TestRollbackWithReleaseVersion
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
RollbackReleaseRequest
{
Name
:
rel
.
Name
,
DisableHooks
:
true
,
Version
:
1
,
}
_
,
err
:=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
}
func
TestRollbackRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
...
...
pkg/helm/option.go
View file @
6860c47d
...
...
@@ -196,6 +196,13 @@ func RollbackDryRun(dry bool) RollbackOption {
}
}
// RollbackVersion sets the version of the release to deploy.
func
RollbackVersion
(
ver
int32
)
RollbackOption
{
return
func
(
opts
*
options
)
{
opts
.
rollbackReq
.
Version
=
ver
}
}
// UpgradeDisableHooks will disable hooks for an upgrade operation.
func
UpgradeDisableHooks
(
disable
bool
)
UpdateOption
{
return
func
(
opts
*
options
)
{
...
...
@@ -333,7 +340,7 @@ func (o *options) rpcRollbackRelease(rlsName string, rlc rls.ReleaseServiceClien
o
.
rollbackReq
.
DryRun
=
o
.
dryRun
o
.
rollbackReq
.
Name
=
rlsName
return
rlc
.
RollbackRelease
(
context
.
TODO
(),
&
o
.
rollbackReq
)
return
rlc
.
RollbackRelease
(
NewContext
(),
&
o
.
rollbackReq
)
}
// Executes tiller.GetReleaseStatus RPC.
...
...
pkg/proto/hapi/services/tiller.pb.go
View file @
6860c47d
This diff is collapsed.
Click to expand it.
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