Skip to content

Commit

Permalink
fix: allow konnectID on ControlPlaneRef but disallow where unsupported
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Jan 22, 2025
1 parent b97af14 commit fbfd68d
Show file tree
Hide file tree
Showing 30 changed files with 76 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/configuration/v1/kongconsumer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions api/configuration/v1alpha1/controlplaneref_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1alpha1/kong_ca_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1alpha1/kong_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1alpha1/kong_vault_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1alpha1/kongkey_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1alpha1/kongkeyset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1alpha1/kongpluginbinding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1alpha1/kongroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1alpha1/kongservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1alpha1/kongupstream_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1beta1/kongconsumergroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ 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
- kic
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'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,17 @@ 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
- kic
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'')
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br /><br /> 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<br /><br /> 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. |

Expand Down
Loading

0 comments on commit fbfd68d

Please sign in to comment.