diff --git a/api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml b/api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml index d30ecd50a..2ca28c625 100644 --- a/api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml +++ b/api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml @@ -668,6 +668,9 @@ spec: - controlPlaneEndpoint - prismCentralEndpoint type: object + x-kubernetes-validations: + - message: Prism Central URL must not match the control plane endpoint IP + rule: isURL(self.prismCentralEndpoint.url) && (url(self.prismCentralEndpoint.url).getHostname() != self.controlPlaneEndpoint.host) proxy: description: HTTPProxy required for providing proxy configuration. properties: diff --git a/api/v1alpha1/nutanix_clusterconfig_types.go b/api/v1alpha1/nutanix_clusterconfig_types.go index 3240eac52..09fab9816 100644 --- a/api/v1alpha1/nutanix_clusterconfig_types.go +++ b/api/v1alpha1/nutanix_clusterconfig_types.go @@ -14,6 +14,7 @@ const ( ) // NutanixSpec defines the desired state of NutanixCluster. +// +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" type NutanixSpec struct { // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. // host can be either DNS name or ip address diff --git a/pkg/webhook/cluster/vaiidator.go b/pkg/webhook/cluster/validator.go similarity index 100% rename from pkg/webhook/cluster/vaiidator.go rename to pkg/webhook/cluster/validator.go