Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
71 changes: 71 additions & 0 deletions webhooks/alias.go
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct as it doesn't implement a defaulting webhook. Let's drop this detail here to avoid having to keep that in sync

// VSphereClusterTemplateWebhook implements a webhook for VSphereClusterTemplate.

(also for all other webhooks)

type VSphereClusterTemplateWebhook struct{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not have a "Webhook" suffix because the package already contains webhooks. (also for all other webhooks)


// 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)
}
18 changes: 18 additions & 0 deletions webhooks/doc.go
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions webhooks/vmware/alias.go
Original file line number Diff line number Diff line change
@@ -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)
}
18 changes: 18 additions & 0 deletions webhooks/vmware/doc.go
Original file line number Diff line number Diff line change
@@ -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