Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it: closes #12414
According to Hooks and the Release Lifecycle, hooks are sorted "by weight (assigning a weight of 0 by default), by resource kind and finally by name in ascending order". In practice, the current behavior is that hooks are sorted by
(Weight, Name)
.The code currently uses
sort.Stable
under the assumption that the hooks are already sorted by Kind. However, stability only applies to elements with the same key, so sinceLess
on thehookByWeight
comparator orders based on the name of the hook too, the existing ordering by Kind is never respected.This PR fixes the comparator so that hooks are sorted by
(Weight, Kind, Name)
as expected and adds tests for this behavior.Special notes for your reviewer:
If applicable: