Skip to content

Commit 4376e6e

Browse files
authored
Merge pull request #179 from mengqiy/sort_webhooks
sort webhooks
2 parents 97df191 + a468398 commit 4376e6e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/webhook/bootstrap.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"net/http"
2424
"net/url"
2525
"path"
26+
"sort"
2627
"strconv"
2728

2829
"k8s.io/api/admissionregistration/v1beta1"
@@ -237,6 +238,10 @@ func (s *Server) mutatingWHConfigs() (runtime.Object, error) {
237238
mutatingWebhooks = append(mutatingWebhooks, *wh)
238239
}
239240

241+
sort.Slice(mutatingWebhooks, func(i, j int) bool {
242+
return mutatingWebhooks[i].Name < mutatingWebhooks[j].Name
243+
})
244+
240245
if len(mutatingWebhooks) > 0 {
241246
return &admissionregistration.MutatingWebhookConfiguration{
242247
TypeMeta: metav1.TypeMeta{
@@ -268,6 +273,10 @@ func (s *Server) validatingWHConfigs() (runtime.Object, error) {
268273
validatingWebhooks = append(validatingWebhooks, *wh)
269274
}
270275

276+
sort.Slice(validatingWebhooks, func(i, j int) bool {
277+
return validatingWebhooks[i].Name < validatingWebhooks[j].Name
278+
})
279+
271280
if len(validatingWebhooks) > 0 {
272281
return &admissionregistration.ValidatingWebhookConfiguration{
273282
TypeMeta: metav1.TypeMeta{

0 commit comments

Comments
 (0)