Skip to content

Commit

Permalink
fix: remove plan bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
jspdown authored Nov 13, 2024
1 parent aac37e9 commit 81f9d76
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 49 deletions.
18 changes: 0 additions & 18 deletions pkg/apis/hub/v1alpha1/api_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ type APIPlanStatus struct {
Hash string `json:"hash,omitempty"`
}

// Bucket defines the scope of rate limit or quota.
// +kubebuilder:validation:Enum=user;access
type Bucket string

// List of supported buckets.
const (
BucketUser Bucket = "user"
BucketAccess Bucket = "access"
)

type RateLimit struct {
// Limit is the maximum number of token in the bucket.
// +kubebuilder:validation:XValidation:message="must be a positive number",rule="self >= 0"
Expand All @@ -83,10 +73,6 @@ type RateLimit struct {
// +optional
// +kubebuilder:validation:XValidation:message="must be between 1s and 1h",rule="self >= duration('1s') && self <= duration('1h')"
Period *Period `json:"period,omitempty"`

// Bucket defines the scope of the rate limit.
// +optional
Bucket Bucket `json:"bucket,omitempty"`
}

type Quota struct {
Expand All @@ -98,10 +84,6 @@ type Quota struct {
// +optional
// +kubebuilder:validation:XValidation:message="must be between 1s and 9999h",rule="self >= duration('1s') && self <= duration('9999h')"
Period *Period `json:"period,omitempty"`

// Bucket defines the scope of the quota.
// +optional
Bucket Bucket `json:"bucket,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
12 changes: 0 additions & 12 deletions pkg/apis/hub/v1alpha1/crd/hub.traefik.io_apiplans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ spec:
quota:
description: Quota defines the quota policy.
properties:
bucket:
description: Bucket defines the scope of the quota.
enum:
- user
- access
type: string
limit:
description: Limit is the maximum number of token in the bucket.
type: integer
Expand All @@ -70,12 +64,6 @@ spec:
rateLimit:
description: RateLimit defines the rate limit policy.
properties:
bucket:
description: Bucket defines the scope of the rate limit.
enum:
- user
- access
type: string
limit:
description: Limit is the maximum number of token in the bucket.
type: integer
Expand Down
20 changes: 1 addition & 19 deletions pkg/validation/v1alpha1/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ spec:
rateLimit:
limit: 1
period: 2s
bucket: user
quota:
limit: 1
period: 2s
bucket: access`),
period: 2s`),
},
{
desc: "missing resource namespace",
Expand Down Expand Up @@ -219,22 +217,6 @@ spec:
period: 0s`),
wantErrs: field.ErrorList{{Type: field.ErrorTypeInvalid, Field: "spec.rateLimit.period", BadValue: "string", Detail: "must be between 1s and 1h"}},
},
{
desc: "unsupported ratelimit bucket",
manifest: []byte(`
apiVersion: hub.traefik.io/v1alpha1
kind: APIPlan
metadata:
name: my-plan
namespace: default
spec:
title: my-plan
rateLimit:
limit: 1
period: 1s
bucket: something`),
wantErrs: field.ErrorList{{Type: field.ErrorTypeNotSupported, Field: "spec.rateLimit.bucket", BadValue: "something", Detail: "supported values: \"user\", \"access\""}},
},
}

for _, test := range tests {
Expand Down

0 comments on commit 81f9d76

Please sign in to comment.