fix: cleanup hook executed too early for apply command (#426)
fixes https://github.com/roboll/helmfile/issues/412 the `apply` command first runs the `diff` command, which triggers the execution of the `cleanup` hooks at the end of the `diff`.
This commit is contained in:
parent
1f7a8ddbe3
commit
fea62032e9
3
main.go
3
main.go
|
|
@ -548,8 +548,9 @@ func executeDiffCommand(c *cli.Context, st *state.HelmState, helm helmexec.Inter
|
||||||
|
|
||||||
values := c.StringSlice("values")
|
values := c.StringSlice("values")
|
||||||
workers := c.Int("concurrency")
|
workers := c.Int("concurrency")
|
||||||
|
triggerCleanupEvents := c.Command.HasName("diff")
|
||||||
|
|
||||||
return st.DiffReleases(helm, values, workers, detailedExitCode, suppressSecrets)
|
return st.DiffReleases(helm, values, workers, detailedExitCode, suppressSecrets, triggerCleanupEvents)
|
||||||
}
|
}
|
||||||
|
|
||||||
type app struct {
|
type app struct {
|
||||||
|
|
|
||||||
|
|
@ -644,7 +644,7 @@ func (state *HelmState) prepareDiffReleases(helm helmexec.Interface, additionalV
|
||||||
|
|
||||||
// DiffReleases wrapper for executing helm diff on the releases
|
// DiffReleases wrapper for executing helm diff on the releases
|
||||||
// It returns releases that had any changes
|
// It returns releases that had any changes
|
||||||
func (state *HelmState) DiffReleases(helm helmexec.Interface, additionalValues []string, workerLimit int, detailedExitCode, suppressSecrets bool) ([]*ReleaseSpec, []error) {
|
func (state *HelmState) DiffReleases(helm helmexec.Interface, additionalValues []string, workerLimit int, detailedExitCode, suppressSecrets bool, triggerCleanupEvents bool) ([]*ReleaseSpec, []error) {
|
||||||
preps, prepErrs := state.prepareDiffReleases(helm, additionalValues, workerLimit, detailedExitCode, suppressSecrets)
|
preps, prepErrs := state.prepareDiffReleases(helm, additionalValues, workerLimit, detailedExitCode, suppressSecrets)
|
||||||
if len(prepErrs) > 0 {
|
if len(prepErrs) > 0 {
|
||||||
return []*ReleaseSpec{}, prepErrs
|
return []*ReleaseSpec{}, prepErrs
|
||||||
|
|
@ -682,8 +682,10 @@ func (state *HelmState) DiffReleases(helm helmexec.Interface, additionalValues [
|
||||||
results <- diffResult{}
|
results <- diffResult{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := state.triggerCleanupEvent(prep.release, "diff"); err != nil {
|
if triggerCleanupEvents {
|
||||||
state.logger.Warnf("warn: %v\n", err)
|
if _, err := state.triggerCleanupEvent(prep.release, "diff"); err != nil {
|
||||||
|
state.logger.Warnf("warn: %v\n", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
waitGroup.Done()
|
waitGroup.Done()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue