From 74b45392fc1194e6003a1f1ab97dae96fb85a76d Mon Sep 17 00:00:00 2001 From: Asad Ali Date: Mon, 11 May 2020 13:08:07 -0700 Subject: [PATCH] Relative Order of Mutating/Validating WebhookConfigs MutatingWebhookConfig may have similar dependencies as the ValidatingWebhookConfig. eg. a k8s cluster service. Therefore, it should be ordered last as well. This PR preserves the implicit ordering between CustomResources and the webhook while introducing a relative order between the two webhooks. i.e. MutatingWebhook should be created prior to the ValidatingWebhook The change is an enhancement of #1104 --- api/resid/gvk.go | 2 +- api/resid/gvk_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/resid/gvk.go b/api/resid/gvk.go index 534fcc644..64d0a0749 100644 --- a/api/resid/gvk.go +++ b/api/resid/gvk.go @@ -84,7 +84,6 @@ var orderFirst = []string{ "ResourceQuota", "StorageClass", "CustomResourceDefinition", - "MutatingWebhookConfiguration", "ServiceAccount", "PodSecurityPolicy", "Role", @@ -102,6 +101,7 @@ var orderFirst = []string{ "PodDisruptionBudget", } var orderLast = []string{ + "MutatingWebhookConfiguration", "ValidatingWebhookConfiguration", } var typeOrders = func() map[string]int { diff --git a/api/resid/gvk_test.go b/api/resid/gvk_test.go index 8957ae53a..440109d9e 100644 --- a/api/resid/gvk_test.go +++ b/api/resid/gvk_test.go @@ -68,6 +68,10 @@ var lessThanTests = []struct { Gvk{Group: "a", Version: "b", Kind: orderLast[0]}}, {Gvk{Group: "a", Version: "b", Kind: "CustomKindA"}, Gvk{Group: "a", Version: "b", Kind: "CustomKindB"}}, + {Gvk{Group: "a", Version: "b", Kind: "CustomKindX"}, + Gvk{Group: "a", Version: "b", Kind: "MutatingWebhookConfiguration"}}, + {Gvk{Group: "a", Version: "b", Kind: "MutatingWebhookConfiguration"}, + Gvk{Group: "a", Version: "b", Kind: "ValidatingWebhookConfiguration"}}, {Gvk{Group: "a", Version: "b", Kind: "CustomKindX"}, Gvk{Group: "a", Version: "b", Kind: "ValidatingWebhookConfiguration"}}, {Gvk{Group: "a", Version: "b", Kind: "APIService"},