diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 57c5157e7012..dc6e7c20c0da 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -55,20 +55,20 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-cluster-x-k8s-io-v1beta2-machine + path: /mutate-runtime-cluster-x-k8s-io-v1beta2-extensionconfig failurePolicy: Fail matchPolicy: Equivalent - name: default.machine.cluster.x-k8s.io + name: default.extensionconfig.runtime.addons.cluster.x-k8s.io rules: - apiGroups: - - cluster.x-k8s.io + - runtime.cluster.x-k8s.io apiVersions: - v1beta2 operations: - CREATE - UPDATE resources: - - machines + - extensionconfigs sideEffects: None - admissionReviewVersions: - v1 @@ -77,10 +77,10 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-cluster-x-k8s-io-v1beta2-machinedeployment + path: /mutate-cluster-x-k8s-io-v1beta2-machine failurePolicy: Fail matchPolicy: Equivalent - name: default.machinedeployment.cluster.x-k8s.io + name: default.machine.cluster.x-k8s.io rules: - apiGroups: - cluster.x-k8s.io @@ -90,7 +90,7 @@ webhooks: - CREATE - UPDATE resources: - - machinedeployments + - machines sideEffects: None - admissionReviewVersions: - v1 @@ -99,10 +99,10 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-cluster-x-k8s-io-v1beta2-machinehealthcheck + path: /mutate-cluster-x-k8s-io-v1beta2-machinedeployment failurePolicy: Fail matchPolicy: Equivalent - name: default.machinehealthcheck.cluster.x-k8s.io + name: default.machinedeployment.cluster.x-k8s.io rules: - apiGroups: - cluster.x-k8s.io @@ -112,7 +112,7 @@ webhooks: - CREATE - UPDATE resources: - - machinehealthchecks + - machinedeployments sideEffects: None - admissionReviewVersions: - v1 @@ -121,10 +121,10 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-cluster-x-k8s-io-v1beta2-machinepool + path: /mutate-cluster-x-k8s-io-v1beta2-machinehealthcheck failurePolicy: Fail matchPolicy: Equivalent - name: default.machinepool.cluster.x-k8s.io + name: default.machinehealthcheck.cluster.x-k8s.io rules: - apiGroups: - cluster.x-k8s.io @@ -134,7 +134,7 @@ webhooks: - CREATE - UPDATE resources: - - machinepools + - machinehealthchecks sideEffects: None - admissionReviewVersions: - v1 @@ -143,10 +143,10 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-cluster-x-k8s-io-v1beta2-machineset + path: /mutate-cluster-x-k8s-io-v1beta2-machinepool failurePolicy: Fail matchPolicy: Equivalent - name: default.machineset.cluster.x-k8s.io + name: default.machinepool.cluster.x-k8s.io rules: - apiGroups: - cluster.x-k8s.io @@ -156,7 +156,7 @@ webhooks: - CREATE - UPDATE resources: - - machinesets + - machinepools sideEffects: None - admissionReviewVersions: - v1 @@ -165,20 +165,20 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-runtime-cluster-x-k8s-io-v1beta2-extensionconfig + path: /mutate-cluster-x-k8s-io-v1beta2-machineset failurePolicy: Fail matchPolicy: Equivalent - name: default.extensionconfig.runtime.addons.cluster.x-k8s.io + name: default.machineset.cluster.x-k8s.io rules: - apiGroups: - - runtime.cluster.x-k8s.io + - cluster.x-k8s.io apiVersions: - v1beta2 operations: - CREATE - UPDATE resources: - - extensionconfigs + - machinesets sideEffects: None --- apiVersion: admissionregistration.k8s.io/v1 @@ -276,6 +276,28 @@ webhooks: resources: - clusterresourcesetbindings sideEffects: None +- admissionReviewVersions: + - v1 + - v1beta1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-runtime-cluster-x-k8s-io-v1beta2-extensionconfig + failurePolicy: Fail + matchPolicy: Equivalent + name: validation.extensionconfig.runtime.cluster.x-k8s.io + rules: + - apiGroups: + - runtime.cluster.x-k8s.io + apiVersions: + - v1beta2 + operations: + - CREATE + - UPDATE + resources: + - extensionconfigs + sideEffects: None - admissionReviewVersions: - v1 - v1beta1 @@ -454,25 +476,3 @@ webhooks: resources: - machinesets sideEffects: None -- admissionReviewVersions: - - v1 - - v1beta1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /validate-runtime-cluster-x-k8s-io-v1beta2-extensionconfig - failurePolicy: Fail - matchPolicy: Equivalent - name: validation.extensionconfig.runtime.cluster.x-k8s.io - rules: - - apiGroups: - - runtime.cluster.x-k8s.io - apiVersions: - - v1beta2 - operations: - - CREATE - - UPDATE - resources: - - extensionconfigs - sideEffects: None diff --git a/controlplane/kubeadm/internal/webhooks/kubeadm_control_plane.go b/controlplane/kubeadm/internal/webhooks/kubeadmcontrolplane.go similarity index 100% rename from controlplane/kubeadm/internal/webhooks/kubeadm_control_plane.go rename to controlplane/kubeadm/internal/webhooks/kubeadmcontrolplane.go diff --git a/controlplane/kubeadm/internal/webhooks/kubeadm_control_plane_test.go b/controlplane/kubeadm/internal/webhooks/kubeadmcontrolplane_test.go similarity index 100% rename from controlplane/kubeadm/internal/webhooks/kubeadm_control_plane_test.go rename to controlplane/kubeadm/internal/webhooks/kubeadmcontrolplane_test.go diff --git a/internal/webhooks/clusterresourceset_webhook.go b/internal/webhooks/clusterresourceset.go similarity index 100% rename from internal/webhooks/clusterresourceset_webhook.go rename to internal/webhooks/clusterresourceset.go diff --git a/internal/webhooks/clusterresourceset_webhook_test.go b/internal/webhooks/clusterresourceset_test.go similarity index 100% rename from internal/webhooks/clusterresourceset_webhook_test.go rename to internal/webhooks/clusterresourceset_test.go diff --git a/internal/webhooks/clusterresourcesetbinding_webhook.go b/internal/webhooks/clusterresourcesetbinding.go similarity index 100% rename from internal/webhooks/clusterresourcesetbinding_webhook.go rename to internal/webhooks/clusterresourcesetbinding.go diff --git a/internal/webhooks/clusterresourcesetbinding_webhook_test.go b/internal/webhooks/clusterresourcesetbinding_test.go similarity index 100% rename from internal/webhooks/clusterresourcesetbinding_webhook_test.go rename to internal/webhooks/clusterresourcesetbinding_test.go diff --git a/internal/webhooks/runtime/extensionconfig_webhook.go b/internal/webhooks/extensionconfig.go similarity index 99% rename from internal/webhooks/runtime/extensionconfig_webhook.go rename to internal/webhooks/extensionconfig.go index 33c030ff6a05..ac8390de88e5 100644 --- a/internal/webhooks/runtime/extensionconfig_webhook.go +++ b/internal/webhooks/extensionconfig.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package runtime +package webhooks import ( "context" diff --git a/internal/webhooks/runtime/extensionconfig_webhook_test.go b/internal/webhooks/extensionconfig_test.go similarity index 98% rename from internal/webhooks/runtime/extensionconfig_webhook_test.go rename to internal/webhooks/extensionconfig_test.go index e255fbbe3000..53f58d10f44d 100644 --- a/internal/webhooks/runtime/extensionconfig_webhook_test.go +++ b/internal/webhooks/extensionconfig_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package runtime +package webhooks import ( "context" @@ -22,21 +22,14 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" utilfeature "k8s.io/component-base/featuregate/testing" "k8s.io/utils/ptr" - ctrl "sigs.k8s.io/controller-runtime" runtimev1 "sigs.k8s.io/cluster-api/api/runtime/v1beta2" "sigs.k8s.io/cluster-api/feature" "sigs.k8s.io/cluster-api/internal/webhooks/util" ) -var ( - ctx = ctrl.SetupSignalHandler() - fakeScheme = runtime.NewScheme() -) - func init() { _ = runtimev1.AddToScheme(fakeScheme) } diff --git a/internal/webhooks/runtime/doc.go b/internal/webhooks/runtime/doc.go deleted file mode 100644 index 6bf9f066c8ef..000000000000 --- a/internal/webhooks/runtime/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2022 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package runtime contains the webhook implementation for runtime ExtensionConfig. -package runtime diff --git a/test/infrastructure/docker/internal/webhooks/devcluster_webhook.go b/test/infrastructure/docker/internal/webhooks/devcluster.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/devcluster_webhook.go rename to test/infrastructure/docker/internal/webhooks/devcluster.go diff --git a/test/infrastructure/docker/internal/webhooks/devclustertemplate_webhook.go b/test/infrastructure/docker/internal/webhooks/devclustertemplate.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/devclustertemplate_webhook.go rename to test/infrastructure/docker/internal/webhooks/devclustertemplate.go diff --git a/test/infrastructure/docker/internal/webhooks/devclustertemplate_webhook_test.go b/test/infrastructure/docker/internal/webhooks/devclustertemplate_test.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/devclustertemplate_webhook_test.go rename to test/infrastructure/docker/internal/webhooks/devclustertemplate_test.go diff --git a/test/infrastructure/docker/internal/webhooks/devmachine_webhook.go b/test/infrastructure/docker/internal/webhooks/devmachine.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/devmachine_webhook.go rename to test/infrastructure/docker/internal/webhooks/devmachine.go diff --git a/test/infrastructure/docker/internal/webhooks/devmachinetemplate_webhook.go b/test/infrastructure/docker/internal/webhooks/devmachinetemplate.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/devmachinetemplate_webhook.go rename to test/infrastructure/docker/internal/webhooks/devmachinetemplate.go diff --git a/test/infrastructure/docker/internal/webhooks/devmachinetemplate_webhook_test.go b/test/infrastructure/docker/internal/webhooks/devmachinetemplate_test.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/devmachinetemplate_webhook_test.go rename to test/infrastructure/docker/internal/webhooks/devmachinetemplate_test.go diff --git a/test/infrastructure/docker/internal/webhooks/dockercluster_webhook.go b/test/infrastructure/docker/internal/webhooks/dockercluster.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/dockercluster_webhook.go rename to test/infrastructure/docker/internal/webhooks/dockercluster.go diff --git a/test/infrastructure/docker/internal/webhooks/dockerclustertemplate_webhook.go b/test/infrastructure/docker/internal/webhooks/dockerclustertemplate.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/dockerclustertemplate_webhook.go rename to test/infrastructure/docker/internal/webhooks/dockerclustertemplate.go diff --git a/test/infrastructure/docker/internal/webhooks/dockerclustertemplate_webhook_test.go b/test/infrastructure/docker/internal/webhooks/dockerclustertemplate_test.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/dockerclustertemplate_webhook_test.go rename to test/infrastructure/docker/internal/webhooks/dockerclustertemplate_test.go diff --git a/test/infrastructure/docker/internal/webhooks/dockermachinepool_webhook.go b/test/infrastructure/docker/internal/webhooks/dockermachinepool.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/dockermachinepool_webhook.go rename to test/infrastructure/docker/internal/webhooks/dockermachinepool.go diff --git a/test/infrastructure/docker/internal/webhooks/dockermachinetemplate_webhook.go b/test/infrastructure/docker/internal/webhooks/dockermachinetemplate.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/dockermachinetemplate_webhook.go rename to test/infrastructure/docker/internal/webhooks/dockermachinetemplate.go diff --git a/test/infrastructure/docker/internal/webhooks/dockermachinetemplate_webhook_test.go b/test/infrastructure/docker/internal/webhooks/dockermachinetemplate_test.go similarity index 100% rename from test/infrastructure/docker/internal/webhooks/dockermachinetemplate_webhook_test.go rename to test/infrastructure/docker/internal/webhooks/dockermachinetemplate_test.go diff --git a/webhooks/alias.go b/webhooks/alias.go index 5c6567fe0fde..ff08aaac98dc 100644 --- a/webhooks/alias.go +++ b/webhooks/alias.go @@ -25,7 +25,6 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" "sigs.k8s.io/cluster-api/internal/webhooks" - runtimewebhooks "sigs.k8s.io/cluster-api/internal/webhooks/runtime" ) // Cluster implements a validating and defaulting webhook for Cluster. @@ -132,7 +131,7 @@ type ExtensionConfig struct{} // SetupWebhookWithManager sets up ClusterResourceSet webhooks. func (webhook *ExtensionConfig) SetupWebhookWithManager(mgr ctrl.Manager) error { - return (&runtimewebhooks.ExtensionConfig{}).SetupWebhookWithManager(mgr) + return (&webhooks.ExtensionConfig{}).SetupWebhookWithManager(mgr) } // MachinePool implements a validating and defaulting webhook for MachinePool.