Skip to content

Commit 23a208d

Browse files
committed
fix: uses CEL instead of webhook validation
1 parent 4651c5b commit 23a208d

File tree

4 files changed

+4
-124
lines changed

4 files changed

+4
-124
lines changed

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,9 @@ spec:
668668
- controlPlaneEndpoint
669669
- prismCentralEndpoint
670670
type: object
671+
x-kubernetes-validations:
672+
- message: Prism Central URL must not match the control plane endpoint IP
673+
rule: isURL(self.prismCentralEndpoint.url) && (url(self.prismCentralEndpoint.url).getHostname() != self.controlPlaneEndpoint.host)
671674
proxy:
672675
description: HTTPProxy required for providing proxy configuration.
673676
properties:

api/v1alpha1/nutanix_clusterconfig_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const (
1414
)
1515

1616
// NutanixSpec defines the desired state of NutanixCluster.
17+
// +kubebuilder:validation:XValidation:rule="isURL(self.prismCentralEndpoint.url) && (url(self.prismCentralEndpoint.url).getHostname() != self.controlPlaneEndpoint.host)", message="Prism Central URL must not match the control plane endpoint IP"
1718
type NutanixSpec struct {
1819
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
1920
// host can be either DNS name or ip address

pkg/webhook/cluster/nutanix_validator.go

Lines changed: 0 additions & 123 deletions
This file was deleted.

pkg/webhook/cluster/validator.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ import (
1111
func NewValidator(client ctrlclient.Client, decoder admission.Decoder) admission.Handler {
1212
return admission.MultiValidatingHandler(
1313
NewClusterUUIDLabeler(client, decoder).Validator(),
14-
NewNutanixValidator(client, decoder).Validator(),
1514
)
1615
}

0 commit comments

Comments
 (0)