Skip to content

Commit fcb69a4

Browse files
committed
🌱 Able to export webhooks for external utilization
1 parent 6e2e39d commit fcb69a4

File tree

5 files changed

+148
-2
lines changed

5 files changed

+148
-2
lines changed

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ import (
5959
"sigs.k8s.io/cluster-api-provider-vsphere/controllers"
6060
"sigs.k8s.io/cluster-api-provider-vsphere/controllers/vmware"
6161
"sigs.k8s.io/cluster-api-provider-vsphere/feature"
62-
"sigs.k8s.io/cluster-api-provider-vsphere/internal/webhooks"
63-
vmwarewebhooks "sigs.k8s.io/cluster-api-provider-vsphere/internal/webhooks/vmware"
6462
capvcontext "sigs.k8s.io/cluster-api-provider-vsphere/pkg/context"
6563
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/manager"
6664
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/session"
6765
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/version"
66+
"sigs.k8s.io/cluster-api-provider-vsphere/webhooks"
67+
vmwarewebhooks "sigs.k8s.io/cluster-api-provider-vsphere/webhooks/vmware"
6868
)
6969

7070
var (

webhooks/alias.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package webhooks
18+
19+
import (
20+
ctrl "sigs.k8s.io/controller-runtime"
21+
22+
"sigs.k8s.io/cluster-api-provider-vsphere/internal/webhooks"
23+
)
24+
25+
// VSphereClusterTemplateWebhook implements a validation and defaulting webhook for VSphereClusterTemplate.
26+
type VSphereClusterTemplateWebhook struct{}
27+
28+
// SetupWebhookWithManager sets up VSphereClusterTemplate webhooks.
29+
func (webhook *VSphereClusterTemplateWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
30+
return (&webhooks.VSphereClusterTemplateWebhook{}).SetupWebhookWithManager(mgr)
31+
}
32+
33+
// VSphereDeploymentZoneWebhook implements a validation and defaulting webhook for VSphereDeploymentZone.
34+
type VSphereDeploymentZoneWebhook struct{}
35+
36+
// SetupWebhookWithManager sets up VSphereDeploymentZone webhooks.
37+
func (webhook *VSphereDeploymentZoneWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
38+
return (&webhooks.VSphereDeploymentZoneWebhook{}).SetupWebhookWithManager(mgr)
39+
}
40+
41+
// VSphereFailureDomainWebhook implements a validation and defaulting webhook for VSphereFailureDomain.
42+
type VSphereFailureDomainWebhook struct{}
43+
44+
// SetupWebhookWithManager sets up VSphereFailureDomain webhooks.
45+
func (webhook *VSphereFailureDomainWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
46+
return (&webhooks.VSphereFailureDomainWebhook{}).SetupWebhookWithManager(mgr)
47+
}
48+
49+
// VSphereMachineWebhook implements a validation and defaulting webhook for VSphereMachine.
50+
type VSphereMachineWebhook struct{}
51+
52+
// SetupWebhookWithManager sets up VSphereMachine webhooks.
53+
func (webhook *VSphereMachineWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
54+
return (&webhooks.VSphereMachineWebhook{}).SetupWebhookWithManager(mgr)
55+
}
56+
57+
// VSphereMachineTemplateWebhook implements a validation and defaulting webhook for VSphereMachineTemplate.
58+
type VSphereMachineTemplateWebhook struct{}
59+
60+
// SetupWebhookWithManager sets up VSphereMachineTemplate webhooks.
61+
func (webhook *VSphereMachineTemplateWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
62+
return (&webhooks.VSphereMachineTemplateWebhook{}).SetupWebhookWithManager(mgr)
63+
}
64+
65+
// VSphereVMWebhook implements a validation and defaulting webhook for VSphereVM.
66+
type VSphereVMWebhook struct{}
67+
68+
// SetupWebhookWithManager sets up VSphereVM webhooks.
69+
func (webhook *VSphereVMWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
70+
return (&webhooks.VSphereVMWebhook{}).SetupWebhookWithManager(mgr)
71+
}

webhooks/doc.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package webhooks contains webhooks for the infrastructure v1beta1 API group.
18+
package webhooks

webhooks/vmware/alias.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package vmware
18+
19+
import (
20+
ctrl "sigs.k8s.io/controller-runtime"
21+
22+
"sigs.k8s.io/cluster-api-provider-vsphere/internal/webhooks/vmware"
23+
)
24+
25+
// VSphereMachineWebhook implements a validation and defaulting webhook for VSphereMachine.
26+
type VSphereMachineWebhook struct{}
27+
28+
// SetupWebhookWithManager sets up VSphereMachine webhooks.
29+
func (webhook *VSphereMachineWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
30+
return (&vmware.VSphereMachineWebhook{}).SetupWebhookWithManager(mgr)
31+
}
32+
33+
// VSphereMachineTemplateWebhook implements a validation and defaulting webhook for VSphereMachineTemplate.
34+
type VSphereMachineTemplateWebhook struct{}
35+
36+
// SetupWebhookWithManager sets up VSphereMachineTemplate webhooks.
37+
func (webhook *VSphereMachineTemplateWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error {
38+
return (&vmware.VSphereMachineTemplateWebhook{}).SetupWebhookWithManager(mgr)
39+
}

webhooks/vmware/doc.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package vmware contains webhooks for the infrastructure vmware v1beta1 API group.
18+
package vmware

0 commit comments

Comments
 (0)