diff --git a/main.go b/main.go index b4fe04d020..63944118a0 100644 --- a/main.go +++ b/main.go @@ -59,12 +59,12 @@ import ( "sigs.k8s.io/cluster-api-provider-vsphere/controllers" "sigs.k8s.io/cluster-api-provider-vsphere/controllers/vmware" "sigs.k8s.io/cluster-api-provider-vsphere/feature" - "sigs.k8s.io/cluster-api-provider-vsphere/internal/webhooks" - vmwarewebhooks "sigs.k8s.io/cluster-api-provider-vsphere/internal/webhooks/vmware" capvcontext "sigs.k8s.io/cluster-api-provider-vsphere/pkg/context" "sigs.k8s.io/cluster-api-provider-vsphere/pkg/manager" "sigs.k8s.io/cluster-api-provider-vsphere/pkg/session" "sigs.k8s.io/cluster-api-provider-vsphere/pkg/version" + "sigs.k8s.io/cluster-api-provider-vsphere/webhooks" + vmwarewebhooks "sigs.k8s.io/cluster-api-provider-vsphere/webhooks/vmware" ) var ( diff --git a/webhooks/alias.go b/webhooks/alias.go new file mode 100644 index 0000000000..eaa8a49c9f --- /dev/null +++ b/webhooks/alias.go @@ -0,0 +1,71 @@ +/* +Copyright 2025 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-provider-vsphere/internal/webhooks" +) + +// VSphereClusterTemplateWebhook implements a validation and defaulting webhook for VSphereClusterTemplate. +type VSphereClusterTemplateWebhook struct{} + +// SetupWebhookWithManager sets up VSphereClusterTemplate webhooks. +func (webhook *VSphereClusterTemplateWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { + return (&webhooks.VSphereClusterTemplateWebhook{}).SetupWebhookWithManager(mgr) +} + +// VSphereDeploymentZoneWebhook implements a validation and defaulting webhook for VSphereDeploymentZone. +type VSphereDeploymentZoneWebhook struct{} + +// SetupWebhookWithManager sets up VSphereDeploymentZone webhooks. +func (webhook *VSphereDeploymentZoneWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { + return (&webhooks.VSphereDeploymentZoneWebhook{}).SetupWebhookWithManager(mgr) +} + +// VSphereFailureDomainWebhook implements a validation and defaulting webhook for VSphereFailureDomain. +type VSphereFailureDomainWebhook struct{} + +// SetupWebhookWithManager sets up VSphereFailureDomain webhooks. +func (webhook *VSphereFailureDomainWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { + return (&webhooks.VSphereFailureDomainWebhook{}).SetupWebhookWithManager(mgr) +} + +// VSphereMachineWebhook implements a validation and defaulting webhook for VSphereMachine. +type VSphereMachineWebhook struct{} + +// SetupWebhookWithManager sets up VSphereMachine webhooks. +func (webhook *VSphereMachineWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { + return (&webhooks.VSphereMachineWebhook{}).SetupWebhookWithManager(mgr) +} + +// VSphereMachineTemplateWebhook implements a validation and defaulting webhook for VSphereMachineTemplate. +type VSphereMachineTemplateWebhook struct{} + +// SetupWebhookWithManager sets up VSphereMachineTemplate webhooks. +func (webhook *VSphereMachineTemplateWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { + return (&webhooks.VSphereMachineTemplateWebhook{}).SetupWebhookWithManager(mgr) +} + +// VSphereVMWebhook implements a validation and defaulting webhook for VSphereVM. +type VSphereVMWebhook struct{} + +// SetupWebhookWithManager sets up VSphereVM webhooks. +func (webhook *VSphereVMWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { + return (&webhooks.VSphereVMWebhook{}).SetupWebhookWithManager(mgr) +} diff --git a/webhooks/doc.go b/webhooks/doc.go new file mode 100644 index 0000000000..d5942d4d10 --- /dev/null +++ b/webhooks/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2025 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 webhooks for the infrastructure v1beta1 API group. +package webhooks diff --git a/webhooks/vmware/alias.go b/webhooks/vmware/alias.go new file mode 100644 index 0000000000..5ff7b0f8f9 --- /dev/null +++ b/webhooks/vmware/alias.go @@ -0,0 +1,39 @@ +/* +Copyright 2025 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 vmware + +import ( + ctrl "sigs.k8s.io/controller-runtime" + + "sigs.k8s.io/cluster-api-provider-vsphere/internal/webhooks/vmware" +) + +// VSphereMachineWebhook implements a validation and defaulting webhook for VSphereMachine. +type VSphereMachineWebhook struct{} + +// SetupWebhookWithManager sets up VSphereMachine webhooks. +func (webhook *VSphereMachineWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { + return (&vmware.VSphereMachineWebhook{}).SetupWebhookWithManager(mgr) +} + +// VSphereMachineTemplateWebhook implements a validation and defaulting webhook for VSphereMachineTemplate. +type VSphereMachineTemplateWebhook struct{} + +// SetupWebhookWithManager sets up VSphereMachineTemplate webhooks. +func (webhook *VSphereMachineTemplateWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { + return (&vmware.VSphereMachineTemplateWebhook{}).SetupWebhookWithManager(mgr) +} diff --git a/webhooks/vmware/doc.go b/webhooks/vmware/doc.go new file mode 100644 index 0000000000..db4a42b4e4 --- /dev/null +++ b/webhooks/vmware/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2025 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 vmware contains webhooks for the infrastructure vmware v1beta1 API group. +package vmware