mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
Merge pull request #5283 from bacongobbler/purge-by-default
ref(uninstall): purge release history by default
This commit is contained in:
commit
b1ae1acc8b
6 changed files with 24 additions and 12 deletions
|
|
@ -27,8 +27,10 @@ import (
|
|||
)
|
||||
|
||||
const uninstallDesc = `
|
||||
This command takes a release name, and then uninstalls the release from Kubernetes.
|
||||
It removes all of the resources associated with the last release of the chart.
|
||||
This command takes a release name and uninstalls the release.
|
||||
|
||||
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
|
||||
uninstalling them.
|
||||
|
|
@ -41,7 +43,7 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Use: "uninstall RELEASE_NAME [...]",
|
||||
Aliases: []string{"del", "delete", "un"},
|
||||
SuggestFor: []string{"remove", "rm"},
|
||||
Short: "given a release name, uninstall the release from Kubernetes",
|
||||
Short: "uninstall a release",
|
||||
Long: uninstallDesc,
|
||||
Args: require.MinimumNArgs(1),
|
||||
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.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.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)")
|
||||
|
||||
return cmd
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ func TestUninstall(t *testing.T) {
|
|||
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})},
|
||||
},
|
||||
{
|
||||
name: "purge",
|
||||
cmd: "uninstall aeneas --purge",
|
||||
golden: "output/uninstall-purge.txt",
|
||||
name: "keep history",
|
||||
cmd: "uninstall aeneas --keep-history",
|
||||
golden: "output/uninstall-keep-history.txt",
|
||||
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
10
docs/faq.md
10
docs/faq.md
|
|
@ -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
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ type Uninstall struct {
|
|||
|
||||
DisableHooks bool
|
||||
DryRun bool
|
||||
Purge bool
|
||||
KeepHistory bool
|
||||
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
|
||||
// already marked deleted?
|
||||
if rel.Info.Status == release.StatusUninstalled {
|
||||
if u.Purge {
|
||||
if !u.KeepHistory {
|
||||
if err := u.purgeReleases(rels...); err != nil {
|
||||
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.Description = "Uninstallation complete"
|
||||
|
||||
if u.Purge {
|
||||
if !u.KeepHistory {
|
||||
u.cfg.Log("purge requested for %s", name)
|
||||
err := u.purgeReleases(rels...)
|
||||
return res, errors.Wrap(err, "uninstall: Failed to purge the release")
|
||||
|
|
|
|||
|
|
@ -287,8 +287,8 @@ _helm_delete()
|
|||
local_nonpersistent_flags+=("--dry-run")
|
||||
flags+=("--no-hooks")
|
||||
local_nonpersistent_flags+=("--no-hooks")
|
||||
flags+=("--purge")
|
||||
local_nonpersistent_flags+=("--purge")
|
||||
flags+=("--keep-history")
|
||||
local_nonpersistent_flags+=("--keep-history")
|
||||
flags+=("--timeout=")
|
||||
local_nonpersistent_flags+=("--timeout=")
|
||||
flags+=("--tls")
|
||||
|
|
|
|||
Loading…
Reference in a new issue