Skip to content

Commit

Permalink
Revert "fix: disallow konnectID references (#198)" (#214)
Browse files Browse the repository at this point in the history
This reverts commit 3a54d1a.
  • Loading branch information
czeslavo authored Jan 8, 2025
1 parent 99c05b8 commit 6dba3ef
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 24 deletions.
4 changes: 2 additions & 2 deletions api/configuration/v1alpha1/key_set_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const (
// KeySetRef is the schema for the KeySetRef type.
// It is used to reference a KeySet entity.
// +kubebuilder:validation:XValidation:rule="self.type == 'namespacedRef' ? has(self.namespacedRef) : true", message="when type is namespacedRef, namespacedRef must be set"
// +kubebuilder:validation:XValidation:rule="self.type == 'konnectID' ? has(self.konnectID) : true", message="when type is konnectID, konnectID must be set"
// +apireference:kgo:include
// +kong:channels=gateway-operator
type KeySetRef struct {
// Type defines type of the KeySet object reference. It can be one of:
// - konnectID
// - namespacedRef
//
// +kubebuilder:validation:Enum=namespacedRef
Type KeySetRefType `json:"type"`

// KonnectID is the schema for the KonnectID type.
Expand Down
3 changes: 2 additions & 1 deletion api/configuration/v1alpha1/konnect_controlplaneref_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ const (
// +apireference:kgo:include
type ControlPlaneRef struct {
// 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.
//
// +kubebuilder:validation:Enum=konnectNamespacedRef;kic
// +kubebuilder:validation:Enum=konnectID;konnectNamespacedRef;kic
// +kubebuilder:default:=kic
Type string `json:"type,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down Expand Up @@ -140,15 +142,13 @@ spec:
- name
type: object
type:
allOf:
- enum:
- konnectID
- namespacedRef
- enum:
- namespacedRef
description: |-
Type defines type of the KeySet object reference. It can be one of:
- konnectID
- namespacedRef
enum:
- konnectID
- namespacedRef
type: string
required:
- type
Expand All @@ -157,6 +157,8 @@ spec:
- message: when type is namespacedRef, namespacedRef must be set
rule: 'self.type == ''namespacedRef'' ? has(self.namespacedRef)
: true'
- message: when type is konnectID, konnectID must be set
rule: 'self.type == ''konnectID'' ? has(self.konnectID) : true'
kid:
description: |-
KID is a unique identifier for a key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ spec:
default: kic
description: |-
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.
enum:
- konnectID
- konnectNamespacedRef
- kic
type: string
Expand Down
4 changes: 2 additions & 2 deletions 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: - 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` _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 Expand Up @@ -776,7 +776,7 @@ It is used to reference a KeySet entity.

| Field | Description |
| --- | --- |
| `type` _[KeySetRefType](#keysetreftype)_ | Type defines type of the KeySet object reference. It can be one of: - namespacedRef |
| `type` _[KeySetRefType](#keysetreftype)_ | Type defines type of the KeySet object reference. It can be one of: - konnectID - namespacedRef |
| `konnectID` _string_ | KonnectID is the schema for the KonnectID type. This field is required when the Type is konnectID. |
| `namespacedRef` _[KeySetNamespacedRef](#keysetnamespacedref)_ | NamespacedRef is a reference to a KeySet entity inside the cluster. This field is required when the Type is namespacedRef. |

Expand Down
5 changes: 1 addition & 4 deletions test/crdsvalidation/kongkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ func TestKongKey(t *testing.T) {
},
},
},
// TODO change when konnectID ref is allowed
ExpectedErrorMessage: lo.ToPtr("Unsupported value: \"konnectID\": supported values: \"namespacedRef\""),
},
{
Name: "when type is 'konnectID', konnectID is required",
Expand All @@ -179,8 +177,7 @@ func TestKongKey(t *testing.T) {
},
},
},
// TODO change when konnectID ref is allowed
ExpectedErrorMessage: lo.ToPtr("Unsupported value: \"konnectID\": supported values: \"namespacedRef\""),
ExpectedErrorMessage: lo.ToPtr("when type is konnectID, konnectID must be set"),
},
{
Name: "unknown type is not accepted",
Expand Down
15 changes: 6 additions & 9 deletions test/crdsvalidation/suite_crd_ref_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ func NewCRDValidationTestCasesGroupCPRefChange[
},
})
ret = append(ret, CRDValidationTestCase[T]{
Name: "providing konnectNamespacedRef when type is konnectID yields an error",
TestObject: obj,
// TODO: change when konnectID is allowed
// ExpectedErrorMessage: lo.ToPtr("when type is konnectID, konnectID must be set"),
ExpectedErrorMessage: lo.ToPtr("Unsupported value: \"konnectID\": supported values: \"konnectNamespacedRef\", \"kic\""),
Name: "providing konnectNamespacedRef when type is konnectID yields an error",
TestObject: obj,
ExpectedErrorMessage: lo.ToPtr("when type is konnectID, konnectID must be set"),
})
}
{
Expand All @@ -141,10 +139,9 @@ func NewCRDValidationTestCasesGroupCPRefChange[
},
})
ret = append(ret, CRDValidationTestCase[T]{
Name: "providing konnectNamespacedRef and konnectID when type is konnectID yields an error",
TestObject: obj,
// TODO: change when konnectID is allowed
ExpectedErrorMessage: lo.ToPtr("Unsupported value: \"konnectID\": supported values: \"konnectNamespacedRef\", \"kic\""),
Name: "providing konnectNamespacedRef and konnectID when type is konnectID yields an error",
TestObject: obj,
ExpectedErrorMessage: lo.ToPtr("when type is konnectID, konnectNamespacedRef must not be set"),
})
}
{
Expand Down

0 comments on commit 6dba3ef

Please sign in to comment.