From 7cedb27ebfbcb3885a6d875d8952a7d94caa4784 Mon Sep 17 00:00:00 2001 From: Pubudu Gunatilaka Date: Fri, 5 Apr 2024 11:32:15 +0530 Subject: [PATCH] Add enabled flag for the CORs policy --- .../apis/dp/v1alpha2/apipolicy_types.go | 7 +++++ .../crd/bases/dp.wso2.com_apipolicies.yaml | 8 +++++ helm-charts/crds/dp.wso2.com_apipolicies.yaml | 29 ++++++++++++------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/common-go-libs/apis/dp/v1alpha2/apipolicy_types.go b/common-go-libs/apis/dp/v1alpha2/apipolicy_types.go index 4bb4008a4..c92ad8bdc 100644 --- a/common-go-libs/apis/dp/v1alpha2/apipolicy_types.go +++ b/common-go-libs/apis/dp/v1alpha2/apipolicy_types.go @@ -71,6 +71,13 @@ type BackendJWTToken struct { // CORSPolicy holds CORS policy information type CORSPolicy struct { + + // Enabled is to enable CORs policy for the API. + // + // +kubebuilder:default=true + // +optional + Enabled bool `json:"enabled,omitempty"` + // AllowCredentials indicates whether the request can include user credentials like // cookies, HTTP authentication or client side SSL certificates. // diff --git a/common-go-libs/config/crd/bases/dp.wso2.com_apipolicies.yaml b/common-go-libs/config/crd/bases/dp.wso2.com_apipolicies.yaml index bf1f51a08..5465823df 100644 --- a/common-go-libs/config/crd/bases/dp.wso2.com_apipolicies.yaml +++ b/common-go-libs/config/crd/bases/dp.wso2.com_apipolicies.yaml @@ -320,6 +320,10 @@ spec: of a preflight request can be cached in a preflight result cache. type: integer + enabled: + default: true + description: Enabled is to enable CORs policy for the API. + type: boolean type: object requestInterceptors: description: RequestInterceptors referenced to intercetor services @@ -410,6 +414,10 @@ spec: of a preflight request can be cached in a preflight result cache. type: integer + enabled: + default: true + description: Enabled is to enable CORs policy for the API. + type: boolean type: object requestInterceptors: description: RequestInterceptors referenced to intercetor services diff --git a/helm-charts/crds/dp.wso2.com_apipolicies.yaml b/helm-charts/crds/dp.wso2.com_apipolicies.yaml index d05fe5fd6..5465823df 100644 --- a/helm-charts/crds/dp.wso2.com_apipolicies.yaml +++ b/helm-charts/crds/dp.wso2.com_apipolicies.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.12.0 name: apipolicies.dp.wso2.com spec: group: dp.wso2.com @@ -207,10 +206,11 @@ spec: type: object targetRef: description: PolicyTargetReference identifies an API object to apply - policy to. This should be used as part of Policy resources that - can target Gateway API resources. For more information on how this - policy attachment model works, and a sample Policy resource, refer - to the policy attachment documentation for Gateway API. + a direct or inherited policy to. This should be used as part of + Policy resources that can target Gateway API resources. For more + information on how this policy attachment model works, and a sample + Policy resource, refer to the policy attachment documentation for + Gateway API. properties: group: description: Group is the group of the target resource. @@ -320,6 +320,10 @@ spec: of a preflight request can be cached in a preflight result cache. type: integer + enabled: + default: true + description: Enabled is to enable CORs policy for the API. + type: boolean type: object requestInterceptors: description: RequestInterceptors referenced to intercetor services @@ -410,6 +414,10 @@ spec: of a preflight request can be cached in a preflight result cache. type: integer + enabled: + default: true + description: Enabled is to enable CORs policy for the API. + type: boolean type: object requestInterceptors: description: RequestInterceptors referenced to intercetor services @@ -453,10 +461,11 @@ spec: type: object targetRef: description: PolicyTargetReference identifies an API object to apply - policy to. This should be used as part of Policy resources that - can target Gateway API resources. For more information on how this - policy attachment model works, and a sample Policy resource, refer - to the policy attachment documentation for Gateway API. + a direct or inherited policy to. This should be used as part of + Policy resources that can target Gateway API resources. For more + information on how this policy attachment model works, and a sample + Policy resource, refer to the policy attachment documentation for + Gateway API. properties: group: description: Group is the group of the target resource.