Hooks with the same Weight but different Kind should not be compared by Name

Signed-off-by: Samir Shetty <samirshetty23@gmail.com>
pull/10007/head
Samir Shetty 4 years ago
parent efe2638f87
commit acb7699c65

@ -38,7 +38,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent,
} }
} }
// hooke are pre-ordered by kind, so keep order stable // hooks are pre-ordered by kind, so keep order stable
sort.Stable(hookByWeight(executingHooks)) sort.Stable(hookByWeight(executingHooks))
for _, h := range executingHooks { for _, h := range executingHooks {
@ -113,7 +113,7 @@ type hookByWeight []*release.Hook
func (x hookByWeight) Len() int { return len(x) } 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) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
func (x hookByWeight) Less(i, j int) bool { func (x hookByWeight) Less(i, j int) bool {
if x[i].Weight == x[j].Weight { if x[i].Weight == x[j].Weight && x[i].Kind == x[j].Kind {
return x[i].Name < x[j].Name return x[i].Name < x[j].Name
} }
return x[i].Weight < x[j].Weight return x[i].Weight < x[j].Weight

Loading…
Cancel
Save