feat: Add `helmfile apply --skip-cleanup` (#1571)

This deprecates the old `--retain-values` which was not working as intended.

Also see #1570 - there's now `--skip-cleanup` for `helmfile-template`, too.
This commit is contained in:
Yusuke Kuoka 2020-11-05 10:18:30 +09:00 committed by GitHub
parent 3899680672
commit 5a15b65b94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 7 deletions

10
main.go
View File

@ -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")
}

View File

@ -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)
}))

View File

@ -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
}

View File

@ -51,6 +51,7 @@ type ApplyConfigProvider interface {
Context() int
RetainValuesFiles() bool
SkipCleanup() bool
concurrencyConfig
interactive

View File

@ -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) {