From 5972452ea35c88a811db4ce2d5f77f75ba52783a Mon Sep 17 00:00:00 2001 From: Yi Tao Date: Tue, 7 Nov 2023 18:00:43 +0800 Subject: [PATCH] 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 90283f9062..07b39fb7da 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 4e407f191b..d1898d2ef7 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 served: true storage: true diff --git a/config/crd/bases/configuration.konghq.com_kongplugins.yaml b/config/crd/bases/configuration.konghq.com_kongplugins.yaml index 68872e4e2b..2b6a43af9f 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 94e1058ae6..2a1d60c95b 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 @@ -64,7 +63,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 eb36e3f58a..06529bc6ec 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` @@ -37,7 +36,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 886f8480e1..10eee7bdd9 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 @@ -64,7 +63,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"