add cleanup to write-values & lint to harmonise this flag (#2021)
This commit is contained in:
parent
346e318fd0
commit
c069fbf268
|
|
@ -258,6 +258,7 @@ func (a *App) WriteValues(c WriteValuesConfigProvider) error {
|
|||
ForceDownload: !run.helm.IsHelm3(),
|
||||
SkipRepos: c.SkipDeps(),
|
||||
SkipDeps: c.SkipDeps(),
|
||||
SkipCleanup: c.SkipCleanup(),
|
||||
}, func() {
|
||||
ok, errs = a.writeValues(run, c)
|
||||
})
|
||||
|
|
@ -307,6 +308,7 @@ func (a *App) Lint(c LintConfigProvider) error {
|
|||
ForceDownload: true,
|
||||
SkipRepos: c.SkipDeps(),
|
||||
SkipDeps: c.SkipDeps(),
|
||||
SkipCleanup: c.SkipCleanup(),
|
||||
}, func() {
|
||||
ok, lintErrs, errs = a.lint(run, c)
|
||||
})
|
||||
|
|
@ -1560,7 +1562,8 @@ func (a *App) lint(r *Run, c LintConfigProvider) (bool, []error, []error) {
|
|||
if len(toLint) > 0 {
|
||||
_, templateErrs := withDAG(st, helm, a.Logger, state.PlanOptions{SelectedReleases: toLint, Reverse: false, SkipNeeds: true}, a.WrapWithoutSelector(func(subst *state.HelmState, helm helmexec.Interface) []error {
|
||||
opts := &state.LintOpts{
|
||||
Set: c.Set(),
|
||||
Set: c.Set(),
|
||||
SkipCleanup: c.SkipCleanup(),
|
||||
}
|
||||
lintErrs := subst.LintReleases(helm, c.Values(), args, c.Concurrency(), opts)
|
||||
if len(lintErrs) == 1 {
|
||||
|
|
@ -1933,6 +1936,7 @@ func (a *App) writeValues(r *Run, c WriteValuesConfigProvider) (bool, []error) {
|
|||
opts := &state.WriteValuesOpts{
|
||||
Set: c.Set(),
|
||||
OutputFileTemplate: c.OutputFileTemplate(),
|
||||
SkipCleanup: c.SkipCleanup(),
|
||||
}
|
||||
errs = st.WriteReleasesValues(helm, c.Values(), opts)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ type LintConfigProvider interface {
|
|||
Values() []string
|
||||
Set() []string
|
||||
SkipDeps() bool
|
||||
SkipCleanup() bool
|
||||
|
||||
concurrencyConfig
|
||||
}
|
||||
|
|
@ -189,6 +190,7 @@ type WriteValuesConfigProvider interface {
|
|||
Set() []string
|
||||
OutputFileTemplate() string
|
||||
SkipDeps() bool
|
||||
SkipCleanup() bool
|
||||
IncludeTransitiveNeeds() bool
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ func (st *HelmState) prepareSyncReleases(helm helmexec.Interface, additionalValu
|
|||
}
|
||||
|
||||
releases := []*ReleaseSpec{}
|
||||
for i, _ := range st.Releases {
|
||||
for i := range st.Releases {
|
||||
releases = append(releases, &st.Releases[i])
|
||||
}
|
||||
|
||||
|
|
@ -766,15 +766,13 @@ func (st *HelmState) SyncReleases(affectedReleases *AffectedReleases, helm helme
|
|||
|
||||
preps, prepErrs := st.prepareSyncReleases(helm, additionalValues, workerLimit, opts)
|
||||
|
||||
defer func() {
|
||||
if opts.SkipCleanup {
|
||||
return
|
||||
}
|
||||
|
||||
for _, p := range preps {
|
||||
st.removeFiles(p.files)
|
||||
}
|
||||
}()
|
||||
if !opts.SkipCleanup {
|
||||
defer func() {
|
||||
for _, p := range preps {
|
||||
st.removeFiles(p.files)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if len(prepErrs) > 0 {
|
||||
return prepErrs
|
||||
|
|
@ -1339,13 +1337,9 @@ func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string,
|
|||
|
||||
flags, files, err := st.flagsForTemplate(helm, release, 0)
|
||||
|
||||
defer func() {
|
||||
if opts.SkipCleanup {
|
||||
return
|
||||
}
|
||||
|
||||
st.removeFiles(files)
|
||||
}()
|
||||
if !opts.SkipCleanup {
|
||||
defer st.removeFiles(files)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
|
|
@ -1412,6 +1406,7 @@ func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string,
|
|||
type WriteValuesOpts struct {
|
||||
Set []string
|
||||
OutputFileTemplate string
|
||||
SkipCleanup bool
|
||||
}
|
||||
|
||||
type WriteValuesOpt interface{ Apply(*WriteValuesOpts) }
|
||||
|
|
@ -1441,9 +1436,9 @@ func (st *HelmState) WriteReleasesValues(helm helmexec.Interface, additionalValu
|
|||
return []error{err}
|
||||
}
|
||||
|
||||
defer func() {
|
||||
st.removeFiles(generatedFiles)
|
||||
}()
|
||||
if !opts.SkipCleanup {
|
||||
defer st.removeFiles(generatedFiles)
|
||||
}
|
||||
|
||||
for _, value := range additionalValues {
|
||||
valfile, err := filepath.Abs(value)
|
||||
|
|
@ -1506,7 +1501,8 @@ func (st *HelmState) WriteReleasesValues(helm helmexec.Interface, additionalValu
|
|||
}
|
||||
|
||||
type LintOpts struct {
|
||||
Set []string
|
||||
Set []string
|
||||
SkipCleanup bool
|
||||
}
|
||||
|
||||
type LintOpt interface{ Apply(*LintOpts) }
|
||||
|
|
@ -1540,7 +1536,9 @@ func (st *HelmState) LintReleases(helm helmexec.Interface, additionalValues []st
|
|||
|
||||
flags, files, err := st.flagsForLint(helm, &release, 0)
|
||||
|
||||
defer st.removeFiles(files)
|
||||
if !opts.SkipCleanup {
|
||||
defer st.removeFiles(files)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
|
|
@ -1625,7 +1623,7 @@ func (st *HelmState) prepareDiffReleases(helm helmexec.Interface, additionalValu
|
|||
}
|
||||
|
||||
releases := []*ReleaseSpec{}
|
||||
for i, _ := range st.Releases {
|
||||
for i := range st.Releases {
|
||||
if !st.Releases[i].Desired() {
|
||||
continue
|
||||
}
|
||||
|
|
@ -1790,13 +1788,11 @@ func (st *HelmState) createHelmContextWithWriter(spec *ReleaseSpec, w io.Writer)
|
|||
}
|
||||
|
||||
type DiffOpts struct {
|
||||
Context int
|
||||
Output string
|
||||
NoColor bool
|
||||
Set []string
|
||||
|
||||
SkipCleanup bool
|
||||
|
||||
Context int
|
||||
Output string
|
||||
NoColor bool
|
||||
Set []string
|
||||
SkipCleanup bool
|
||||
SkipDiffOnInstall bool
|
||||
}
|
||||
|
||||
|
|
@ -1822,15 +1818,13 @@ func (st *HelmState) DiffReleases(helm helmexec.Interface, additionalValues []st
|
|||
|
||||
preps, prepErrs := st.prepareDiffReleases(helm, additionalValues, workerLimit, detailedExitCode, includeTests, suppressSecrets, showSecrets, opts)
|
||||
|
||||
defer func() {
|
||||
if opts.SkipCleanup {
|
||||
return
|
||||
}
|
||||
|
||||
for _, p := range preps {
|
||||
st.removeFiles(p.files)
|
||||
}
|
||||
}()
|
||||
if !opts.SkipCleanup {
|
||||
defer func() {
|
||||
for _, p := range preps {
|
||||
st.removeFiles(p.files)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if len(prepErrs) > 0 {
|
||||
return []ReleaseSpec{}, prepErrs
|
||||
|
|
|
|||
Loading…
Reference in New Issue