diff --git a/bundle/manifests/observability.openshift.io_uiplugins.yaml b/bundle/manifests/observability.openshift.io_uiplugins.yaml index 92f8af4e2..26020b8cf 100644 --- a/bundle/manifests/observability.openshift.io_uiplugins.yaml +++ b/bundle/manifests/observability.openshift.io_uiplugins.yaml @@ -246,6 +246,16 @@ spec: - conditions type: object type: object + x-kubernetes-validations: + - message: UIPlugin name must be 'logging' if type is Logging + rule: self.spec.type != 'Logging' || self.metadata.name == 'logging' + - message: UIPlugin name must be 'troubleshooting-panel' if type is TroubleshootingPanel + rule: self.spec.type != 'TroubleshootingPanel' || self.metadata.name == + 'troubleshooting-panel' + - message: UIPlugin name must be 'distributed-tracing' if type is DistributedTracing + rule: self.spec.type != 'DistributedTracing' || self.metadata.name == 'distributed-tracing' + - message: UIPlugin name must be 'dashboards' if type is Dashboards + rule: self.spec.type != 'Dashboards' || self.metadata.name == 'dashboards' served: true storage: true subresources: diff --git a/deploy/crds/common/observability.openshift.io_uiplugins.yaml b/deploy/crds/common/observability.openshift.io_uiplugins.yaml index 35093ca0e..839126f4f 100644 --- a/deploy/crds/common/observability.openshift.io_uiplugins.yaml +++ b/deploy/crds/common/observability.openshift.io_uiplugins.yaml @@ -246,6 +246,16 @@ spec: - conditions type: object type: object + x-kubernetes-validations: + - message: UIPlugin name must be 'logging' if type is Logging + rule: self.spec.type != 'Logging' || self.metadata.name == 'logging' + - message: UIPlugin name must be 'troubleshooting-panel' if type is TroubleshootingPanel + rule: self.spec.type != 'TroubleshootingPanel' || self.metadata.name == + 'troubleshooting-panel' + - message: UIPlugin name must be 'distributed-tracing' if type is DistributedTracing + rule: self.spec.type != 'DistributedTracing' || self.metadata.name == 'distributed-tracing' + - message: UIPlugin name must be 'dashboards' if type is Dashboards + rule: self.spec.type != 'Dashboards' || self.metadata.name == 'dashboards' served: true storage: true subresources: diff --git a/pkg/apis/uiplugin/v1alpha1/types.go b/pkg/apis/uiplugin/v1alpha1/types.go index 5ce9b4234..b27ddcbba 100644 --- a/pkg/apis/uiplugin/v1alpha1/types.go +++ b/pkg/apis/uiplugin/v1alpha1/types.go @@ -15,6 +15,10 @@ import ( // +k8s:openapi-gen=true // +kubebuilder:resource:scope=Cluster // +kubebuilder:subresource:status +// +kubebuilder:validation:XValidation:rule="self.spec.type != 'Logging' || self.metadata.name == 'logging'",message="UIPlugin name must be 'logging' if type is Logging" +// +kubebuilder:validation:XValidation:rule="self.spec.type != 'TroubleshootingPanel' || self.metadata.name == 'troubleshooting-panel'",message="UIPlugin name must be 'troubleshooting-panel' if type is TroubleshootingPanel" +// +kubebuilder:validation:XValidation:rule="self.spec.type != 'DistributedTracing' || self.metadata.name == 'distributed-tracing'",message="UIPlugin name must be 'distributed-tracing' if type is DistributedTracing" +// +kubebuilder:validation:XValidation:rule="self.spec.type != 'Dashboards' || self.metadata.name == 'dashboards'",message="UIPlugin name must be 'dashboards' if type is Dashboards" type UIPlugin struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"`