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
1ea977b5
Commit
1ea977b5
authored
Oct 18, 2016
by
Adam Reese
Committed by
GitHub
Oct 18, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1405 from adamreese/fix/1395-purge-all
fix(tiller): delete all revisions with --purge
parents
fcdb79da
4f4be2ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
release_server.go
cmd/tiller/release_server.go
+11
-2
release_server_test.go
cmd/tiller/release_server_test.go
+12
-5
No files found.
cmd/tiller/release_server.go
View file @
1ea977b5
...
@@ -803,6 +803,15 @@ func (s *releaseServer) execHook(hs []*release.Hook, name, namespace, hook strin
...
@@ -803,6 +803,15 @@ func (s *releaseServer) execHook(hs []*release.Hook, name, namespace, hook strin
return
nil
return
nil
}
}
func
(
s
*
releaseServer
)
purgeReleases
(
rels
...*
release
.
Release
)
error
{
for
_
,
rel
:=
range
rels
{
if
_
,
err
:=
s
.
env
.
Releases
.
Delete
(
rel
.
Name
,
rel
.
Version
);
err
!=
nil
{
return
err
}
}
return
nil
}
func
(
s
*
releaseServer
)
UninstallRelease
(
c
ctx
.
Context
,
req
*
services
.
UninstallReleaseRequest
)
(
*
services
.
UninstallReleaseResponse
,
error
)
{
func
(
s
*
releaseServer
)
UninstallRelease
(
c
ctx
.
Context
,
req
*
services
.
UninstallReleaseRequest
)
(
*
services
.
UninstallReleaseResponse
,
error
)
{
if
!
checkClientVersion
(
c
)
{
if
!
checkClientVersion
(
c
)
{
return
nil
,
errIncompatibleVersion
return
nil
,
errIncompatibleVersion
...
@@ -829,7 +838,7 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR
...
@@ -829,7 +838,7 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR
// already marked deleted?
// already marked deleted?
if
rel
.
Info
.
Status
.
Code
==
release
.
Status_DELETED
{
if
rel
.
Info
.
Status
.
Code
==
release
.
Status_DELETED
{
if
req
.
Purge
{
if
req
.
Purge
{
if
_
,
err
:=
s
.
env
.
Releases
.
Delete
(
rel
.
Name
,
rel
.
Version
);
err
!=
nil
{
if
err
:=
s
.
purgeReleases
(
rels
...
);
err
!=
nil
{
log
.
Printf
(
"uninstall: Failed to purge the release: %s"
,
err
)
log
.
Printf
(
"uninstall: Failed to purge the release: %s"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
...
@@ -882,7 +891,7 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR
...
@@ -882,7 +891,7 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR
log
.
Printf
(
"uninstall: Failed to store updated release: %s"
,
err
)
log
.
Printf
(
"uninstall: Failed to store updated release: %s"
,
err
)
}
}
}
else
{
}
else
{
if
_
,
err
:=
s
.
env
.
Releases
.
Delete
(
rel
.
Name
,
rel
.
Version
);
err
!=
nil
{
if
err
:=
s
.
purgeReleases
(
rels
...
);
err
!=
nil
{
log
.
Printf
(
"uninstall: Failed to purge the release: %s"
,
err
)
log
.
Printf
(
"uninstall: Failed to purge the release: %s"
,
err
)
}
}
}
}
...
...
cmd/tiller/release_server_test.go
View file @
1ea977b5
...
@@ -902,7 +902,11 @@ func TestUninstallRelease(t *testing.T) {
...
@@ -902,7 +902,11 @@ func TestUninstallRelease(t *testing.T) {
func
TestUninstallPurgeRelease
(
t
*
testing
.
T
)
{
func
TestUninstallPurgeRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rs
:=
rsFixture
()
rs
.
env
.
Releases
.
Create
(
releaseStub
())
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
UninstallReleaseRequest
{
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
Name
:
"angry-panda"
,
...
@@ -922,13 +926,16 @@ func TestUninstallPurgeRelease(t *testing.T) {
...
@@ -922,13 +926,16 @@ func TestUninstallPurgeRelease(t *testing.T) {
t
.
Errorf
(
"Expected status code to be DELETED, got %d"
,
res
.
Release
.
Info
.
Status
.
Code
)
t
.
Errorf
(
"Expected status code to be DELETED, got %d"
,
res
.
Release
.
Info
.
Status
.
Code
)
}
}
if
res
.
Release
.
Hooks
[
0
]
.
LastRun
.
Seconds
==
0
{
t
.
Error
(
"Expected LastRun to be greater than zero."
)
}
if
res
.
Release
.
Info
.
Deleted
.
Seconds
<=
0
{
if
res
.
Release
.
Info
.
Deleted
.
Seconds
<=
0
{
t
.
Errorf
(
"Expected valid UNIX date, got %d"
,
res
.
Release
.
Info
.
Deleted
.
Seconds
)
t
.
Errorf
(
"Expected valid UNIX date, got %d"
,
res
.
Release
.
Info
.
Deleted
.
Seconds
)
}
}
rels
,
err
:=
rs
.
GetHistory
(
helm
.
NewContext
(),
&
services
.
GetHistoryRequest
{
Name
:
"angry-panda"
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
rels
.
Releases
)
!=
0
{
t
.
Errorf
(
"Expected no releases in storage, got %d"
,
len
(
rels
.
Releases
))
}
}
}
func
TestUninstallPurgeDeleteRelease
(
t
*
testing
.
T
)
{
func
TestUninstallPurgeDeleteRelease
(
t
*
testing
.
T
)
{
...
...
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