diff --git a/cmd/helm/rollback.go b/cmd/helm/rollback.go index 4849913a1..2cd6fa2cb 100644 --- a/cmd/helm/rollback.go +++ b/cmd/helm/rollback.go @@ -83,6 +83,7 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout") f.BoolVar(&client.CleanupOnFail, "cleanup-on-fail", false, "allow deletion of new resources created in this rollback when rollback fails") + f.IntVar(&client.MaxHistory, "history-max", settings.MaxHistory, "limit the maximum number of revisions saved per release. Use 0 for no limit") return cmd } diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 81812983f..8773b6271 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -42,6 +42,7 @@ type Rollback struct { Recreate bool // will (if true) recreate pods after a rollback. Force bool // will (if true) force resource upgrade through uninstall/recreate if needed CleanupOnFail bool + MaxHistory int // MaxHistory limits the maximum number of revisions saved per release } // NewRollback creates a new Rollback object with the given configuration. @@ -57,6 +58,8 @@ func (r *Rollback) Run(name string) error { return err } + r.cfg.Releases.MaxHistory = r.MaxHistory + r.cfg.Log("preparing rollback of %s", name) currentRelease, targetRelease, err := r.prepareRollback(name) if err != nil {