Skip to content

Commit

Permalink
Merge pull request #1370 from Tharsanan1/fix-ratelimit-bug
Browse files Browse the repository at this point in the history
Add default value for api.organization and validation logic
  • Loading branch information
Tharsanan1 authored Jul 11, 2023
2 parents 73df4fe + d360a82 commit a9f2939
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions adapter/internal/operator/apis/dp/v1alpha1/api_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ func (r *API) validateAPI() error {
allErrs = append(allErrs, err)
}

// Organization value should not be empty as it required when applying ratelimit policy
if r.Spec.Organization == "" {
allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("organization"), "Organization can not be empty"))
}

if errMsg := validateAPITypeFormat(r.Spec.APIType); errMsg != "" {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("apiType"), r.Spec.APIType, errMsg))
} else {
Expand Down
1 change: 1 addition & 0 deletions helm-charts/crds/dp.wso2.com_apis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ spec:
description: Organization denotes the organization. related to the
API
type: string
default: super-user
production:
description: 'Production contains a list of references to HttpRoutes
of type HttpRoute. xref: https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go'
Expand Down

0 comments on commit a9f2939

Please sign in to comment.