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
f9922877
Commit
f9922877
authored
Aug 08, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(*): integrate support for upgrade hooks
parent
70b9f11a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
14 deletions
+74
-14
upgrade.go
cmd/helm/upgrade.go
+2
-1
upgrade_test.go
cmd/helm/upgrade_test.go
+6
-2
release_server.go
cmd/tiller/release_server.go
+10
-10
release_server_test.go
cmd/tiller/release_server_test.go
+56
-0
option.go
pkg/helm/option.go
+0
-1
No files found.
cmd/helm/upgrade.go
View file @
f9922877
...
...
@@ -95,7 +95,8 @@ func (u *upgradeCmd) run() error {
return
prettyError
(
err
)
}
fmt
.
Fprintf
(
u
.
out
,
"It's not you. It's me
\n
Your upgrade looks valid but this command is still under active development.
\n
Hang tight.
\n
"
)
success
:=
u
.
release
+
" has been upgraded. Happy Helming!
\n
"
fmt
.
Fprintf
(
u
.
out
,
success
)
return
nil
...
...
cmd/helm/upgrade_test.go
View file @
f9922877
...
...
@@ -52,18 +52,22 @@ func TestUpgradeCmd(t *testing.T) {
Description
:
"A Helm chart for Kubernetes"
,
Version
:
"0.1.2"
,
}
chartPath
,
err
=
chartutil
.
Create
(
cfile
,
tmpChart
)
if
err
!=
nil
{
t
.
Errorf
(
"Error creating chart: %v"
,
err
)
}
ch
,
_
=
chartutil
.
Load
(
chartPath
)
ch
,
err
=
chartutil
.
Load
(
chartPath
)
if
err
!=
nil
{
t
.
Errorf
(
"Error loading updated chart: %v"
,
err
)
}
tests
:=
[]
releaseCase
{
{
name
:
"upgrade a release"
,
args
:
[]
string
{
"funny-bunny"
,
chartPath
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"funny-bunny"
,
version
:
2
,
chart
:
ch
}),
expected
:
"
It's not you. It's me
\n
Your upgrade looks valid but this command is still under active development.
\n
Hang tight.
\n
"
,
expected
:
"
funny-bunny has been upgraded. Happy Helming!
\n
"
,
},
}
...
...
cmd/tiller/release_server.go
View file @
f9922877
...
...
@@ -196,11 +196,11 @@ func (s *releaseServer) performUpdate(originalRelease, updatedRelease *release.R
}
// pre-ugrade hooks
//
if !req.DisableHooks {
//
if err := s.execHook(updatedRelease.Hooks, updatedRelease.Name, updatedRelease.Namespace, preUpgrade); err != nil {
//
return res, err
//
}
//
}
if
!
req
.
DisableHooks
{
if
err
:=
s
.
execHook
(
updatedRelease
.
Hooks
,
updatedRelease
.
Name
,
updatedRelease
.
Namespace
,
preUpgrade
);
err
!=
nil
{
return
res
,
err
}
}
kubeCli
:=
s
.
env
.
KubeClient
original
:=
bytes
.
NewBufferString
(
originalRelease
.
Manifest
)
...
...
@@ -210,11 +210,11 @@ func (s *releaseServer) performUpdate(originalRelease, updatedRelease *release.R
}
// post-upgrade hooks
//
if !req.DisableHooks {
//
if err := s.execHook(updatedRelease.Hooks, updatedRelease.Name, updatedRelease.Namespace, postUpgrade); err != nil {
//
return res, err
//
}
//
}
if
!
req
.
DisableHooks
{
if
err
:=
s
.
execHook
(
updatedRelease
.
Hooks
,
updatedRelease
.
Name
,
updatedRelease
.
Namespace
,
postUpgrade
);
err
!=
nil
{
return
res
,
err
}
}
updatedRelease
.
Info
.
Status
.
Code
=
release
.
Status_DEPLOYED
...
...
cmd/tiller/release_server_test.go
View file @
f9922877
...
...
@@ -44,6 +44,16 @@ data:
name: value
`
var
manifestWithUpgradeHooks
=
`apiVersion: v1
kind: ConfigMap
metadata:
name: test-cm
annotations:
"helm.sh/hook": post-upgrade,pre-upgrade
data:
name: value
`
func
rsFixture
()
*
releaseServer
{
return
&
releaseServer
{
env
:
mockEnvironment
(),
...
...
@@ -302,6 +312,7 @@ func TestUpdateRelease(t *testing.T) {
Metadata
:
&
chart
.
Metadata
{
Name
:
"hello"
},
Templates
:
[]
*
chart
.
Template
{
{
Name
:
"hello"
,
Data
:
[]
byte
(
"hello: world"
)},
{
Name
:
"hooks"
,
Data
:
[]
byte
(
manifestWithUpgradeHooks
)},
},
},
}
...
...
@@ -309,6 +320,7 @@ func TestUpdateRelease(t *testing.T) {
if
err
!=
nil
{
t
.
Errorf
(
"Failed updated: %s"
,
err
)
}
if
res
.
Release
.
Name
==
""
{
t
.
Errorf
(
"Expected release name."
)
}
...
...
@@ -326,6 +338,21 @@ func TestUpdateRelease(t *testing.T) {
t
.
Errorf
(
"Expected release for %s (%v)."
,
res
.
Release
.
Name
,
rs
.
env
.
Releases
)
}
if
len
(
updated
.
Hooks
)
!=
1
{
t
.
Fatalf
(
"Expected 1 hook, got %d"
,
len
(
updated
.
Hooks
))
}
if
updated
.
Hooks
[
0
]
.
Manifest
!=
manifestWithUpgradeHooks
{
t
.
Errorf
(
"Unexpected manifest: %v"
,
updated
.
Hooks
[
0
]
.
Manifest
)
}
if
updated
.
Hooks
[
0
]
.
Events
[
0
]
!=
release
.
Hook_POST_UPGRADE
{
t
.
Errorf
(
"Expected event 0 to be post upgrade"
)
}
if
updated
.
Hooks
[
0
]
.
Events
[
1
]
!=
release
.
Hook_PRE_UPGRADE
{
t
.
Errorf
(
"Expected event 0 to be pre upgrade"
)
}
if
len
(
res
.
Release
.
Manifest
)
==
0
{
t
.
Errorf
(
"No manifest returned: %v"
,
res
.
Release
)
}
...
...
@@ -343,6 +370,35 @@ func TestUpdateRelease(t *testing.T) {
}
}
func
TestUpdateReleaseNoHooks
(
t
*
testing
.
T
)
{
c
:=
context
.
Background
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
req
:=
&
services
.
UpdateReleaseRequest
{
Name
:
rel
.
Name
,
DisableHooks
:
true
,
Chart
:
&
chart
.
Chart
{
Metadata
:
&
chart
.
Metadata
{
Name
:
"hello"
},
Templates
:
[]
*
chart
.
Template
{
{
Name
:
"hello"
,
Data
:
[]
byte
(
"hello: world"
)},
{
Name
:
"hooks"
,
Data
:
[]
byte
(
manifestWithUpgradeHooks
)},
},
},
}
res
,
err
:=
rs
.
UpdateRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed updated: %s"
,
err
)
}
if
hl
:=
res
.
Release
.
Hooks
[
0
]
.
LastRun
;
hl
!=
nil
{
t
.
Errorf
(
"Expected that no hooks were run. Got %d"
,
hl
)
}
}
func
TestUninstallRelease
(
t
*
testing
.
T
)
{
c
:=
context
.
Background
()
rs
:=
rsFixture
()
...
...
pkg/helm/option.go
View file @
f9922877
...
...
@@ -244,7 +244,6 @@ func (o *options) rpcDeleteRelease(rlsName string, rlc rls.ReleaseServiceClient,
// Executes tiller.UpdateRelease RPC.
func
(
o
*
options
)
rpcUpdateRelease
(
rlsName
string
,
chr
*
cpb
.
Chart
,
rlc
rls
.
ReleaseServiceClient
,
opts
...
UpdateOption
)
(
*
rls
.
UpdateReleaseResponse
,
error
)
{
//TODO: handle dryRun
for
_
,
opt
:=
range
opts
{
opt
(
o
)
}
...
...
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