From 0d54671263f8cbfabaff4ad51507ce1a577ca0e1 Mon Sep 17 00:00:00 2001 From: Roberto Santalla Date: Fri, 11 Mar 2022 16:52:51 +0100 Subject: [PATCH] action/hooks: remove hook sorting, as they already come sorted from earlier Co-authored-by: Alvaro Cabanas Co-authored-by: Paolo Gallina Signed-off-by: Roberto Santalla --- pkg/action/hooks.go | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index 40c1ffdb6..fde37b825 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -17,11 +17,9 @@ package action import ( "bytes" - "sort" "time" "github.com/pkg/errors" - "helm.sh/helm/v3/pkg/release" 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 { // Set default delete policy to before-hook-creation if h.DeletePolicies == nil || len(h.DeletePolicies) == 0 { @@ -107,18 +102,6 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, 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 func (cfg *Configuration) deleteHookByPolicy(h *release.Hook, policy release.HookDeletePolicy) error { // Never delete CustomResourceDefinitions; this could cause lots of