Skip to content

Commit

Permalink
IMPROVE: validation
Browse files Browse the repository at this point in the history
Ensure the user can create a ratelimit policy without at least one limit.

Signed-off-by: Jim Fitzpatrick <[email protected]>
  • Loading branch information
Boomatang committed Nov 14, 2024
1 parent fe39f7f commit 388af1f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion api/v1/ratelimitpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ type RateLimitPolicySpecProper struct {
MergeableWhenPredicates `json:""`

// Limits holds the struct of limits indexed by a unique name
// +optional
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinProperties=1
Limits map[string]Limit `json:"limits,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/kuadrant/kuadrant-operator:latest
createdAt: "2024-11-13T16:31:14Z"
createdAt: "2024-11-14T16:40:13Z"
description: A Kubernetes Operator to manage the lifecycle of the Kuadrant system
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down
8 changes: 8 additions & 0 deletions bundle/manifests/kuadrant.io_ratelimitpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ spec:
type: object
description: Limits holds the struct of limits indexed by a unique
name
minProperties: 1
type: object
strategy:
default: atomic
Expand All @@ -163,6 +164,8 @@ spec:
- predicate
type: object
type: array
required:
- limits
type: object
limits:
additionalProperties:
Expand Down Expand Up @@ -225,6 +228,7 @@ spec:
type: object
description: Limits holds the struct of limits indexed by a unique
name
minProperties: 1
type: object
overrides:
description: |-
Expand Down Expand Up @@ -293,6 +297,7 @@ spec:
type: object
description: Limits holds the struct of limits indexed by a unique
name
minProperties: 1
type: object
strategy:
default: atomic
Expand All @@ -318,6 +323,8 @@ spec:
- predicate
type: object
type: array
required:
- limits
type: object
targetRef:
description: Reference to the object to which this policy applies.
Expand Down Expand Up @@ -383,6 +390,7 @@ spec:
type: object
type: array
required:
- limits
- targetRef
type: object
x-kubernetes-validations:
Expand Down
8 changes: 8 additions & 0 deletions charts/kuadrant-operator/templates/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7740,6 +7740,7 @@ spec:
type: object
description: Limits holds the struct of limits indexed by a unique
name
minProperties: 1
type: object
strategy:
default: atomic
Expand All @@ -7765,6 +7766,8 @@ spec:
- predicate
type: object
type: array
required:
- limits
type: object
limits:
additionalProperties:
Expand Down Expand Up @@ -7827,6 +7830,7 @@ spec:
type: object
description: Limits holds the struct of limits indexed by a unique
name
minProperties: 1
type: object
overrides:
description: |-
Expand Down Expand Up @@ -7895,6 +7899,7 @@ spec:
type: object
description: Limits holds the struct of limits indexed by a unique
name
minProperties: 1
type: object
strategy:
default: atomic
Expand All @@ -7920,6 +7925,8 @@ spec:
- predicate
type: object
type: array
required:
- limits
type: object
targetRef:
description: Reference to the object to which this policy applies.
Expand Down Expand Up @@ -7985,6 +7992,7 @@ spec:
type: object
type: array
required:
- limits
- targetRef
type: object
x-kubernetes-validations:
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/kuadrant.io_ratelimitpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ spec:
type: object
description: Limits holds the struct of limits indexed by a unique
name
minProperties: 1
type: object
strategy:
default: atomic
Expand All @@ -162,6 +163,8 @@ spec:
- predicate
type: object
type: array
required:
- limits
type: object
limits:
additionalProperties:
Expand Down Expand Up @@ -224,6 +227,7 @@ spec:
type: object
description: Limits holds the struct of limits indexed by a unique
name
minProperties: 1
type: object
overrides:
description: |-
Expand Down Expand Up @@ -292,6 +296,7 @@ spec:
type: object
description: Limits holds the struct of limits indexed by a unique
name
minProperties: 1
type: object
strategy:
default: atomic
Expand All @@ -317,6 +322,8 @@ spec:
- predicate
type: object
type: array
required:
- limits
type: object
targetRef:
description: Reference to the object to which this policy applies.
Expand Down Expand Up @@ -382,6 +389,7 @@ spec:
type: object
type: array
required:
- limits
- targetRef
type: object
x-kubernetes-validations:
Expand Down

0 comments on commit 388af1f

Please sign in to comment.