From fbfd68dac5b2e4cb958ef6b6625dfb30d328de5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Wed, 22 Jan 2025 14:10:22 +0100 Subject: [PATCH] fix: allow konnectID on ControlPlaneRef but disallow where unsupported --- api/configuration/v1/kongconsumer_types.go | 1 + api/configuration/v1alpha1/controlplaneref_types.go | 2 ++ api/configuration/v1alpha1/kong_ca_certificate.go | 1 + api/configuration/v1alpha1/kong_certificate.go | 1 + api/configuration/v1alpha1/kong_vault_types.go | 1 + .../v1alpha1/kongdataplaneclientcertificate_types.go | 1 + api/configuration/v1alpha1/kongkey_types.go | 1 + api/configuration/v1alpha1/kongkeyset_types.go | 1 + api/configuration/v1alpha1/kongpluginbinding_types.go | 1 + api/configuration/v1alpha1/kongroute_types.go | 1 + api/configuration/v1alpha1/kongservice_types.go | 1 + api/configuration/v1alpha1/kongupstream_types.go | 1 + api/configuration/v1beta1/kongconsumergroup_types.go | 1 + .../configuration.konghq.com_kongcacertificates.yaml | 4 ++++ .../configuration.konghq.com_kongcertificates.yaml | 4 ++++ .../configuration.konghq.com_kongconsumergroups.yaml | 4 ++++ .../configuration.konghq.com_kongconsumers.yaml | 4 ++++ ...figuration.konghq.com_kongdataplaneclientcertificates.yaml | 4 ++++ .../gateway-operator/configuration.konghq.com_kongkeys.yaml | 4 ++++ .../configuration.konghq.com_kongkeysets.yaml | 4 ++++ .../configuration.konghq.com_kongpluginbindings.yaml | 4 ++++ .../gateway-operator/configuration.konghq.com_kongroutes.yaml | 4 ++++ .../configuration.konghq.com_kongservices.yaml | 4 ++++ .../configuration.konghq.com_kongupstreams.yaml | 4 ++++ .../gateway-operator/configuration.konghq.com_kongvaults.yaml | 4 ++++ .../configuration.konghq.com_kongconsumergroups.yaml | 4 ++++ .../configuration.konghq.com_kongconsumers.yaml | 4 ++++ .../configuration.konghq.com_kongvaults.yaml | 4 ++++ docs/api-reference.md | 2 +- test/crdsvalidation/suite_crd_ref_change_test.go | 2 +- 30 files changed, 76 insertions(+), 2 deletions(-) diff --git a/api/configuration/v1/kongconsumer_types.go b/api/configuration/v1/kongconsumer_types.go index e845acf..887fc8c 100644 --- a/api/configuration/v1/kongconsumer_types.go +++ b/api/configuration/v1/kongconsumer_types.go @@ -76,6 +76,7 @@ type KongConsumer struct { type KongConsumerSpec struct { // ControlPlaneRef is a reference to a ControlPlane this Consumer is associated with. // +optional + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *configurationv1alpha1.ControlPlaneRef `json:"controlPlaneRef,omitempty"` // Tags is an optional set of tags applied to the consumer. diff --git a/api/configuration/v1alpha1/controlplaneref_types.go b/api/configuration/v1alpha1/controlplaneref_types.go index 8fecea5..8e65130 100644 --- a/api/configuration/v1alpha1/controlplaneref_types.go +++ b/api/configuration/v1alpha1/controlplaneref_types.go @@ -31,6 +31,8 @@ type ControlPlaneRef struct { // - kic // // The default is kic, which implies that the Control Plane is KIC. + // KonnectID might not be available for all the resources. + // Consult the specific resource documentation for more information. // // +kubebuilder:validation:Enum=konnectID;konnectNamespacedRef;kic // +kubebuilder:default:=kic diff --git a/api/configuration/v1alpha1/kong_ca_certificate.go b/api/configuration/v1alpha1/kong_ca_certificate.go index b35804d..49f38af 100644 --- a/api/configuration/v1alpha1/kong_ca_certificate.go +++ b/api/configuration/v1alpha1/kong_ca_certificate.go @@ -37,6 +37,7 @@ type KongCACertificate struct { type KongCACertificateSpec struct { // ControlPlaneRef references the Konnect Control Plane that this KongCACertificate should be created in. // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef"` KongCACertificateAPISpec `json:",inline"` diff --git a/api/configuration/v1alpha1/kong_certificate.go b/api/configuration/v1alpha1/kong_certificate.go index 3c471cc..3483d25 100644 --- a/api/configuration/v1alpha1/kong_certificate.go +++ b/api/configuration/v1alpha1/kong_certificate.go @@ -37,6 +37,7 @@ type KongCertificate struct { type KongCertificateSpec struct { // ControlPlaneRef references the Konnect Control Plane that this KongCertificate should be created in. // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef"` KongCertificateAPISpec `json:",inline"` diff --git a/api/configuration/v1alpha1/kong_vault_types.go b/api/configuration/v1alpha1/kong_vault_types.go index 74653f7..005e827 100644 --- a/api/configuration/v1alpha1/kong_vault_types.go +++ b/api/configuration/v1alpha1/kong_vault_types.go @@ -79,6 +79,7 @@ type KongVaultSpec struct { Tags common.Tags `json:"tags,omitempty"` // ControlPlaneRef is a reference to a Konnect ControlPlane this KongVault is associated with. // +optional + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef,omitempty"` } diff --git a/api/configuration/v1alpha1/kongdataplaneclientcertificate_types.go b/api/configuration/v1alpha1/kongdataplaneclientcertificate_types.go index 37e5b81..d078536 100644 --- a/api/configuration/v1alpha1/kongdataplaneclientcertificate_types.go +++ b/api/configuration/v1alpha1/kongdataplaneclientcertificate_types.go @@ -53,6 +53,7 @@ type KongDataPlaneClientCertificate struct { type KongDataPlaneClientCertificateSpec struct { // ControlPlaneRef is a reference to a Konnect ControlPlane this KongDataPlaneClientCertificate is associated with. // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef"` // KongDataPlaneClientCertificateAPISpec are the attributes of the KongDataPlaneClientCertificate itself. diff --git a/api/configuration/v1alpha1/kongkey_types.go b/api/configuration/v1alpha1/kongkey_types.go index b2d7dce..8d6e727 100644 --- a/api/configuration/v1alpha1/kongkey_types.go +++ b/api/configuration/v1alpha1/kongkey_types.go @@ -53,6 +53,7 @@ type KongKey struct { type KongKeySpec struct { // ControlPlaneRef is a reference to a Konnect ControlPlane this KongKey is associated with. // +optional + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef,omitempty"` // KeySetRef is a reference to a KongKeySet this KongKey is attached to. diff --git a/api/configuration/v1alpha1/kongkeyset_types.go b/api/configuration/v1alpha1/kongkeyset_types.go index 4febfc3..d62717b 100644 --- a/api/configuration/v1alpha1/kongkeyset_types.go +++ b/api/configuration/v1alpha1/kongkeyset_types.go @@ -52,6 +52,7 @@ type KongKeySet struct { type KongKeySetSpec struct { // ControlPlaneRef is a reference to a Konnect ControlPlane with which KongKeySet is associated. // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef"` // KongKeySetAPISpec are the attributes of the KongKeySet itself. diff --git a/api/configuration/v1alpha1/kongpluginbinding_types.go b/api/configuration/v1alpha1/kongpluginbinding_types.go index 30cc8cf..cfa5d5c 100644 --- a/api/configuration/v1alpha1/kongpluginbinding_types.go +++ b/api/configuration/v1alpha1/kongpluginbinding_types.go @@ -80,6 +80,7 @@ type KongPluginBindingSpec struct { // ControlPlaneRef is a reference to a ControlPlane this KongPluginBinding is associated with. // +optional + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef,omitempty"` } diff --git a/api/configuration/v1alpha1/kongroute_types.go b/api/configuration/v1alpha1/kongroute_types.go index dd26ec8..30e300a 100644 --- a/api/configuration/v1alpha1/kongroute_types.go +++ b/api/configuration/v1alpha1/kongroute_types.go @@ -63,6 +63,7 @@ type KongRouteSpec struct { // Route can either specify a ControlPlaneRef and be 'serviceless' route or // specify a ServiceRef and be associated with a Service. // +optional + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef,omitempty"` // ServiceRef is a reference to a Service this KongRoute is associated with. // Route can either specify a ControlPlaneRef and be 'serviceless' route or diff --git a/api/configuration/v1alpha1/kongservice_types.go b/api/configuration/v1alpha1/kongservice_types.go index e72a05c..e79d6d1 100644 --- a/api/configuration/v1alpha1/kongservice_types.go +++ b/api/configuration/v1alpha1/kongservice_types.go @@ -57,6 +57,7 @@ type KongService struct { type KongServiceSpec struct { // ControlPlaneRef is a reference to a ControlPlane this KongService is associated with. // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef"` KongServiceAPISpec `json:",inline"` diff --git a/api/configuration/v1alpha1/kongupstream_types.go b/api/configuration/v1alpha1/kongupstream_types.go index fb0f9e3..80eb3c1 100644 --- a/api/configuration/v1alpha1/kongupstream_types.go +++ b/api/configuration/v1alpha1/kongupstream_types.go @@ -55,6 +55,7 @@ type KongUpstream struct { type KongUpstreamSpec struct { // ControlPlaneRef is a reference to a ControlPlane this KongUpstream is associated with. // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *ControlPlaneRef `json:"controlPlaneRef"` KongUpstreamAPISpec `json:",inline"` diff --git a/api/configuration/v1beta1/kongconsumergroup_types.go b/api/configuration/v1beta1/kongconsumergroup_types.go index c403adf..e8c6bfa 100644 --- a/api/configuration/v1beta1/kongconsumergroup_types.go +++ b/api/configuration/v1beta1/kongconsumergroup_types.go @@ -59,6 +59,7 @@ type KongConsumerGroupSpec struct { // ControlPlaneRef is a reference to a ControlPlane this ConsumerGroup is associated with. // +optional + // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'konnectID'", message="konnectID type is not supported" ControlPlaneRef *configurationv1alpha1.ControlPlaneRef `json:"controlPlaneRef,omitempty"` // Tags is an optional set of tags applied to the ConsumerGroup. diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongcacertificates.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongcacertificates.yaml index 0c227de..3815f36 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongcacertificates.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongcacertificates.yaml @@ -85,6 +85,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -92,6 +94,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongcertificates.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongcertificates.yaml index 5c14cc1..d5bbbc5 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongcertificates.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongcertificates.yaml @@ -91,6 +91,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -98,6 +100,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongconsumergroups.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongconsumergroups.yaml index 2518d87..7d2dedb 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongconsumergroups.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongconsumergroups.yaml @@ -87,6 +87,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -94,6 +96,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongconsumers.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongconsumers.yaml index c9efdd2..4623152 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongconsumers.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongconsumers.yaml @@ -112,6 +112,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -119,6 +121,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongdataplaneclientcertificates.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongdataplaneclientcertificates.yaml index 0bb5dba..5619e24 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongdataplaneclientcertificates.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongdataplaneclientcertificates.yaml @@ -87,6 +87,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -94,6 +96,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongkeys.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongkeys.yaml index 0053f94..e3a4548 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongkeys.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongkeys.yaml @@ -81,6 +81,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -88,6 +90,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongkeysets.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongkeysets.yaml index 99d0663..306e458 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongkeysets.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongkeysets.yaml @@ -81,6 +81,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -88,6 +90,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongpluginbindings.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongpluginbindings.yaml index 23bbc07..1faf7dc 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongpluginbindings.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongpluginbindings.yaml @@ -89,6 +89,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -96,6 +98,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongroutes.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongroutes.yaml index 7f2824b..a7d365d 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongroutes.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongroutes.yaml @@ -82,6 +82,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -89,6 +91,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongservices.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongservices.yaml index 9ff3813..c8db247 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongservices.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongservices.yaml @@ -94,6 +94,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -101,6 +103,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongupstreams.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongupstreams.yaml index 9c022a9..833490f 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongupstreams.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongupstreams.yaml @@ -91,6 +91,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -98,6 +100,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongvaults.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongvaults.yaml index 2047a57..07b8739 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongvaults.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongvaults.yaml @@ -114,6 +114,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -121,6 +123,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongconsumergroups.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongconsumergroups.yaml index 2518d87..7d2dedb 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongconsumergroups.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongconsumergroups.yaml @@ -87,6 +87,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -94,6 +96,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongconsumers.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongconsumers.yaml index c9efdd2..4623152 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongconsumers.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongconsumers.yaml @@ -112,6 +112,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -119,6 +121,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongvaults.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongvaults.yaml index 2047a57..07b8739 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongvaults.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongvaults.yaml @@ -114,6 +114,8 @@ spec: - kic The default is kic, which implies that the Control Plane is KIC. + KonnectID might not be available for all the resources. + Consult the specific resource documentation for more information. enum: - konnectID - konnectNamespacedRef @@ -121,6 +123,8 @@ spec: type: string type: object x-kubernetes-validations: + - message: konnectID type is not supported + rule: '!has(self.type) || self.type != ''konnectID''' - message: when type is konnectNamespacedRef, konnectNamespacedRef must be set rule: '(has(self.type) && self.type == ''konnectNamespacedRef'') diff --git a/docs/api-reference.md b/docs/api-reference.md index 051fa1b..c77cd60 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -685,7 +685,7 @@ It is used to reference a Control Plane entity. | Field | Description | | --- | --- | -| `type` _string_ | Type indicates the type of the control plane being referenced. Allowed values: - konnectID - konnectNamespacedRef - kic

The default is kic, which implies that the Control Plane is KIC. | +| `type` _string_ | Type indicates the type of the control plane being referenced. Allowed values: - konnectID - konnectNamespacedRef - kic

The default is kic, which implies that the Control Plane is KIC. KonnectID might not be available for all the resources. Consult the specific resource documentation for more information. | | `konnectID` _string_ | KonnectID is the schema for the KonnectID type. This field is required when the Type is konnectID. | | `konnectNamespacedRef` _[KonnectNamespacedRef](#konnectnamespacedref)_ | KonnectNamespacedRef is a reference to a Konnect Control Plane entity inside the cluster. It contains the name of the Konnect Control Plane. This field is required when the Type is konnectNamespacedRef. | diff --git a/test/crdsvalidation/suite_crd_ref_change_test.go b/test/crdsvalidation/suite_crd_ref_change_test.go index 8e65729..7ed0527 100644 --- a/test/crdsvalidation/suite_crd_ref_change_test.go +++ b/test/crdsvalidation/suite_crd_ref_change_test.go @@ -127,7 +127,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ ret = append(ret, crdsvalidation.TestCase[T]{ Name: "providing konnectNamespacedRef when type is konnectID yields an error", TestObject: obj, - ExpectedErrorMessage: lo.ToPtr("when type is konnectID, konnectID must be set"), + ExpectedErrorMessage: lo.ToPtr("spec.controlPlaneRef: Invalid value: \"object\": konnectID type is not supported"), }) } {