Skip to content

Commit 8af8136

Browse files
committed
rough validation
regex's might need more work
1 parent 81e6368 commit 8af8136

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

pkg/apis/configuration/v1/types.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -600,27 +600,32 @@ type AccessControl struct {
600600

601601
// RateLimit defines a rate limit policy.
602602
type RateLimit struct {
603-
Rate string `json:"rate"`
604-
Key string `json:"key"`
605-
Delay *int `json:"delay"`
606-
NoDelay *bool `json:"noDelay"`
607-
Burst *int `json:"burst"`
608-
ZoneSize string `json:"zoneSize"`
609-
DryRun *bool `json:"dryRun"`
610-
LogLevel string `json:"logLevel"`
611-
RejectCode *int `json:"rejectCode"`
612-
Scale bool `json:"scale"`
613-
Condition *RateLimitCondition `json:"condition"`
614-
}
615-
616-
// TODO: add valition at CRD level
603+
Rate string `json:"rate"`
604+
Key string `json:"key"`
605+
Delay *int `json:"delay"`
606+
NoDelay *bool `json:"noDelay"`
607+
Burst *int `json:"burst"`
608+
ZoneSize string `json:"zoneSize"`
609+
DryRun *bool `json:"dryRun"`
610+
LogLevel string `json:"logLevel"`
611+
RejectCode *int `json:"rejectCode"`
612+
Scale bool `json:"scale"`
613+
// +kubebuilder:validation:Optional
614+
Condition *RateLimitCondition `json:"condition"`
615+
}
616+
617617
type RateLimitCondition struct {
618-
JWT JWTCondition `json:"jwt"`
619-
Default bool `json:"default"`
618+
JWT JWTCondition `json:"jwt"`
619+
// +kubebuilder:validation:Optional
620+
Default bool `json:"default"`
620621
}
621622

622623
type JWTCondition struct {
624+
// +kubebuilder:validation:Required
625+
// +kubebuilder:validation:Pattern=^([^$\s"'])*$
623626
Claim string `json:"claim"`
627+
// +kubebuilder:validation:Required
628+
// +kubebuilder:validation:Pattern=^([^$\s."'])*$
624629
Match string `json:"match"`
625630
}
626631

0 commit comments

Comments
 (0)