ref(uninstall): purge release history by default

Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
pull/5283/head
Matthew Fisher 6 years ago
parent 0b1caa14a7
commit 0805a87140
No known key found for this signature in database
GPG Key ID: 92AA783CBAAE8E3B

@ -27,8 +27,10 @@ import (
) )
const uninstallDesc = ` const uninstallDesc = `
This command takes a release name, and then uninstalls the release from Kubernetes. This command takes a release name and uninstalls the release.
It removes all of the resources associated with the last release of the chart.
It removes all of the resources associated with the last release of the chart
as well as the release history, freeing it up for future use.
Use the '--dry-run' flag to see which releases will be uninstalled without actually Use the '--dry-run' flag to see which releases will be uninstalled without actually
uninstalling them. uninstalling them.
@ -41,7 +43,7 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
Use: "uninstall RELEASE_NAME [...]", Use: "uninstall RELEASE_NAME [...]",
Aliases: []string{"del", "delete", "un"}, Aliases: []string{"del", "delete", "un"},
SuggestFor: []string{"remove", "rm"}, SuggestFor: []string{"remove", "rm"},
Short: "given a release name, uninstall the release from Kubernetes", Short: "uninstall a release",
Long: uninstallDesc, Long: uninstallDesc,
Args: require.MinimumNArgs(1), Args: require.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -64,7 +66,7 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.BoolVar(&client.DryRun, "dry-run", false, "simulate a uninstall") f.BoolVar(&client.DryRun, "dry-run", false, "simulate a uninstall")
f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation") f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation")
f.BoolVar(&client.Purge, "purge", false, "remove the release from the store and make its name free for later use") f.BoolVar(&client.KeepHistory, "keep-history", false, "remove all associated resources and mark the release as deleted, but retain the release history")
f.Int64Var(&client.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") f.Int64Var(&client.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)")
return cmd return cmd

@ -43,9 +43,9 @@ func TestUninstall(t *testing.T) {
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})}, rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})},
}, },
{ {
name: "purge", name: "keep history",
cmd: "uninstall aeneas --purge", cmd: "uninstall aeneas --keep-history",
golden: "output/uninstall-purge.txt", golden: "output/uninstall-keep-history.txt",
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})}, rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})},
}, },
{ {

@ -15,6 +15,16 @@ Here's an exhaustive list of all the major changes introduced in Helm 3.
In Helm 3, Helm switched the Go import path over from `k8s.io/helm` to `helm.sh/helm`. If you intend In Helm 3, Helm switched the Go import path over from `k8s.io/helm` to `helm.sh/helm`. If you intend
to upgrade to the Helm 3 Go client libraries, make sure to change your import paths. to upgrade to the Helm 3 Go client libraries, make sure to change your import paths.
### Helm delete
In order to better align the verbiage from other package managers, `helm delete` was re-named to
`helm uninstall`. `helm delete` is still retained as an alias to `helm uninstall`, so either form
can be used.
In Helm 2, in order to purge the release ledger, the `--purge` flag had to be provided. This
functionality is now enabled by default. To retain the previous behaviour, use
`helm uninstall --keep-history`.
## Installing ## Installing

@ -38,7 +38,7 @@ type Uninstall struct {
DisableHooks bool DisableHooks bool
DryRun bool DryRun bool
Purge bool KeepHistory bool
Timeout int64 Timeout int64
} }
@ -78,7 +78,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error)
// TODO: Are there any cases where we want to force a delete even if it's // TODO: Are there any cases where we want to force a delete even if it's
// already marked deleted? // already marked deleted?
if rel.Info.Status == release.StatusUninstalled { if rel.Info.Status == release.StatusUninstalled {
if u.Purge { if !u.KeepHistory {
if err := u.purgeReleases(rels...); err != nil { if err := u.purgeReleases(rels...); err != nil {
return nil, errors.Wrap(err, "uninstall: Failed to purge the release") return nil, errors.Wrap(err, "uninstall: Failed to purge the release")
} }
@ -119,7 +119,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error)
rel.Info.Status = release.StatusUninstalled rel.Info.Status = release.StatusUninstalled
rel.Info.Description = "Uninstallation complete" rel.Info.Description = "Uninstallation complete"
if u.Purge { if !u.KeepHistory {
u.cfg.Log("purge requested for %s", name) u.cfg.Log("purge requested for %s", name)
err := u.purgeReleases(rels...) err := u.purgeReleases(rels...)
return res, errors.Wrap(err, "uninstall: Failed to purge the release") return res, errors.Wrap(err, "uninstall: Failed to purge the release")

@ -287,8 +287,8 @@ _helm_delete()
local_nonpersistent_flags+=("--dry-run") local_nonpersistent_flags+=("--dry-run")
flags+=("--no-hooks") flags+=("--no-hooks")
local_nonpersistent_flags+=("--no-hooks") local_nonpersistent_flags+=("--no-hooks")
flags+=("--purge") flags+=("--keep-history")
local_nonpersistent_flags+=("--purge") local_nonpersistent_flags+=("--keep-history")
flags+=("--timeout=") flags+=("--timeout=")
local_nonpersistent_flags+=("--timeout=") local_nonpersistent_flags+=("--timeout=")
flags+=("--tls") flags+=("--tls")

Loading…
Cancel
Save