|
|
@ -17,11 +17,9 @@ package action
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"bytes"
|
|
|
|
"sort"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/release"
|
|
|
|
"helm.sh/helm/v3/pkg/release"
|
|
|
|
helmtime "helm.sh/helm/v3/pkg/time"
|
|
|
|
helmtime "helm.sh/helm/v3/pkg/time"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -38,9 +36,6 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// hooke are pre-ordered by kind, so keep order stable
|
|
|
|
|
|
|
|
sort.Stable(hookByWeight(executingHooks))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, h := range executingHooks {
|
|
|
|
for _, h := range executingHooks {
|
|
|
|
// Set default delete policy to before-hook-creation
|
|
|
|
// Set default delete policy to before-hook-creation
|
|
|
|
if h.DeletePolicies == nil || len(h.DeletePolicies) == 0 {
|
|
|
|
if h.DeletePolicies == nil || len(h.DeletePolicies) == 0 {
|
|
|
@ -107,18 +102,6 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent,
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// hookByWeight is a sorter for hooks
|
|
|
|
|
|
|
|
type hookByWeight []*release.Hook
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (x hookByWeight) Len() int { return len(x) }
|
|
|
|
|
|
|
|
func (x hookByWeight) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
|
|
|
|
|
|
|
|
func (x hookByWeight) Less(i, j int) bool {
|
|
|
|
|
|
|
|
if x[i].Weight == x[j].Weight {
|
|
|
|
|
|
|
|
return x[i].Name < x[j].Name
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return x[i].Weight < x[j].Weight
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// deleteHookByPolicy deletes a hook if the hook policy instructs it to
|
|
|
|
// deleteHookByPolicy deletes a hook if the hook policy instructs it to
|
|
|
|
func (cfg *Configuration) deleteHookByPolicy(h *release.Hook, policy release.HookDeletePolicy) error {
|
|
|
|
func (cfg *Configuration) deleteHookByPolicy(h *release.Hook, policy release.HookDeletePolicy) error {
|
|
|
|
// Never delete CustomResourceDefinitions; this could cause lots of
|
|
|
|
// Never delete CustomResourceDefinitions; this could cause lots of
|
|
|
|