From 179f3c0fc38fa0c4193236d13977622d79155d66 Mon Sep 17 00:00:00 2001 From: Yi Tao Date: Tue, 7 Nov 2023 18:00:43 +0800 Subject: [PATCH 1/3] remove kubebuilder:validation:Optional comments on types --- ...uration.konghq.com_kongclusterplugins.yaml | 2 ++ ...uration.konghq.com_kongconsumergroups.yaml | 2 +- ...onfiguration.konghq.com_kongconsumers.yaml | 2 ++ .../configuration.konghq.com_kongplugins.yaml | 2 ++ pkg/apis/configuration/v1/configsource.go | 19 +++++++------------ .../v1/kongclusterplugin_types.go | 3 +-- .../configuration/v1/kongconsumer_types.go | 3 +-- .../configuration/v1/kongingress_types.go | 1 - pkg/apis/configuration/v1/kongplugin_types.go | 3 +-- .../configuration/v1beta1/ingress_rules.go | 15 ++------------- .../v1beta1/kongconsumergroup_types.go | 3 +-- .../configuration/v1beta1/tcpingress_types.go | 1 - .../configuration/v1beta1/udpingress_types.go | 1 - 13 files changed, 20 insertions(+), 37 deletions(-) diff --git a/config/crd/bases/configuration.konghq.com_kongclusterplugins.yaml b/config/crd/bases/configuration.konghq.com_kongclusterplugins.yaml index 2f80eeb8dd..1dc78bed92 100644 --- a/config/crd/bases/configuration.konghq.com_kongclusterplugins.yaml +++ b/config/crd/bases/configuration.konghq.com_kongclusterplugins.yaml @@ -84,6 +84,8 @@ spec: - name - namespace type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. diff --git a/config/crd/bases/configuration.konghq.com_kongconsumergroups.yaml b/config/crd/bases/configuration.konghq.com_kongconsumergroups.yaml index 9abb76af93..a0f56a2af8 100644 --- a/config/crd/bases/configuration.konghq.com_kongconsumergroups.yaml +++ b/config/crd/bases/configuration.konghq.com_kongconsumergroups.yaml @@ -44,7 +44,7 @@ spec: metadata: type: object status: - description: Status represents the current status of the KongConsumer + description: Status represents the current status of the KongConsumerGroup resource. properties: conditions: diff --git a/config/crd/bases/configuration.konghq.com_kongconsumers.yaml b/config/crd/bases/configuration.konghq.com_kongconsumers.yaml index 02ac427eb2..65943be20c 100644 --- a/config/crd/bases/configuration.konghq.com_kongconsumers.yaml +++ b/config/crd/bases/configuration.konghq.com_kongconsumers.yaml @@ -151,6 +151,8 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string + required: + - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id diff --git a/config/crd/bases/configuration.konghq.com_kongplugins.yaml b/config/crd/bases/configuration.konghq.com_kongplugins.yaml index 775fdb3e92..f08b7b3de6 100644 --- a/config/crd/bases/configuration.konghq.com_kongplugins.yaml +++ b/config/crd/bases/configuration.konghq.com_kongplugins.yaml @@ -80,6 +80,8 @@ spec: - key - name type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. diff --git a/pkg/apis/configuration/v1/configsource.go b/pkg/apis/configuration/v1/configsource.go index 2ba4ea73b1..d4fc0efe6e 100644 --- a/pkg/apis/configuration/v1/configsource.go +++ b/pkg/apis/configuration/v1/configsource.go @@ -4,37 +4,32 @@ package v1 // +kubebuilder:object:generate=true type ConfigSource struct { // Specifies a name and a key of a secret to refer to. The namespace is implicitly set to the one of referring object. - SecretValue SecretValueFromSource `json:"secretKeyRef,omitempty"` + SecretValue SecretValueFromSource `json:"secretKeyRef"` } // NamespacedConfigSource is a wrapper around NamespacedSecretValueFromSource. // +kubebuilder:object:generate=true type NamespacedConfigSource struct { // Specifies a name, a namespace, and a key of a secret to refer to. - SecretValue NamespacedSecretValueFromSource `json:"secretKeyRef,omitempty"` + SecretValue NamespacedSecretValueFromSource `json:"secretKeyRef"` } // SecretValueFromSource represents the source of a secret value. // +kubebuilder:object:generate=true type SecretValueFromSource struct { // The secret containing the key. - // +kubebuilder:validation:Required - Secret string `json:"name,omitempty"` + Secret string `json:"name"` // The key containing the value. - // +kubebuilder:validation:Required - Key string `json:"key,omitempty"` + Key string `json:"key"` } // NamespacedSecretValueFromSource represents the source of a secret value specifying the secret namespace. // +kubebuilder:object:generate=true type NamespacedSecretValueFromSource struct { // The namespace containing the secret. - // +kubebuilder:validation:Required - Namespace string `json:"namespace,omitempty"` + Namespace string `json:"namespace"` // The secret containing the key. - // +kubebuilder:validation:Required - Secret string `json:"name,omitempty"` + Secret string `json:"name"` // The key containing the value. - // +kubebuilder:validation:Required - Key string `json:"key,omitempty"` + Key string `json:"key"` } diff --git a/pkg/apis/configuration/v1/kongclusterplugin_types.go b/pkg/apis/configuration/v1/kongclusterplugin_types.go index 052d908788..dc4b187d41 100644 --- a/pkg/apis/configuration/v1/kongclusterplugin_types.go +++ b/pkg/apis/configuration/v1/kongclusterplugin_types.go @@ -29,7 +29,6 @@ import ( // +kubebuilder:resource:scope=Cluster,shortName=kcp,categories=kong-ingress-controller // +kubebuilder:subresource:status // +kubebuilder:storageversion -// +kubebuilder:validation:Optional // +kubebuilder:printcolumn:name="Plugin-Type",type=string,JSONPath=`.plugin`,description="Name of the plugin" // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Age" // +kubebuilder:printcolumn:name="Disabled",type=boolean,JSONPath=`.disabled`,description="Indicates if the plugin is disabled",priority=1 @@ -65,7 +64,7 @@ type KongClusterPlugin struct { // PluginName is the name of the plugin to which to apply the config. // +kubebuilder:validation:Required - PluginName string `json:"plugin,omitempty"` + PluginName string `json:"plugin"` // RunOn configures the plugin to run on the first or the second or both // nodes in case of a service mesh deployment. diff --git a/pkg/apis/configuration/v1/kongconsumer_types.go b/pkg/apis/configuration/v1/kongconsumer_types.go index 007b317ca8..9713eb6a21 100644 --- a/pkg/apis/configuration/v1/kongconsumer_types.go +++ b/pkg/apis/configuration/v1/kongconsumer_types.go @@ -26,7 +26,6 @@ import ( // +kubebuilder:subresource:status // +kubebuilder:storageversion // +kubebuilder:resource:shortName=kc,categories=kong-ingress-controller -// +kubebuilder:validation:Optional // +kubebuilder:printcolumn:name="Username",type=string,JSONPath=`.username`,description="Username of a Kong Consumer" // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Age" // +kubebuilder:printcolumn:name="Programmed",type=string,JSONPath=`.status.conditions[?(@.type=="Programmed")].status` @@ -38,7 +37,7 @@ type KongConsumer struct { metav1.ObjectMeta `json:"metadata,omitempty"` // Username is a Kong cluster-unique username of the consumer. - Username string `json:"username,omitempty"` + Username string `json:"username"` // CustomID is a Kong cluster-unique existing ID for the consumer - useful for mapping // Kong with users in your existing database. diff --git a/pkg/apis/configuration/v1/kongingress_types.go b/pkg/apis/configuration/v1/kongingress_types.go index 3e171b9fc0..26b7121cca 100644 --- a/pkg/apis/configuration/v1/kongingress_types.go +++ b/pkg/apis/configuration/v1/kongingress_types.go @@ -27,7 +27,6 @@ import ( // +kubebuilder:subresource:status // +kubebuilder:storageversion // +kubebuilder:resource:shortName=ki,categories=kong-ingress-controller -// +kubebuilder:validation:Optional // +kubebuilder:validation:XValidation:rule="!has(self.proxy)", message="'proxy' field is no longer supported, use Service's annotations instead" // +kubebuilder:validation:XValidation:rule="!has(self.route)", message="'route' field is no longer supported, use Ingress' annotations instead" diff --git a/pkg/apis/configuration/v1/kongplugin_types.go b/pkg/apis/configuration/v1/kongplugin_types.go index 03bb937b2d..d88663d922 100644 --- a/pkg/apis/configuration/v1/kongplugin_types.go +++ b/pkg/apis/configuration/v1/kongplugin_types.go @@ -28,7 +28,6 @@ import ( // +kubebuilder:subresource:status // +kubebuilder:storageversion // +kubebuilder:resource:shortName=kp,categories=kong-ingress-controller -// +kubebuilder:validation:Optional // +kubebuilder:printcolumn:name="Plugin-Type",type=string,JSONPath=`.plugin`,description="Name of the plugin" // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Age" // +kubebuilder:printcolumn:name="Disabled",type=boolean,JSONPath=`.disabled`,description="Indicates if the plugin is disabled",priority=1 @@ -65,7 +64,7 @@ type KongPlugin struct { // PluginName is the name of the plugin to which to apply the config. // +kubebuilder:validation:Required - PluginName string `json:"plugin,omitempty"` + PluginName string `json:"plugin"` // RunOn configures the plugin to run on the first or the second or both // nodes in case of a service mesh deployment. diff --git a/pkg/apis/configuration/v1beta1/ingress_rules.go b/pkg/apis/configuration/v1beta1/ingress_rules.go index cb59b1b8cd..87e5563a1c 100644 --- a/pkg/apis/configuration/v1beta1/ingress_rules.go +++ b/pkg/apis/configuration/v1beta1/ingress_rules.go @@ -1,7 +1,5 @@ package v1beta1 -// +kubebuilder:validation:Optional - // UDPIngressRule represents a rule to apply against incoming requests // wherein no Host matching is available for request routing, only the port // is used to match requests. @@ -11,17 +9,13 @@ type UDPIngressRule struct { // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // +kubebuilder:validation:Format=int32 - // +kubebuilder:validation:Required Port int `json:"port"` // Backend defines the Kubernetes service which accepts traffic from the // listening Port defined above. - // +kubebuilder:validation:Required Backend IngressBackend `json:"backend"` } -// +kubebuilder:validation:Optional - // IngressRule represents a rule to apply against incoming requests. // Matching is performed based on an (optional) SNI and port. type IngressRule struct { @@ -32,6 +26,7 @@ type IngressRule struct { // If a Host is specified, the protocol must be TLS over TCP. // A plain-text TCP request cannot be routed based on Host. It can only // be routed based on Port. + // +kubebuilder:validation:Optional Host string `json:"host,omitempty"` // Port is the port on which to accept TCP or TLS over TCP sessions and @@ -40,21 +35,16 @@ type IngressRule struct { // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // +kubebuilder:validation:Format=int32 - // +kubebuilder:validation:Required - Port int `json:"port,omitempty"` + Port int `json:"port"` // Backend defines the referenced service endpoint to which the traffic // will be forwarded to. - // +kubebuilder:validation:Required Backend IngressBackend `json:"backend"` } -// +kubebuilder:validation:Optional - // IngressBackend describes all endpoints for a given service and port. type IngressBackend struct { // Specifies the name of the referenced service. - // +kubebuilder:validation:Required // +kubebuilder:validation:MinLength=1 ServiceName string `json:"serviceName"` @@ -62,6 +52,5 @@ type IngressBackend struct { // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // +kubebuilder:validation:Format=int32 - // +kubebuilder:validation:Required ServicePort int `json:"servicePort"` } diff --git a/pkg/apis/configuration/v1beta1/kongconsumergroup_types.go b/pkg/apis/configuration/v1beta1/kongconsumergroup_types.go index 06d9717890..4292f5e6c5 100644 --- a/pkg/apis/configuration/v1beta1/kongconsumergroup_types.go +++ b/pkg/apis/configuration/v1beta1/kongconsumergroup_types.go @@ -26,7 +26,6 @@ import ( // +kubebuilder:subresource:status // +kubebuilder:storageversion // +kubebuilder:resource:shortName=kcg,categories=kong-ingress-controller -// +kubebuilder:validation:Optional // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Age" // +kubebuilder:printcolumn:name="Programmed",type=string,JSONPath=`.status.conditions[?(@.type=="Programmed")].status` @@ -35,7 +34,7 @@ type KongConsumerGroup struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // Status represents the current status of the KongConsumer resource. + // Status represents the current status of the KongConsumerGroup resource. Status KongConsumerGroupStatus `json:"status,omitempty"` } diff --git a/pkg/apis/configuration/v1beta1/tcpingress_types.go b/pkg/apis/configuration/v1beta1/tcpingress_types.go index 3063083244..3ffcd69ac9 100644 --- a/pkg/apis/configuration/v1beta1/tcpingress_types.go +++ b/pkg/apis/configuration/v1beta1/tcpingress_types.go @@ -27,7 +27,6 @@ import ( // +kubebuilder:resource:categories=kong-ingress-controller // +kubebuilder:subresource:status // +kubebuilder:storageversion -// +kubebuilder:validation:Optional // +kubebuilder:printcolumn:name="Address",type=string,JSONPath=`.status.loadBalancer.ingress[*].ip`,description="Address of the load balancer" // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Age" diff --git a/pkg/apis/configuration/v1beta1/udpingress_types.go b/pkg/apis/configuration/v1beta1/udpingress_types.go index a62b33ecbf..a2b6f86c02 100644 --- a/pkg/apis/configuration/v1beta1/udpingress_types.go +++ b/pkg/apis/configuration/v1beta1/udpingress_types.go @@ -40,7 +40,6 @@ type UDPIngressList struct { // +kubebuilder:resource:categories=kong-ingress-controller // +kubebuilder:subresource:status // +kubebuilder:storageversion -// +kubebuilder:validation:Optional // +kubebuilder:printcolumn:name="Address",type=string,JSONPath=`.status.loadBalancer.ingress[*].ip`,description="Address of the load balancer" // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Age" From 37232dfa41bb261d069c4adae3862c74d60eca01 Mon Sep 17 00:00:00 2001 From: Yi Tao Date: Wed, 8 Nov 2023 16:17:04 +0800 Subject: [PATCH 2/3] update manifests --- .../e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml | 8 +++++++- .../manifests/all-in-one-dbless-konnect-enterprise.yaml | 8 +++++++- test/e2e/manifests/all-in-one-dbless-konnect.yaml | 8 +++++++- test/e2e/manifests/all-in-one-dbless.yaml | 8 +++++++- test/e2e/manifests/all-in-one-postgres-enterprise.yaml | 8 +++++++- .../manifests/all-in-one-postgres-multiple-gateways.yaml | 8 +++++++- test/e2e/manifests/all-in-one-postgres.yaml | 8 +++++++- 7 files changed, 49 insertions(+), 7 deletions(-) diff --git a/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml b/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml index 2e3129c044..d834312894 100644 --- a/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml +++ b/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml @@ -142,6 +142,8 @@ spec: - name - namespace type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. @@ -358,7 +360,7 @@ spec: metadata: type: object status: - description: Status represents the current status of the KongConsumer + description: Status represents the current status of the KongConsumerGroup resource. properties: conditions: @@ -600,6 +602,8 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string + required: + - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id @@ -1054,6 +1058,8 @@ spec: - key - name type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. diff --git a/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml b/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml index 6b7d911b70..e7764331b1 100644 --- a/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml +++ b/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml @@ -142,6 +142,8 @@ spec: - name - namespace type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. @@ -358,7 +360,7 @@ spec: metadata: type: object status: - description: Status represents the current status of the KongConsumer + description: Status represents the current status of the KongConsumerGroup resource. properties: conditions: @@ -600,6 +602,8 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string + required: + - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id @@ -1054,6 +1058,8 @@ spec: - key - name type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. diff --git a/test/e2e/manifests/all-in-one-dbless-konnect.yaml b/test/e2e/manifests/all-in-one-dbless-konnect.yaml index 58092edcf7..08bc8d8ee6 100644 --- a/test/e2e/manifests/all-in-one-dbless-konnect.yaml +++ b/test/e2e/manifests/all-in-one-dbless-konnect.yaml @@ -142,6 +142,8 @@ spec: - name - namespace type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. @@ -358,7 +360,7 @@ spec: metadata: type: object status: - description: Status represents the current status of the KongConsumer + description: Status represents the current status of the KongConsumerGroup resource. properties: conditions: @@ -600,6 +602,8 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string + required: + - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id @@ -1054,6 +1058,8 @@ spec: - key - name type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. diff --git a/test/e2e/manifests/all-in-one-dbless.yaml b/test/e2e/manifests/all-in-one-dbless.yaml index 04478faafa..f3fd748f18 100644 --- a/test/e2e/manifests/all-in-one-dbless.yaml +++ b/test/e2e/manifests/all-in-one-dbless.yaml @@ -142,6 +142,8 @@ spec: - name - namespace type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. @@ -358,7 +360,7 @@ spec: metadata: type: object status: - description: Status represents the current status of the KongConsumer + description: Status represents the current status of the KongConsumerGroup resource. properties: conditions: @@ -600,6 +602,8 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string + required: + - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id @@ -1054,6 +1058,8 @@ spec: - key - name type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. diff --git a/test/e2e/manifests/all-in-one-postgres-enterprise.yaml b/test/e2e/manifests/all-in-one-postgres-enterprise.yaml index afe7e9e9cc..0de6e06abc 100644 --- a/test/e2e/manifests/all-in-one-postgres-enterprise.yaml +++ b/test/e2e/manifests/all-in-one-postgres-enterprise.yaml @@ -142,6 +142,8 @@ spec: - name - namespace type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. @@ -358,7 +360,7 @@ spec: metadata: type: object status: - description: Status represents the current status of the KongConsumer + description: Status represents the current status of the KongConsumerGroup resource. properties: conditions: @@ -600,6 +602,8 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string + required: + - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id @@ -1054,6 +1058,8 @@ spec: - key - name type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. diff --git a/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml b/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml index a0a202e760..55214936a2 100644 --- a/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml +++ b/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml @@ -142,6 +142,8 @@ spec: - name - namespace type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. @@ -358,7 +360,7 @@ spec: metadata: type: object status: - description: Status represents the current status of the KongConsumer + description: Status represents the current status of the KongConsumerGroup resource. properties: conditions: @@ -600,6 +602,8 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string + required: + - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id @@ -1054,6 +1058,8 @@ spec: - key - name type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. diff --git a/test/e2e/manifests/all-in-one-postgres.yaml b/test/e2e/manifests/all-in-one-postgres.yaml index b510dcce5e..5a9d3ccd24 100644 --- a/test/e2e/manifests/all-in-one-postgres.yaml +++ b/test/e2e/manifests/all-in-one-postgres.yaml @@ -142,6 +142,8 @@ spec: - name - namespace type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. @@ -358,7 +360,7 @@ spec: metadata: type: object status: - description: Status represents the current status of the KongConsumer + description: Status represents the current status of the KongConsumerGroup resource. properties: conditions: @@ -600,6 +602,8 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string + required: + - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id @@ -1054,6 +1058,8 @@ spec: - key - name type: object + required: + - secretKeyRef type: object consumerRef: description: ConsumerRef is a reference to a particular consumer. From 350d71bfa2c165f21b42c6421e57bc977d1eae07 Mon Sep 17 00:00:00 2001 From: Yi Tao Date: Fri, 10 Nov 2023 11:30:30 +0800 Subject: [PATCH 3/3] add changelog and address comments --- CHANGELOG.md | 4 ++++ config/crd/bases/configuration.konghq.com_kongconsumers.yaml | 2 -- pkg/apis/configuration/v1/kongconsumer_types.go | 2 +- pkg/apis/configuration/v1beta1/ingress_rules.go | 4 ++++ test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml | 2 -- test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml | 2 -- test/e2e/manifests/all-in-one-dbless-konnect.yaml | 2 -- test/e2e/manifests/all-in-one-dbless.yaml | 2 -- test/e2e/manifests/all-in-one-postgres-enterprise.yaml | 2 -- test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml | 2 -- test/e2e/manifests/all-in-one-postgres.yaml | 2 -- 11 files changed, 9 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9d0812eb4..a3564ad0bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,10 @@ Adding a new version? You'll need three changes: ### Changed +- `SecretKeyRef` of `ConfigFrom` field in `KongPlugin` and `KongClusterPlugin` + are `Required`. When `ConfigFrom` is specified, the validation of there CRDs + will require `SecretKeyRef` to be present. + [#5103](https://github.com/Kong/kubernetes-ingress-controller/pull/5103) - CRD Validation Expressions - `KongPlugin` and `KongClusterPlugin` now enforce only one of `config` and `configFrom` to be set. diff --git a/config/crd/bases/configuration.konghq.com_kongconsumers.yaml b/config/crd/bases/configuration.konghq.com_kongconsumers.yaml index 65943be20c..02ac427eb2 100644 --- a/config/crd/bases/configuration.konghq.com_kongconsumers.yaml +++ b/config/crd/bases/configuration.konghq.com_kongconsumers.yaml @@ -151,8 +151,6 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string - required: - - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id diff --git a/pkg/apis/configuration/v1/kongconsumer_types.go b/pkg/apis/configuration/v1/kongconsumer_types.go index 9713eb6a21..036b3dcf1f 100644 --- a/pkg/apis/configuration/v1/kongconsumer_types.go +++ b/pkg/apis/configuration/v1/kongconsumer_types.go @@ -37,7 +37,7 @@ type KongConsumer struct { metav1.ObjectMeta `json:"metadata,omitempty"` // Username is a Kong cluster-unique username of the consumer. - Username string `json:"username"` + Username string `json:"username,omitempty"` // CustomID is a Kong cluster-unique existing ID for the consumer - useful for mapping // Kong with users in your existing database. diff --git a/pkg/apis/configuration/v1beta1/ingress_rules.go b/pkg/apis/configuration/v1beta1/ingress_rules.go index 87e5563a1c..22cdaf8e7d 100644 --- a/pkg/apis/configuration/v1beta1/ingress_rules.go +++ b/pkg/apis/configuration/v1beta1/ingress_rules.go @@ -32,6 +32,7 @@ type IngressRule struct { // Port is the port on which to accept TCP or TLS over TCP sessions and // route. It is a required field. If a Host is not specified, the requested // are routed based only on Port. + // +kubebuilder:validation:Required // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // +kubebuilder:validation:Format=int32 @@ -39,16 +40,19 @@ type IngressRule struct { // Backend defines the referenced service endpoint to which the traffic // will be forwarded to. + // +kubebuilder:validation:Required Backend IngressBackend `json:"backend"` } // IngressBackend describes all endpoints for a given service and port. type IngressBackend struct { // Specifies the name of the referenced service. + // +kubebuilder:validation:Required // +kubebuilder:validation:MinLength=1 ServiceName string `json:"serviceName"` // Specifies the port of the referenced service. + // +kubebuilder:validation:Required // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // +kubebuilder:validation:Format=int32 diff --git a/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml b/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml index d834312894..1aee4c809b 100644 --- a/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml +++ b/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml @@ -602,8 +602,6 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string - required: - - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id diff --git a/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml b/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml index e7764331b1..876e2558a6 100644 --- a/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml +++ b/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml @@ -602,8 +602,6 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string - required: - - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id diff --git a/test/e2e/manifests/all-in-one-dbless-konnect.yaml b/test/e2e/manifests/all-in-one-dbless-konnect.yaml index 08bc8d8ee6..a869f2e93d 100644 --- a/test/e2e/manifests/all-in-one-dbless-konnect.yaml +++ b/test/e2e/manifests/all-in-one-dbless-konnect.yaml @@ -602,8 +602,6 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string - required: - - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id diff --git a/test/e2e/manifests/all-in-one-dbless.yaml b/test/e2e/manifests/all-in-one-dbless.yaml index f3fd748f18..3e2abcbc49 100644 --- a/test/e2e/manifests/all-in-one-dbless.yaml +++ b/test/e2e/manifests/all-in-one-dbless.yaml @@ -602,8 +602,6 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string - required: - - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id diff --git a/test/e2e/manifests/all-in-one-postgres-enterprise.yaml b/test/e2e/manifests/all-in-one-postgres-enterprise.yaml index 0de6e06abc..2eda27af14 100644 --- a/test/e2e/manifests/all-in-one-postgres-enterprise.yaml +++ b/test/e2e/manifests/all-in-one-postgres-enterprise.yaml @@ -602,8 +602,6 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string - required: - - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id diff --git a/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml b/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml index 55214936a2..fa5bd7205b 100644 --- a/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml +++ b/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml @@ -602,8 +602,6 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string - required: - - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id diff --git a/test/e2e/manifests/all-in-one-postgres.yaml b/test/e2e/manifests/all-in-one-postgres.yaml index 5a9d3ccd24..22d86c82f9 100644 --- a/test/e2e/manifests/all-in-one-postgres.yaml +++ b/test/e2e/manifests/all-in-one-postgres.yaml @@ -602,8 +602,6 @@ spec: username: description: Username is a Kong cluster-unique username of the consumer. type: string - required: - - username type: object x-kubernetes-validations: - message: Need to provide either username or custom_id