diff --git a/test/infrastructure/docker/exp/internal/webhooks/doc.go b/test/infrastructure/docker/exp/internal/webhooks/doc.go new file mode 100644 index 000000000000..7732f4d31b5f --- /dev/null +++ b/test/infrastructure/docker/exp/internal/webhooks/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2023 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 webhooks implements docker infrastructure exp webhooks. +package webhooks diff --git a/test/infrastructure/docker/exp/api/v1beta1/dockermachinepool_webhook.go b/test/infrastructure/docker/exp/internal/webhooks/dockermachinepool_webhook.go similarity index 74% rename from test/infrastructure/docker/exp/api/v1beta1/dockermachinepool_webhook.go rename to test/infrastructure/docker/exp/internal/webhooks/dockermachinepool_webhook.go index a6ffc3bbdaf1..0f5a674fb8c6 100644 --- a/test/infrastructure/docker/exp/api/v1beta1/dockermachinepool_webhook.go +++ b/test/infrastructure/docker/exp/internal/webhooks/dockermachinepool_webhook.go @@ -14,14 +14,19 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package webhooks import ( ctrl "sigs.k8s.io/controller-runtime" + + infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1" ) +// DockerMachinePool implements a validating and defaulting webhook for DockerMachinePool. +type DockerMachinePool struct{} + func (c *DockerMachinePool) SetupWebhookWithManager(mgr ctrl.Manager) error { return ctrl.NewWebhookManagedBy(mgr). - For(c). + For(&infraexpv1.DockerMachinePool{}). Complete() } diff --git a/test/infrastructure/docker/exp/webhooks/alias.go b/test/infrastructure/docker/exp/webhooks/alias.go new file mode 100644 index 000000000000..88f6e9ad980c --- /dev/null +++ b/test/infrastructure/docker/exp/webhooks/alias.go @@ -0,0 +1,31 @@ +/* +Copyright 2023 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 webhooks + +import ( + ctrl "sigs.k8s.io/controller-runtime" + + "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/internal/webhooks" +) + +// DockerMachinePool implements a validating and defaulting webhook for DockerMachinePool. +type DockerMachinePool struct{} + +// SetupWebhookWithManager sets up DockerMachinePool webhooks. +func (webhook *DockerMachinePool) SetupWebhookWithManager(mgr ctrl.Manager) error { + return (&webhooks.DockerMachinePool{}).SetupWebhookWithManager(mgr) +} diff --git a/test/infrastructure/docker/exp/webhooks/doc.go b/test/infrastructure/docker/exp/webhooks/doc.go new file mode 100644 index 000000000000..a24820761de0 --- /dev/null +++ b/test/infrastructure/docker/exp/webhooks/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2023 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 webhooks contains docker infrastructure experimental webhook implementations for some of our API types. +package webhooks diff --git a/test/infrastructure/docker/main.go b/test/infrastructure/docker/main.go index 526a39387d26..15b0ca43b70d 100644 --- a/test/infrastructure/docker/main.go +++ b/test/infrastructure/docker/main.go @@ -55,6 +55,7 @@ import ( infraexpv1alpha4 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1alpha4" infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1" expcontrollers "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/controllers" + "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/webhooks" "sigs.k8s.io/cluster-api/util/flags" "sigs.k8s.io/cluster-api/version" ) @@ -377,7 +378,7 @@ func setupWebhooks(mgr ctrl.Manager) { } if feature.Gates.Enabled(feature.MachinePool) { - if err := (&infraexpv1.DockerMachinePool{}).SetupWebhookWithManager(mgr); err != nil { + if err := (&webhooks.DockerMachinePool{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "DockerMachinePool") os.Exit(1) }