Move preapply code to separate function

Signed-off-by: Anton Bretting <sajfer@gmail.com>
This commit is contained in:
Anton Bretting 2022-06-12 11:54:31 +02:00 committed by Yusuke Kuoka
parent ca7942c751
commit ea56061609
1 changed files with 3 additions and 22 deletions

View File

@ -790,7 +790,7 @@ func (a *App) visitStates(fileOrDir string, defOpts LoadOpts, converge func(*sta
go func() { go func() {
sig := <-sigs sig := <-sigs
errs := []error{fmt.Errorf("Received [%s] to shutdown ", sig)} errs := []error{fmt.Errorf("received [%s] to shutdown ", sig)}
_ = context{app: a, st: st, retainValues: defOpts.RetainValuesFiles}.clean(errs) _ = context{app: a, st: st, retainValues: defOpts.RetainValuesFiles}.clean(errs)
// See http://tldp.org/LDP/abs/html/exitcodes.html // See http://tldp.org/LDP/abs/html/exitcodes.html
switch sig { switch sig {
@ -1323,28 +1323,9 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
} }
} }
var releasesWithPreApply []state.ReleaseSpec releasesWithPreApply := getReleasesWithPreApply(toApplyWithNeeds)
for _, r := range toApplyWithNeeds {
release := r
for _, hook := range release.Hooks {
if slices.Contains(hook.Events, "preapply") {
releasesWithPreApply = append(releasesWithPreApply, release)
break
}
}
}
if len(releasesWithPreApply) > 0 { infoMsg = preApplyInfoMsg(releasesWithPreApply, infoMsg)
msg := "Releases with preapply hooks: \n"
if infoMsg != nil {
msg = fmt.Sprintf("%s%s", *infoMsg, msg)
}
infoMsg = &msg
}
for _, release := range releasesWithPreApply {
tmp := fmt.Sprintf("%s %s (%s)", *infoMsg, release.Name, release.Chart)
infoMsg = &tmp
}
if releasesToBeDeleted == nil && releasesToBeUpdated == nil && releasesWithPreApply == nil { if releasesToBeDeleted == nil && releasesToBeUpdated == nil && releasesWithPreApply == nil {
if infoMsg != nil { if infoMsg != nil {