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:
		
							parent
							
								
									3899680672
								
							
						
					
					
						commit
						5a15b65b94
					
				
							
								
								
									
										10
									
								
								main.go
								
								
								
								
							
							
						
						
									
										10
									
								
								main.go
								
								
								
								
							|  | @ -386,7 +386,11 @@ func main() { | ||||||
| 				}, | 				}, | ||||||
| 				cli.BoolFlag{ | 				cli.BoolFlag{ | ||||||
| 					Name:  "retain-values-files", | 					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{ | 				cli.BoolFlag{ | ||||||
| 					Name:  "include-tests", | 					Name:  "include-tests", | ||||||
|  | @ -725,6 +729,10 @@ func (c configImpl) Context() int { | ||||||
| 	return c.c.Int("context") | 	return c.c.Int("context") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (c configImpl) SkipCleanup() bool { | ||||||
|  | 	return c.c.Bool("skip-cleanup") | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (c configImpl) EmbedValues() bool { | func (c configImpl) EmbedValues() bool { | ||||||
| 	return c.c.Bool("embed-values") | 	return c.c.Bool("embed-values") | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -296,7 +296,7 @@ func (a *App) Apply(c ApplyConfigProvider) error { | ||||||
| 
 | 
 | ||||||
| 	var opts []LoadOption | 	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) { | 	err := a.ForEachState(func(run *Run) (ok bool, errs []error) { | ||||||
| 		prepErr := run.withPreparedCharts("apply", state.ChartPrepareOptions{ | 		prepErr := run.withPreparedCharts("apply", state.ChartPrepareOptions{ | ||||||
|  | @ -1059,9 +1059,10 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) { | ||||||
| 	detailedExitCode := true | 	detailedExitCode := true | ||||||
| 
 | 
 | ||||||
| 	diffOpts := &state.DiffOpts{ | 	diffOpts := &state.DiffOpts{ | ||||||
| 		NoColor: c.NoColor(), | 		NoColor:     c.NoColor(), | ||||||
| 		Context: c.Context(), | 		Context:     c.Context(), | ||||||
| 		Set:     c.Set(), | 		Set:         c.Set(), | ||||||
|  | 		SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	infoMsg, releasesToBeUpdated, releasesToBeDeleted, errs := r.diff(false, detailedExitCode, c, diffOpts) | 	infoMsg, releasesToBeUpdated, releasesToBeDeleted, errs := r.diff(false, detailedExitCode, c, diffOpts) | ||||||
|  | @ -1150,7 +1151,8 @@ Do you really want to apply? | ||||||
| 				subst.Releases = rs | 				subst.Releases = rs | ||||||
| 
 | 
 | ||||||
| 				syncOpts := state.SyncOpts{ | 				syncOpts := state.SyncOpts{ | ||||||
| 					Set: c.Set(), | 					Set:         c.Set(), | ||||||
|  | 					SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(), | ||||||
| 				} | 				} | ||||||
| 				return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), &syncOpts) | 				return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), &syncOpts) | ||||||
| 			})) | 			})) | ||||||
|  |  | ||||||
|  | @ -2298,6 +2298,7 @@ type applyConfig struct { | ||||||
| 	retainValuesFiles bool | 	retainValuesFiles bool | ||||||
| 	set               []string | 	set               []string | ||||||
| 	validate          bool | 	validate          bool | ||||||
|  | 	skipCleanup       bool | ||||||
| 	skipDeps          bool | 	skipDeps          bool | ||||||
| 	includeTests      bool | 	includeTests      bool | ||||||
| 	suppressSecrets   bool | 	suppressSecrets   bool | ||||||
|  | @ -2326,6 +2327,10 @@ func (a applyConfig) Validate() bool { | ||||||
| 	return a.validate | 	return a.validate | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (a applyConfig) SkipCleanup() bool { | ||||||
|  | 	return a.skipCleanup | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (a applyConfig) SkipDeps() bool { | func (a applyConfig) SkipDeps() bool { | ||||||
| 	return a.skipDeps | 	return a.skipDeps | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -51,6 +51,7 @@ type ApplyConfigProvider interface { | ||||||
| 	Context() int | 	Context() int | ||||||
| 
 | 
 | ||||||
| 	RetainValuesFiles() bool | 	RetainValuesFiles() bool | ||||||
|  | 	SkipCleanup() bool | ||||||
| 
 | 
 | ||||||
| 	concurrencyConfig | 	concurrencyConfig | ||||||
| 	interactive | 	interactive | ||||||
|  |  | ||||||
|  | @ -535,7 +535,8 @@ func (st *HelmState) DetectReleasesToBeDeleted(helm helmexec.Interface, releases | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type SyncOpts struct { | type SyncOpts struct { | ||||||
| 	Set []string | 	Set         []string | ||||||
|  | 	SkipCleanup bool | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type SyncOpt interface{ Apply(*SyncOpts) } | type SyncOpt interface{ Apply(*SyncOpts) } | ||||||
|  | @ -1549,6 +1550,8 @@ type DiffOpts struct { | ||||||
| 	Context int | 	Context int | ||||||
| 	NoColor bool | 	NoColor bool | ||||||
| 	Set     []string | 	Set     []string | ||||||
|  | 
 | ||||||
|  | 	SkipCleanup bool | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (o *DiffOpts) Apply(opts *DiffOpts) { | func (o *DiffOpts) Apply(opts *DiffOpts) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue