helm uninstall

The goal is to have the same behaviour with or without dry-run with --ignore-not-found

close #12970

Signed-off-by: Stephane Jeandeaux <stephane.jeandeaux@gmail.com>
pull/12968/head
Stephane Jeandeaux 1 year ago
parent c6f9fd0fe0
commit b3568a67a8
No known key found for this signature in database
GPG Key ID: 167157842698B63C

@ -66,12 +66,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
default:
return &release.UninstallReleaseResponse{}, err
}
return &release.UninstallReleaseResponse{Release: r}, nil
}
if err := chartutil.ValidateReleaseName(name); err != nil {

@ -34,6 +34,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
@ -44,7 +55,6 @@ func TestUninstallRelease_ignoreNotFound(t *testing.T) {
is.Nil(res)
is.NoError(err)
}
func TestUninstallRelease_deleteRelease(t *testing.T) {
is := assert.New(t)

Loading…
Cancel
Save