Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm uninstall #12968

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkg/action/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"helm.sh/helm/v3/pkg/kube"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/releaseutil"
"helm.sh/helm/v3/pkg/storage/driver"
helmtime "helm.sh/helm/v3/pkg/time"
)

Expand Down Expand Up @@ -61,12 +62,15 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error)
}

if u.DryRun {
// In the dry run case, just see if the release exists
r, err := u.cfg.releaseContent(name, 0)
if err != nil {
switch {
case u.IgnoreNotFound && errors.As(err, &driver.ErrReleaseNotFound):
fallthrough
case err == nil:
return &release.UninstallReleaseResponse{Release: r}, nil
sjeandeaux marked this conversation as resolved.
Show resolved Hide resolved
default:
return &release.UninstallReleaseResponse{}, err
}
return &release.UninstallReleaseResponse{Release: r}, nil
}

if err := chartutil.ValidateReleaseName(name); err != nil {
Expand Down
12 changes: 11 additions & 1 deletion pkg/action/uninstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ func uninstallAction(t *testing.T) *Uninstall {
return unAction
}

func TestUninstallRelease_dryRun_ignoreNotFound(t *testing.T) {
unAction := uninstallAction(t)
unAction.DryRun = true
unAction.IgnoreNotFound = true

is := assert.New(t)
res, err := unAction.Run("release-non-exist")
is.NotNil(res)
is.NoError(err)
}

func TestUninstallRelease_ignoreNotFound(t *testing.T) {
unAction := uninstallAction(t)
unAction.DryRun = false
Expand All @@ -42,7 +53,6 @@ func TestUninstallRelease_ignoreNotFound(t *testing.T) {
is.Nil(res)
is.NoError(err)
}

func TestUninstallRelease_deleteRelease(t *testing.T) {
is := assert.New(t)

Expand Down