diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index 61e10b2c8..6306a93b4 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -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 { diff --git a/pkg/action/uninstall_test.go b/pkg/action/uninstall_test.go index 8b148522c..8e8af7493 100644 --- a/pkg/action/uninstall_test.go +++ b/pkg/action/uninstall_test.go @@ -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)