diff --git a/main.go b/main.go index f84acf44..9a385e86 100644 --- a/main.go +++ b/main.go @@ -386,7 +386,11 @@ func main() { }, cli.BoolFlag{ Name: "retain-values-files", - Usage: "Stop cleaning up values files passed to Helm. Together with --log-level=debug, you can manually rerun helm commands as Helmfile did for debugging purpose", + Usage: "DEPRECATED: Use skip-cleanup instead", + }, + cli.BoolFlag{ + Name: "skip-cleanup", + Usage: "Stop cleaning up temporary values generated by helmfile and helm-secrets. Useful for debugging. Don't use in production for security", }, cli.BoolFlag{ Name: "include-tests", @@ -725,6 +729,10 @@ func (c configImpl) Context() int { return c.c.Int("context") } +func (c configImpl) SkipCleanup() bool { + return c.c.Bool("skip-cleanup") +} + func (c configImpl) EmbedValues() bool { return c.c.Bool("embed-values") } diff --git a/pkg/app/app.go b/pkg/app/app.go index 80a2b09c..1c0e754f 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -296,7 +296,7 @@ func (a *App) Apply(c ApplyConfigProvider) error { var opts []LoadOption - opts = append(opts, SetRetainValuesFiles(c.RetainValuesFiles())) + opts = append(opts, SetRetainValuesFiles(c.RetainValuesFiles() || c.SkipCleanup())) err := a.ForEachState(func(run *Run) (ok bool, errs []error) { prepErr := run.withPreparedCharts("apply", state.ChartPrepareOptions{ @@ -1059,9 +1059,10 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) { detailedExitCode := true diffOpts := &state.DiffOpts{ - NoColor: c.NoColor(), - Context: c.Context(), - Set: c.Set(), + NoColor: c.NoColor(), + Context: c.Context(), + Set: c.Set(), + SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(), } infoMsg, releasesToBeUpdated, releasesToBeDeleted, errs := r.diff(false, detailedExitCode, c, diffOpts) @@ -1150,7 +1151,8 @@ Do you really want to apply? subst.Releases = rs syncOpts := state.SyncOpts{ - Set: c.Set(), + Set: c.Set(), + SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(), } return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), &syncOpts) })) diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index 8c126a2e..b36fb159 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -2298,6 +2298,7 @@ type applyConfig struct { retainValuesFiles bool set []string validate bool + skipCleanup bool skipDeps bool includeTests bool suppressSecrets bool @@ -2326,6 +2327,10 @@ func (a applyConfig) Validate() bool { return a.validate } +func (a applyConfig) SkipCleanup() bool { + return a.skipCleanup +} + func (a applyConfig) SkipDeps() bool { return a.skipDeps } diff --git a/pkg/app/config.go b/pkg/app/config.go index 484ee606..a5d27f2b 100644 --- a/pkg/app/config.go +++ b/pkg/app/config.go @@ -51,6 +51,7 @@ type ApplyConfigProvider interface { Context() int RetainValuesFiles() bool + SkipCleanup() bool concurrencyConfig interactive diff --git a/pkg/state/state.go b/pkg/state/state.go index 8a655bc8..591392e8 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -535,7 +535,8 @@ func (st *HelmState) DetectReleasesToBeDeleted(helm helmexec.Interface, releases } type SyncOpts struct { - Set []string + Set []string + SkipCleanup bool } type SyncOpt interface{ Apply(*SyncOpts) } @@ -1549,6 +1550,8 @@ type DiffOpts struct { Context int NoColor bool Set []string + + SkipCleanup bool } func (o *DiffOpts) Apply(opts *DiffOpts) {