Skip to content

Commit b599659

Browse files
fix(consumer): add maxLength and pattern validations for KongConsumer and KongConsumerGroup (#3109)
1 parent 3fc1f70 commit b599659

23 files changed

+325
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464

6565
- Fix validation logic for dataplane ports in admission policy.
6666
[#3031](https://github.com/Kong/kong-operator/pull/3031)
67+
- Add maxLength and pattern validations for `KongConsumer` and `KongConsumerGroup` fields.
68+
[#3109](https://github.com/Kong/kong-operator/pull/3109)
6769
- Gateway: Sort Gateway/DataPlane status addresses deterministically with hostname-first priority.
6870
[#3110](https://github.com/Kong/kong-operator/pull/3110)
6971
- HybridGateway: Fixed the logic of translating `HTTPRoute` path matches to

api/configuration/v1/kongconsumer_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ type KongConsumer struct {
4444
metav1.ObjectMeta `json:"metadata,omitempty"`
4545

4646
// Username is a Kong cluster-unique username of the consumer.
47+
// +kubebuilder:validation:MaxLength=128
48+
// +kubebuilder:validation:Pattern=`^[\p{L}\p{N}.\-_~+@/\[\]]*(?: [\p{L}\p{N}.\-_~+@/\[\]]+)*$`
4749
Username string `json:"username,omitempty"`
4850

4951
// CustomID is a Kong cluster-unique existing ID for the consumer - useful for mapping
5052
// Kong with users in your existing database.
53+
// +kubebuilder:validation:MaxLength=128
54+
// +kubebuilder:validation:Pattern=`^[0-9a-zA-Z.\-_~\(\)#%@|+\[\]]*(?: [0-9a-zA-Z.\-_~\(\)#%@|+\[\]]+)*$`
5155
CustomID string `json:"custom_id,omitempty"`
5256

5357
// Credentials are references to secrets containing a credential to be

api/configuration/v1beta1/kongconsumergroup_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ type KongConsumerGroup struct {
5353
// +kubebuilder:validation:XValidation:rule="(has(oldSelf.adopt) && has(self.adopt)) || (!has(oldSelf.adopt) && !has(self.adopt))", message="Cannot set or unset spec.adopt in updates"
5454
type KongConsumerGroupSpec struct {
5555
// Name is the name of the ConsumerGroup in Kong.
56+
// +kubebuilder:validation:MaxLength=128
57+
// +kubebuilder:validation:Pattern=`^[\p{N}\p{L}.\-_~]*$`
5658
Name string `json:"name,omitempty"`
5759

5860
// ControlPlaneRef is a reference to a ControlPlane this ConsumerGroup is associated with.

charts/kong-operator/charts/ko-crds/templates/ko-crds.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50337,6 +50337,8 @@ spec:
5033750337
rule: '!has(self.type) ? !has(self.konnectNamespacedRef) : true'
5033850338
name:
5033950339
description: Name is the name of the ConsumerGroup in Kong.
50340+
maxLength: 128
50341+
pattern: ^[\p{N}\p{L}.\-_~]*$
5034050342
type: string
5034150343
tags:
5034250344
description: Tags is an optional set of tags applied to the ConsumerGroup.
@@ -50534,6 +50536,8 @@ spec:
5053450536
description: |-
5053550537
CustomID is a Kong cluster-unique existing ID for the consumer - useful for mapping
5053650538
Kong with users in your existing database.
50539+
maxLength: 128
50540+
pattern: '^[0-9a-zA-Z.\-_~\(\)#%@|+\[\]]*(?: [0-9a-zA-Z.\-_~\(\)#%@|+\[\]]+)*$'
5053750541
type: string
5053850542
kind:
5053950543
description: |-
@@ -50784,6 +50788,8 @@ spec:
5078450788
type: object
5078550789
username:
5078650790
description: Username is a Kong cluster-unique username of the consumer.
50791+
maxLength: 128
50792+
pattern: '^[\p{L}\p{N}.\-_~+@/\[\]]*(?: [\p{L}\p{N}.\-_~+@/\[\]]+)*$'
5078750793
type: string
5078850794
type: object
5078950795
x-kubernetes-validations:

charts/kong-operator/ci/__snapshots__/affinity-values.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/kong-operator/ci/__snapshots__/controlplane-config-dump.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/kong-operator/ci/__snapshots__/disable-gateway-controller-values.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/kong-operator/ci/__snapshots__/env-and-args-values.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/kong-operator/ci/__snapshots__/env-and-customenv-values.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/kong-operator/ci/__snapshots__/extra-labels-values.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)