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
43ce6b57
Commit
43ce6b57
authored
Aug 04, 2017
by
Baofa Fan
Committed by
Adam Reese
Aug 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete secret when helm reset (#2715)
* delete secret when helm reset * add test * expected 3 actions
parent
b5552067
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
14 deletions
+39
-14
install.go
cmd/helm/installer/install.go
+0
-1
uninstall.go
cmd/helm/installer/uninstall.go
+11
-1
uninstall_test.go
cmd/helm/installer/uninstall_test.go
+22
-6
reset_test.go
cmd/helm/reset_test.go
+6
-6
No files found.
cmd/helm/installer/install.go
View file @
43ce6b57
...
...
@@ -251,7 +251,6 @@ func createSecret(client corev1.SecretsGetter, opts *Options) error {
// generateSecret builds the secret object that hold Tiller secrets.
func
generateSecret
(
opts
*
Options
)
(
*
v1
.
Secret
,
error
)
{
const
secretName
=
"tiller-secret"
labels
:=
generateLabels
(
map
[
string
]
string
{
"name"
:
"tiller"
})
secret
:=
&
v1
.
Secret
{
...
...
cmd/helm/installer/uninstall.go
View file @
43ce6b57
...
...
@@ -28,6 +28,7 @@ import (
const
(
deploymentName
=
"tiller-deploy"
serviceName
=
"tiller-deploy"
secretName
=
"tiller-secret"
)
// Uninstall uses Kubernetes client to uninstall Tiller.
...
...
@@ -35,7 +36,10 @@ func Uninstall(client internalclientset.Interface, opts *Options) error {
if
err
:=
deleteService
(
client
.
Core
(),
opts
.
Namespace
);
err
!=
nil
{
return
err
}
return
deleteDeployment
(
client
,
opts
.
Namespace
)
if
err
:=
deleteDeployment
(
client
,
opts
.
Namespace
);
err
!=
nil
{
return
err
}
return
deleteSecret
(
client
.
Core
(),
opts
.
Namespace
)
}
// deleteService deletes the Tiller Service resource
...
...
@@ -53,6 +57,12 @@ func deleteDeployment(client internalclientset.Interface, namespace string) erro
return
ingoreNotFound
(
err
)
}
// deleteSecret deletes the Tiller Secret resource
func
deleteSecret
(
client
coreclient
.
SecretsGetter
,
namespace
string
)
error
{
err
:=
client
.
Secrets
(
namespace
)
.
Delete
(
secretName
,
&
metav1
.
DeleteOptions
{})
return
ingoreNotFound
(
err
)
}
func
ingoreNotFound
(
err
error
)
error
{
if
apierrors
.
IsNotFound
(
err
)
{
return
nil
...
...
cmd/helm/installer/uninstall_test.go
View file @
43ce6b57
...
...
@@ -34,8 +34,8 @@ func TestUninstall(t *testing.T) {
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
if
actions
:=
fc
.
Actions
();
len
(
actions
)
!=
6
{
t
.
Errorf
(
"unexpected actions: %v, expected
6
actions got %d"
,
actions
,
len
(
actions
))
if
actions
:=
fc
.
Actions
();
len
(
actions
)
!=
7
{
t
.
Errorf
(
"unexpected actions: %v, expected
7
actions got %d"
,
actions
,
len
(
actions
))
}
}
...
...
@@ -50,8 +50,8 @@ func TestUninstall_serviceNotFound(t *testing.T) {
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
if
actions
:=
fc
.
Actions
();
len
(
actions
)
!=
6
{
t
.
Errorf
(
"unexpected actions: %v, expected
6
actions got %d"
,
actions
,
len
(
actions
))
if
actions
:=
fc
.
Actions
();
len
(
actions
)
!=
7
{
t
.
Errorf
(
"unexpected actions: %v, expected
7
actions got %d"
,
actions
,
len
(
actions
))
}
}
...
...
@@ -66,7 +66,23 @@ func TestUninstall_deploymentNotFound(t *testing.T) {
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
if
actions
:=
fc
.
Actions
();
len
(
actions
)
!=
6
{
t
.
Errorf
(
"unexpected actions: %v, expected 6 actions got %d"
,
actions
,
len
(
actions
))
if
actions
:=
fc
.
Actions
();
len
(
actions
)
!=
7
{
t
.
Errorf
(
"unexpected actions: %v, expected 7 actions got %d"
,
actions
,
len
(
actions
))
}
}
func
TestUninstall_secretNotFound
(
t
*
testing
.
T
)
{
fc
:=
&
fake
.
Clientset
{}
fc
.
AddReactor
(
"delete"
,
"secrets"
,
func
(
action
testcore
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
return
true
,
nil
,
apierrors
.
NewNotFound
(
api
.
Resource
(
"secrets"
),
"1"
)
})
opts
:=
&
Options
{
Namespace
:
api
.
NamespaceDefault
}
if
err
:=
Uninstall
(
fc
,
opts
);
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
if
actions
:=
fc
.
Actions
();
len
(
actions
)
!=
7
{
t
.
Errorf
(
"unexpected actions: %v, expect 7 actions got %d"
,
actions
,
len
(
actions
))
}
}
cmd/helm/reset_test.go
View file @
43ce6b57
...
...
@@ -52,8 +52,8 @@ func TestResetCmd(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
actions
:=
fc
.
Actions
()
if
len
(
actions
)
!=
2
{
t
.
Errorf
(
"Expected
2
actions, got %d"
,
len
(
actions
))
if
len
(
actions
)
!=
3
{
t
.
Errorf
(
"Expected
3
actions, got %d"
,
len
(
actions
))
}
expected
:=
"Tiller (the Helm server-side component) has been uninstalled from your Kubernetes Cluster."
if
!
strings
.
Contains
(
buf
.
String
(),
expected
)
{
...
...
@@ -86,8 +86,8 @@ func TestResetCmd_removeHelmHome(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
actions
:=
fc
.
Actions
()
if
len
(
actions
)
!=
2
{
t
.
Errorf
(
"Expected
2
actions, got %d"
,
len
(
actions
))
if
len
(
actions
)
!=
3
{
t
.
Errorf
(
"Expected
3
actions, got %d"
,
len
(
actions
))
}
expected
:=
"Tiller (the Helm server-side component) has been uninstalled from your Kubernetes Cluster."
if
!
strings
.
Contains
(
buf
.
String
(),
expected
)
{
...
...
@@ -157,8 +157,8 @@ func TestReset_forceFlag(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
actions
:=
fc
.
Actions
()
if
len
(
actions
)
!=
2
{
t
.
Errorf
(
"Expected
2
actions, got %d"
,
len
(
actions
))
if
len
(
actions
)
!=
3
{
t
.
Errorf
(
"Expected
3
actions, got %d"
,
len
(
actions
))
}
expected
:=
"Tiller (the Helm server-side component) has been uninstalled from your Kubernetes Cluster."
if
!
strings
.
Contains
(
buf
.
String
(),
expected
)
{
...
...
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