diff --git a/adapter/go.mod b/adapter/go.mod index eeb7f4350..33326670b 100644 --- a/adapter/go.mod +++ b/adapter/go.mod @@ -12,7 +12,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/prometheus/client_golang v1.18.0 github.com/sirupsen/logrus v1.9.0 - github.com/wso2/apk/common-go-libs v0.0.0-20231208100153-24bee7b4bd81 + github.com/wso2/apk/common-go-libs v0.0.0-20240911043600-b84cd52d2bd3 golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.34.1 diff --git a/adapter/internal/oasparser/envoyconf/internal_dtos.go b/adapter/internal/oasparser/envoyconf/internal_dtos.go index 5ecb0b93e..df4b3b0ab 100644 --- a/adapter/internal/oasparser/envoyconf/internal_dtos.go +++ b/adapter/internal/oasparser/envoyconf/internal_dtos.go @@ -19,7 +19,7 @@ package envoyconf import ( "github.com/wso2/apk/adapter/internal/oasparser/model" - "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" + "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" ) // routeCreateParams is the DTO used to provide information to the envoy route create function @@ -41,7 +41,7 @@ type routeCreateParams struct { isDefaultVersion bool createDefaultPath bool apiLevelRateLimitPolicy *model.RateLimitPolicy - apiProperties []v1beta1.Property + apiProperties []v1alpha3.Property environment string envType string mirrorClusterNames map[string][]string diff --git a/adapter/internal/oasparser/envoyconf/routes_with_clusters.go b/adapter/internal/oasparser/envoyconf/routes_with_clusters.go index e52d77fac..daab77b18 100644 --- a/adapter/internal/oasparser/envoyconf/routes_with_clusters.go +++ b/adapter/internal/oasparser/envoyconf/routes_with_clusters.go @@ -52,7 +52,7 @@ import ( logging "github.com/wso2/apk/adapter/internal/logging" "github.com/wso2/apk/adapter/internal/oasparser/constants" "github.com/wso2/apk/adapter/internal/oasparser/model" - "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" + "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" "google.golang.org/protobuf/proto" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" ) @@ -1610,7 +1610,7 @@ func getUpgradeConfig(apiType string) []*routev3.RouteAction_UpgradeConfig { return upgradeConfig } -func getAPIProperties(apiPropertiesConfig []v1beta1.Property) string { +func getAPIProperties(apiPropertiesConfig []v1alpha3.Property) string { var apiProperties = make(map[string]string) for _, val := range apiPropertiesConfig { apiProperties[val.Name] = val.Value diff --git a/adapter/internal/oasparser/envoyconf/routes_with_clusters_test.go b/adapter/internal/oasparser/envoyconf/routes_with_clusters_test.go index 5a8ca8659..f813221e0 100644 --- a/adapter/internal/oasparser/envoyconf/routes_with_clusters_test.go +++ b/adapter/internal/oasparser/envoyconf/routes_with_clusters_test.go @@ -31,7 +31,7 @@ import ( operatorutils "github.com/wso2/apk/adapter/internal/operator/utils" "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" - "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" + "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8types "k8s.io/apimachinery/pkg/types" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" @@ -39,16 +39,16 @@ import ( func TestCreateRoutesWithClustersWithExactAndRegularExpressionRules(t *testing.T) { apiState := synchronizer.APIState{} - apiDefinition := v1beta1.API{ + apiDefinition := v1alpha3.API{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test-api-2", }, - Spec: v1beta1.APISpec{ + Spec: v1alpha3.APISpec{ APIName: "test-api-2", APIVersion: "2.0.0", BasePath: "/test-api/2.0.0", - Production: []v1beta1.EnvConfig{ + Production: []v1alpha3.EnvConfig{ { RouteRefs: []string{ "test-api-2-prod-http-route", @@ -211,16 +211,16 @@ func TestExtractAPIDetailsFromHTTPRouteForSpecificEnvironment(t *testing.T) { func generateSampleAPI(apiName string, apiVersion string, basePath string) synchronizer.APIState { apiState := synchronizer.APIState{} - apiDefinition := v1beta1.API{ + apiDefinition := v1alpha3.API{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: apiName, }, - Spec: v1beta1.APISpec{ + Spec: v1alpha3.APISpec{ APIName: apiName, APIVersion: apiVersion, BasePath: basePath, - Production: []v1beta1.EnvConfig{ + Production: []v1alpha3.EnvConfig{ { RouteRefs: []string{ apiName + "-prod-http-route", @@ -274,16 +274,16 @@ func generateSampleAPI(apiName string, apiVersion string, basePath string) synch // TODO: Fix this test case func TestCreateRoutesWithClustersWithMultiplePathPrefixRules(t *testing.T) { apiState := synchronizer.APIState{} - apiDefinition := v1beta1.API{ + apiDefinition := v1alpha3.API{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test-api-1", }, - Spec: v1beta1.APISpec{ + Spec: v1alpha3.APISpec{ APIName: "test-api", APIVersion: "1.0.0", BasePath: "/test-api/1.0.0", - Production: []v1beta1.EnvConfig{ + Production: []v1alpha3.EnvConfig{ { RouteRefs: []string{ "test-api-1-prod-http-route", @@ -423,16 +423,16 @@ func TestCreateRoutesWithClustersWithMultiplePathPrefixRules(t *testing.T) { func TestCreateRoutesWithClustersWithBackendTLSConfigs(t *testing.T) { apiState := synchronizer.APIState{} - apiDefinition := v1beta1.API{ + apiDefinition := v1alpha3.API{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test-api-3", }, - Spec: v1beta1.APISpec{ + Spec: v1alpha3.APISpec{ APIName: "test-api-3", APIVersion: "1.0.0", BasePath: "/test-api-3/1.0.0", - Production: []v1beta1.EnvConfig{ + Production: []v1alpha3.EnvConfig{ { RouteRefs: []string{ "test-api-3-prod-http-route", @@ -546,16 +546,16 @@ func TestCreateHealthEndpoint(t *testing.T) { func TestCreateRoutesWithClustersDifferentBackendRefs(t *testing.T) { apiState := synchronizer.APIState{} - apiDefinition := v1beta1.API{ + apiDefinition := v1alpha3.API{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test-api-different-backendrefs", }, - Spec: v1beta1.APISpec{ + Spec: v1alpha3.APISpec{ APIName: "test-api-different-backendrefs", APIVersion: "1.0.0", BasePath: "/test-api-different-backendrefs/1.0.0", - Production: []v1beta1.EnvConfig{ + Production: []v1alpha3.EnvConfig{ { RouteRefs: []string{ "test-api-different-backendrefs-prod-http-route", @@ -638,16 +638,16 @@ func TestCreateRoutesWithClustersDifferentBackendRefs(t *testing.T) { func TestCreateRoutesWithClustersSameBackendRefs(t *testing.T) { apiState := synchronizer.APIState{} - apiDefinition := v1beta1.API{ + apiDefinition := v1alpha3.API{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test-api-same-backendrefs", }, - Spec: v1beta1.APISpec{ + Spec: v1alpha3.APISpec{ APIName: "test-api-same-backendrefs", APIVersion: "1.0.0", BasePath: "/test-api-same-backendrefs/1.0.0", - Production: []v1beta1.EnvConfig{ + Production: []v1alpha3.EnvConfig{ { RouteRefs: []string{ "test-api-same-backendrefs-prod-http-route", diff --git a/adapter/internal/oasparser/model/adapter_internal_api.go b/adapter/internal/oasparser/model/adapter_internal_api.go index f5278b3c4..136422997 100644 --- a/adapter/internal/oasparser/model/adapter_internal_api.go +++ b/adapter/internal/oasparser/model/adapter_internal_api.go @@ -34,7 +34,6 @@ import ( dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" dpv1alpha3 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" - dpv1beta1 "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" "golang.org/x/exp/maps" "k8s.io/apimachinery/pkg/types" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" @@ -74,7 +73,7 @@ type AdapterInternalAPI struct { apiDefinitionFile []byte apiDefinitionEndpoint string subscriptionValidation bool - APIProperties []dpv1beta1.Property + APIProperties []dpv1alpha3.Property // GraphQLSchema string // GraphQLComplexities GraphQLComplexityYaml IsSystemAPI bool @@ -1308,10 +1307,18 @@ func (adapterInternalAPI *AdapterInternalAPI) SetInfoGRPCRouteCR(grpcRoute *gwap adapterInternalAPI.disableAuthentications = *authScheme.Spec.Override.Disabled } authSpec := utils.SelectPolicy(&authScheme.Spec.Override, &authScheme.Spec.Default, nil, nil) - if authSpec != nil && authSpec.AuthTypes != nil && authSpec.AuthTypes.Oauth2.Required != "" { - adapterInternalAPI.SetXWSO2ApplicationSecurity(authSpec.AuthTypes.Oauth2.Required == "mandatory") + if authSpec != nil && authSpec.AuthTypes != nil { + if authSpec.AuthTypes.OAuth2.Required != "" { + adapterInternalAPI.SetApplicationSecurity(constants.OAuth2, authSpec.AuthTypes.OAuth2.Required == "mandatory") + } else { + adapterInternalAPI.SetApplicationSecurity(constants.OAuth2, true) + } + + if authSpec.AuthTypes.APIKey != nil { + adapterInternalAPI.SetApplicationSecurity(constants.APIKey, authSpec.AuthTypes.APIKey.Required == "mandatory") + } } else { - adapterInternalAPI.SetXWSO2ApplicationSecurity(true) + adapterInternalAPI.SetApplicationSecurity(constants.OAuth2, true) } adapterInternalAPI.disableScopes = disableScopes // Check whether the API has a backend JWT token diff --git a/adapter/internal/oasparser/model/http_route.go b/adapter/internal/oasparser/model/http_route.go index 081ed2a00..6092dd66b 100644 --- a/adapter/internal/oasparser/model/http_route.go +++ b/adapter/internal/oasparser/model/http_route.go @@ -25,7 +25,6 @@ import ( dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" dpv1alpha3 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" - "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" "k8s.io/apimachinery/pkg/types" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" ) @@ -311,7 +310,7 @@ func getAllowedOperations(httpMethod *gwapiv1.HTTPMethod, policies OperationPoli } // SetInfoAPICR populates ID, ApiType, Version and XWso2BasePath of adapterInternalAPI. -func (swagger *AdapterInternalAPI) SetInfoAPICR(api v1beta1.API) { +func (swagger *AdapterInternalAPI) SetInfoAPICR(api dpv1alpha3.API) { swagger.UUID = string(api.ObjectMeta.UID) swagger.title = api.Spec.APIName swagger.apiType = api.Spec.APIType diff --git a/adapter/internal/operator/config/crd/bases/dp.wso2.com_apis.yaml b/adapter/internal/operator/config/crd/bases/dp.wso2.com_apis.yaml index 1fa8ea672..d3bd7331b 100644 --- a/adapter/internal/operator/config/crd/bases/dp.wso2.com_apis.yaml +++ b/adapter/internal/operator/config/crd/bases/dp.wso2.com_apis.yaml @@ -379,7 +379,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1beta1 + name: v1alpha3 schema: openAPIV3Schema: description: API is the Schema for the apis API diff --git a/adapter/internal/operator/config/webhook/manifests.yaml b/adapter/internal/operator/config/webhook/manifests.yaml index 54cbdd40d..b13c9e7c4 100644 --- a/adapter/internal/operator/config/webhook/manifests.yaml +++ b/adapter/internal/operator/config/webhook/manifests.yaml @@ -24,6 +24,26 @@ webhooks: resources: - apis sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-dp-wso2-com-v1alpha3-api + failurePolicy: Fail + name: mapi.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - apis + sideEffects: None - admissionReviewVersions: - v1 clientConfig: @@ -230,6 +250,26 @@ webhooks: resources: - apis sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-dp-wso2-com-v1alpha3-api + failurePolicy: Fail + name: vapi.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - apis + sideEffects: None - admissionReviewVersions: - v1 clientConfig: diff --git a/adapter/internal/operator/controllers/dp/api_controller.go b/adapter/internal/operator/controllers/dp/api_controller.go index 14ece13ae..98b08ff68 100644 --- a/adapter/internal/operator/controllers/dp/api_controller.go +++ b/adapter/internal/operator/controllers/dp/api_controller.go @@ -60,10 +60,8 @@ import ( gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" - "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" dpv1alpha3 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" - dpv1beta1 "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -121,7 +119,7 @@ type APIReconciler struct { apiPropagationEnabled bool } -// NewAPIController creates a new API controller instance. API Controllers watches for dpv1beta1.API and gwapiv1.HTTPRoute. +// NewAPIController creates a new API controller instance. API Controllers watches for dpv1alpha3.API and gwapiv1.HTTPRoute. func NewAPIController(mgr manager.Manager, operatorDataStore *synchronizer.OperatorDataStore, statusUpdater *status.UpdateHandler, ch *chan *synchronizer.APIEvent, successChannel *chan synchronizer.SuccessEvent) error { apiReconciler := &APIReconciler{ @@ -143,7 +141,7 @@ func NewAPIController(mgr manager.Manager, operatorDataStore *synchronizer.Opera apiReconciler.apiPropagationEnabled = conf.Adapter.ControlPlane.EnableAPIPropagation predicates := []predicate.Predicate{predicate.NewPredicateFuncs(utils.FilterByNamespaces(conf.Adapter.Operator.Namespaces))} - if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1beta1.API{}), &handler.EnqueueRequestForObject{}, + if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1alpha3.API{}), &handler.EnqueueRequestForObject{}, predicates...); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2611, logging.BLOCKER, "Error watching API resources: %v", err)) return err @@ -277,7 +275,7 @@ func (apiReconciler *APIReconciler) Reconcile(ctx context.Context, req ctrl.Requ applyAllAPIsOnce.Do(apiReconciler.applyStartupAPIs) loggers.LoggerAPKOperator.Infof("Reconciling for API %s", req.NamespacedName.String()) // Check whether the API CR exist, if not consider as a DELETE event. - var apiCR dpv1beta1.API + var apiCR dpv1alpha3.API if err := apiReconciler.client.Get(ctx, req.NamespacedName, &apiCR); err != nil { apiState, found := apiReconciler.ods.GetCachedAPI(req.NamespacedName) if found && k8error.IsNotFound(err) { @@ -344,7 +342,7 @@ func (apiReconciler *APIReconciler) applyStartupAPIs() { // resolveAPIRefs validates following references related to the API // - HTTPRoutes -func (apiReconciler *APIReconciler) resolveAPIRefs(ctx context.Context, api dpv1beta1.API) (*synchronizer.APIEvent, error) { +func (apiReconciler *APIReconciler) resolveAPIRefs(ctx context.Context, api dpv1alpha3.API) (*synchronizer.APIEvent, error) { var prodRouteRefs, sandRouteRefs []string if len(api.Spec.Production) > 0 { prodRouteRefs = api.Spec.Production[0].RouteRefs @@ -564,7 +562,7 @@ func isAPIPropagatable(apiState *synchronizer.APIState) bool { } func (apiReconciler *APIReconciler) resolveGQLRouteRefs(ctx context.Context, gqlRouteRefs []string, - namespace string, api dpv1beta1.API) (*synchronizer.GQLRouteState, error) { + namespace string, api dpv1alpha3.API) (*synchronizer.GQLRouteState, error) { gqlRouteState, err := apiReconciler.concatGQLRoutes(ctx, gqlRouteRefs, namespace, api) if err != nil { return nil, err @@ -577,7 +575,7 @@ func (apiReconciler *APIReconciler) resolveGQLRouteRefs(ctx context.Context, gql // - Authentications func (apiReconciler *APIReconciler) resolveHTTPRouteRefs(ctx context.Context, httpRouteState *synchronizer.HTTPRouteState, httpRouteRefs []string, namespace string, interceptorServiceMapping map[string]dpv1alpha1.InterceptorService, - api dpv1beta1.API) (*synchronizer.HTTPRouteState, error) { + api dpv1alpha3.API) (*synchronizer.HTTPRouteState, error) { var err error httpRouteState.HTTPRouteCombined, httpRouteState.HTTPRoutePartitions, err = apiReconciler.concatHTTPRoutes(ctx, httpRouteRefs, namespace, api) if err != nil { @@ -593,7 +591,7 @@ func (apiReconciler *APIReconciler) resolveHTTPRouteRefs(ctx context.Context, ht } func (apiReconciler *APIReconciler) resolveGRPCRouteRefs(ctx context.Context, grpcRouteRefs []string, - namespace string, api dpv1beta1.API) (*synchronizer.GRPCRouteState, error) { + namespace string, api dpv1alpha3.API) (*synchronizer.GRPCRouteState, error) { grpcRouteState, err := apiReconciler.concatGRPCRoutes(ctx, grpcRouteRefs, namespace, api) if err != nil { return nil, err @@ -603,7 +601,7 @@ func (apiReconciler *APIReconciler) resolveGRPCRouteRefs(ctx context.Context, gr } func (apiReconciler *APIReconciler) concatGRPCRoutes(ctx context.Context, grpcRouteRefs []string, - namespace string, api dpv1beta1.API) (synchronizer.GRPCRouteState, error) { + namespace string, api dpv1alpha3.API) (synchronizer.GRPCRouteState, error) { grpcRouteState := synchronizer.GRPCRouteState{} grpcRoutePartitions := make(map[string]*gwapiv1a2.GRPCRoute) for _, grpcRouteRef := range grpcRouteRefs { @@ -638,7 +636,7 @@ func (apiReconciler *APIReconciler) concatGRPCRoutes(ctx context.Context, grpcRo } func (apiReconciler *APIReconciler) concatGQLRoutes(ctx context.Context, gqlRouteRefs []string, - namespace string, api dpv1beta1.API) (synchronizer.GQLRouteState, error) { + namespace string, api dpv1alpha3.API) (synchronizer.GQLRouteState, error) { gqlRouteState := synchronizer.GQLRouteState{} gqlRoutePartitions := make(map[string]*dpv1alpha2.GQLRoute) for _, gqlRouteRef := range gqlRouteRefs { @@ -672,7 +670,7 @@ func (apiReconciler *APIReconciler) concatGQLRoutes(ctx context.Context, gqlRout } func (apiReconciler *APIReconciler) getScopesForGRPCRoute(ctx context.Context, - grpcRoute *gwapiv1a2.GRPCRoute, api dpv1beta1.API) (map[string]dpv1alpha1.Scope, error) { + grpcRoute *gwapiv1a2.GRPCRoute, api dpv1alpha3.API) (map[string]dpv1alpha1.Scope, error) { scopes := make(map[string]dpv1alpha1.Scope) for _, rule := range grpcRoute.Spec.Rules { for _, filter := range rule.Filters { @@ -692,7 +690,7 @@ func (apiReconciler *APIReconciler) getScopesForGRPCRoute(ctx context.Context, } func (apiReconciler *APIReconciler) concatHTTPRoutes(ctx context.Context, httpRouteRefs []string, - namespace string, api dpv1beta1.API) (*gwapiv1.HTTPRoute, map[string]*gwapiv1.HTTPRoute, error) { + namespace string, api dpv1alpha3.API) (*gwapiv1.HTTPRoute, map[string]*gwapiv1.HTTPRoute, error) { var combinedHTTPRoute *gwapiv1.HTTPRoute httpRoutePartitions := make(map[string]*gwapiv1.HTTPRoute) for _, httpRouteRef := range httpRouteRefs { @@ -713,7 +711,7 @@ func (apiReconciler *APIReconciler) concatHTTPRoutes(ctx context.Context, httpRo } func (apiReconciler *APIReconciler) getAuthenticationsForAPI(ctx context.Context, - api dpv1beta1.API) (map[string]dpv1alpha2.Authentication, error) { + api dpv1alpha3.API) (map[string]dpv1alpha2.Authentication, error) { nameSpacedName := utils.NamespacedName(&api).String() authentications := make(map[string]dpv1alpha2.Authentication) authenticationList := &dpv1alpha2.AuthenticationList{} @@ -730,7 +728,7 @@ func (apiReconciler *APIReconciler) getAuthenticationsForAPI(ctx context.Context } func (apiReconciler *APIReconciler) getRatelimitPoliciesForAPI(ctx context.Context, - api dpv1beta1.API) (map[string]dpv1alpha3.RateLimitPolicy, error) { + api dpv1alpha3.API) (map[string]dpv1alpha3.RateLimitPolicy, error) { nameSpacedName := utils.NamespacedName(&api).String() ratelimitPolicies := make(map[string]dpv1alpha3.RateLimitPolicy) ratelimitPolicyList := &dpv1alpha3.RateLimitPolicyList{} @@ -747,7 +745,7 @@ func (apiReconciler *APIReconciler) getRatelimitPoliciesForAPI(ctx context.Conte } func (apiReconciler *APIReconciler) getScopesForGQLRoute(ctx context.Context, - gqlRoute *dpv1alpha2.GQLRoute, api dpv1beta1.API) (map[string]dpv1alpha1.Scope, error) { + gqlRoute *dpv1alpha2.GQLRoute, api dpv1alpha3.API) (map[string]dpv1alpha1.Scope, error) { scopes := make(map[string]dpv1alpha1.Scope) for _, rule := range gqlRoute.Spec.Rules { for _, filter := range rule.Filters { @@ -767,7 +765,7 @@ func (apiReconciler *APIReconciler) getScopesForGQLRoute(ctx context.Context, } func (apiReconciler *APIReconciler) getScopesForHTTPRoute(ctx context.Context, - httpRoute *gwapiv1.HTTPRoute, api dpv1beta1.API) (map[string]dpv1alpha1.Scope, error) { + httpRoute *gwapiv1.HTTPRoute, api dpv1alpha3.API) (map[string]dpv1alpha1.Scope, error) { scopes := make(map[string]dpv1alpha1.Scope) for _, rule := range httpRoute.Spec.Rules { for _, filter := range rule.Filters { @@ -789,7 +787,7 @@ func (apiReconciler *APIReconciler) getScopesForHTTPRoute(ctx context.Context, } func (apiReconciler *APIReconciler) getAuthenticationsForResources(ctx context.Context, - api dpv1beta1.API) (map[string]dpv1alpha2.Authentication, error) { + api dpv1alpha3.API) (map[string]dpv1alpha2.Authentication, error) { nameSpacedName := utils.NamespacedName(&api).String() authentications := make(map[string]dpv1alpha2.Authentication) authenticationList := &dpv1alpha2.AuthenticationList{} @@ -806,7 +804,7 @@ func (apiReconciler *APIReconciler) getAuthenticationsForResources(ctx context.C } func (apiReconciler *APIReconciler) getRatelimitPoliciesForResources(ctx context.Context, - api dpv1beta1.API) (map[string]dpv1alpha3.RateLimitPolicy, error) { + api dpv1alpha3.API) (map[string]dpv1alpha3.RateLimitPolicy, error) { nameSpacedName := utils.NamespacedName(&api).String() ratelimitpolicies := make(map[string]dpv1alpha3.RateLimitPolicy) ratelimitPolicyList := &dpv1alpha3.RateLimitPolicyList{} @@ -822,7 +820,7 @@ func (apiReconciler *APIReconciler) getRatelimitPoliciesForResources(ctx context return ratelimitpolicies, nil } -func (apiReconciler *APIReconciler) getAPIPoliciesForAPI(ctx context.Context, api dpv1beta1.API) (map[string]dpv1alpha3.APIPolicy, error) { +func (apiReconciler *APIReconciler) getAPIPoliciesForAPI(ctx context.Context, api dpv1alpha3.API) (map[string]dpv1alpha3.APIPolicy, error) { nameSpacedName := utils.NamespacedName(&api).String() apiPolicies := make(map[string]dpv1alpha3.APIPolicy) apiPolicyList := &dpv1alpha3.APIPolicyList{} @@ -840,7 +838,7 @@ func (apiReconciler *APIReconciler) getAPIPoliciesForAPI(ctx context.Context, ap } func (apiReconciler *APIReconciler) getAPIDefinitionForAPI(ctx context.Context, - apiDefinitionFile, namespace string, api dpv1beta1.API) ([]byte, error) { + apiDefinitionFile, namespace string, api dpv1alpha3.API) ([]byte, error) { configMap := &corev1.ConfigMap{} if err := utils.ResolveRef(ctx, apiReconciler.client, &api, types.NamespacedName{Namespace: namespace, Name: apiDefinitionFile}, true, configMap); err != nil { @@ -857,7 +855,7 @@ func (apiReconciler *APIReconciler) getAPIDefinitionForAPI(ctx context.Context, } func (apiReconciler *APIReconciler) getAPIPoliciesForResources(ctx context.Context, - api dpv1beta1.API) (map[string]dpv1alpha3.APIPolicy, error) { + api dpv1alpha3.API) (map[string]dpv1alpha3.APIPolicy, error) { nameSpacedName := utils.NamespacedName(&api).String() apiPolicies := make(map[string]dpv1alpha3.APIPolicy) apiPolicyList := &dpv1alpha3.APIPolicyList{} @@ -879,7 +877,7 @@ func (apiReconciler *APIReconciler) getAPIPoliciesForResources(ctx context.Conte // - subscription validation func (apiReconciler *APIReconciler) getAPIPolicyChildrenRefs(ctx context.Context, apiPolicies, resourceAPIPolicies map[string]dpv1alpha3.APIPolicy, - api dpv1beta1.API) (map[string]dpv1alpha1.InterceptorService, map[string]dpv1alpha1.BackendJWT, bool, *dpv1alpha3.AIProvider, error) { + api dpv1alpha3.API) (map[string]dpv1alpha1.InterceptorService, map[string]dpv1alpha1.BackendJWT, bool, *dpv1alpha3.AIProvider, error) { allAPIPolicies := append(maps.Values(apiPolicies), maps.Values(resourceAPIPolicies)...) interceptorServices := make(map[string]dpv1alpha1.InterceptorService) backendJWTs := make(map[string]dpv1alpha1.BackendJWT) @@ -968,7 +966,7 @@ func (apiReconciler *APIReconciler) resolveAuthentications(ctx context.Context, func (apiReconciler *APIReconciler) getResolvedBackendsMapping(ctx context.Context, httpRouteState *synchronizer.HTTPRouteState, interceptorServiceMapping map[string]dpv1alpha1.InterceptorService, - api dpv1beta1.API) (map[string]*dpv1alpha2.ResolvedBackend, error) { + api dpv1alpha3.API) (map[string]*dpv1alpha2.ResolvedBackend, error) { backendMapping := make(map[string]*dpv1alpha2.ResolvedBackend) // Resolve backends in HTTPRoute @@ -1412,7 +1410,7 @@ func (apiReconciler *APIReconciler) getAPIForGQLRoute(ctx context.Context, obj k loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2665, logging.TRIVIAL, "Unexpected object type, bypassing reconciliation: %v", gqlRoute)) return []reconcile.Request{} } - apiList := &dpv1beta1.APIList{} + apiList := &dpv1alpha3.APIList{} if err := apiReconciler.client.List(ctx, apiList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(gqlRouteAPIIndex, utils.NamespacedName(gqlRoute).String()), }); err != nil { @@ -1447,7 +1445,7 @@ func (apiReconciler *APIReconciler) getAPIForHTTPRoute(ctx context.Context, obj return []reconcile.Request{} } - apiList := &dpv1beta1.APIList{} + apiList := &dpv1alpha3.APIList{} if err := apiReconciler.client.List(ctx, apiList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(httpRouteAPIIndex, utils.NamespacedName(httpRoute).String()), }); err != nil { @@ -1485,7 +1483,7 @@ func (apiReconciler *APIReconciler) getAPIForGRPCRoute(ctx context.Context, obj return []reconcile.Request{} } - apiList := &dpv1beta1.APIList{} + apiList := &dpv1alpha3.APIList{} logrus.Info("=============GETTING API FOR GRPC ROUTE================") if err := apiReconciler.client.List(ctx, apiList, &k8client.ListOptions{ @@ -1538,7 +1536,7 @@ func (apiReconciler *APIReconciler) getAPIsForConfigMap(ctx context.Context, obj return requests } - apiList := &dpv1beta1.APIList{} + apiList := &dpv1alpha3.APIList{} err = apiReconciler.client.List(ctx, apiList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(configMapAPIDefinition, utils.NamespacedName(configMap).String()), }) @@ -1969,9 +1967,9 @@ func (apiReconciler *APIReconciler) getAPIsForGateway(ctx context.Context, obj k // apiPolicy schemes related to httproutes // This helps to find apiPolicy schemes binded to HTTPRoute. func addIndexes(ctx context.Context, mgr manager.Manager) error { - if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1beta1.API{}, httpRouteAPIIndex, + if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha3.API{}, httpRouteAPIIndex, func(rawObj k8client.Object) []string { - api := rawObj.(*dpv1beta1.API) + api := rawObj.(*dpv1alpha3.API) var httpRoutes []string if len(api.Spec.Production) > 0 { for _, ref := range api.Spec.Production[0].RouteRefs { @@ -2000,9 +1998,9 @@ func addIndexes(ctx context.Context, mgr manager.Manager) error { return err } - if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1beta1.API{}, gqlRouteAPIIndex, + if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha3.API{}, gqlRouteAPIIndex, func(rawObj k8client.Object) []string { - api := rawObj.(*dpv1beta1.API) + api := rawObj.(*dpv1alpha3.API) var gqlRoutes []string if len(api.Spec.Production) > 0 { for _, ref := range api.Spec.Production[0].RouteRefs { @@ -2031,9 +2029,9 @@ func addIndexes(ctx context.Context, mgr manager.Manager) error { return err } - if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1beta1.API{}, grpcRouteAPIIndex, + if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha3.API{}, grpcRouteAPIIndex, func(rawObj k8client.Object) []string { - api := rawObj.(*dpv1beta1.API) + api := rawObj.(*dpv1alpha3.API) if api.Spec.APIType != constants.GRPC { return nil } @@ -2065,9 +2063,9 @@ func addIndexes(ctx context.Context, mgr manager.Manager) error { return err } - if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1beta1.API{}, configMapAPIDefinition, + if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha3.API{}, configMapAPIDefinition, func(rawObj k8client.Object) []string { - api := rawObj.(*dpv1beta1.API) + api := rawObj.(*dpv1alpha3.API) var configMaps []string if api.Spec.DefinitionFileRef != "" { configMaps = append(configMaps, @@ -2621,9 +2619,9 @@ func (apiReconciler *APIReconciler) handleStatus() { for _, apiName := range successEvent.APINamespacedName { // handle startup multiple apis apiReconciler.statusUpdater.Send(status.Update{ NamespacedName: apiName, - Resource: new(dpv1beta1.API), + Resource: new(dpv1alpha3.API), UpdateStatus: func(obj k8client.Object) k8client.Object { - h, ok := obj.(*dpv1beta1.API) + h, ok := obj.(*dpv1alpha3.API) if !ok { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2626, logging.BLOCKER, "Unsupported object type %T", obj)) } @@ -2660,7 +2658,7 @@ func (apiReconciler *APIReconciler) handleLabels(ctx context.Context) { }) } payloadBytes, _ := json.Marshal(patchOps) - apiCR := dpv1beta1.API{ + apiCR := dpv1alpha3.API{ ObjectMeta: metav1.ObjectMeta{ Namespace: labelUpdate.Namespace, Name: labelUpdate.Name, @@ -2671,7 +2669,7 @@ func (apiReconciler *APIReconciler) handleLabels(ctx context.Context) { if err != nil { loggers.LoggerAPKOperator.Errorf("Failed to patch api %s/%s with patch: %+v, error: %+v", labelUpdate.Name, labelUpdate.Namespace, patchOps, err) // Patch did not work it could be due to labels field does not exists. Lets try to update the CR with labels field. - var apiCR dpv1beta1.API + var apiCR dpv1alpha3.API if err := apiReconciler.client.Get(ctx, types.NamespacedName{Namespace: labelUpdate.Namespace, Name: labelUpdate.Name}, &apiCR); err == nil { if apiCR.ObjectMeta.Labels == nil { apiCR.ObjectMeta.Labels = map[string]string{} @@ -2691,9 +2689,9 @@ func (apiReconciler *APIReconciler) handleLabels(ctx context.Context) { } func (apiReconciler *APIReconciler) handleOwnerReference(ctx context.Context, obj k8client.Object, apiRequests *[]reconcile.Request) { - apis := []dpv1beta1.API{} + apis := []dpv1alpha3.API{} for _, req := range *apiRequests { - var apiCR dpv1beta1.API + var apiCR dpv1alpha3.API if err := apiReconciler.client.Get(ctx, req.NamespacedName, &apiCR); err == nil { apis = append(apis, apiCR) } else { @@ -2723,7 +2721,7 @@ func (apiReconciler *APIReconciler) handleOwnerReference(ctx context.Context, ob } } -func prepareOwnerReference(apiItems []dpv1beta1.API) []metav1.OwnerReference { +func prepareOwnerReference(apiItems []dpv1alpha3.API) []metav1.OwnerReference { ownerReferences := []metav1.OwnerReference{} uidMap := make(map[string]bool) for _, ref := range apiItems { @@ -3095,7 +3093,7 @@ func geSandVhost(apiState *synchronizer.APIState) string { } func prepareSecuritySchemeForCP(apiState *synchronizer.APIState) ([]string, string, string) { - var pickedAuth *v1alpha2.Authentication + var pickedAuth *dpv1alpha2.Authentication authHeader := "Authorization" apiKeyHeader := "ApiKey" for _, auth := range apiState.Authentications { @@ -3103,7 +3101,7 @@ func prepareSecuritySchemeForCP(apiState *synchronizer.APIState) ([]string, stri break } if pickedAuth != nil { - var authSpec *v1alpha2.AuthSpec + var authSpec *dpv1alpha2.AuthSpec if pickedAuth.Spec.Override != nil { authSpec = pickedAuth.Spec.Override } else { diff --git a/adapter/internal/operator/operator.go b/adapter/internal/operator/operator.go index ee97187a2..35eb1a867 100644 --- a/adapter/internal/operator/operator.go +++ b/adapter/internal/operator/operator.go @@ -50,7 +50,6 @@ import ( dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" dpv1alpha3 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" - dpv1beta1 "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" //+kubebuilder:scaffold:imports ) @@ -71,7 +70,6 @@ func init() { utilruntime.Must(dpv1alpha3.AddToScheme(scheme)) - utilruntime.Must(dpv1beta1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } diff --git a/adapter/internal/operator/synchronizer/api_state.go b/adapter/internal/operator/synchronizer/api_state.go index f0712f72a..ffc318bdc 100644 --- a/adapter/internal/operator/synchronizer/api_state.go +++ b/adapter/internal/operator/synchronizer/api_state.go @@ -21,7 +21,6 @@ import ( "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" - "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) @@ -30,7 +29,7 @@ import ( // the state of the Kubernetes controller cache to detect updates. // +k8s:deepcopy-gen=true type APIState struct { - APIDefinition *v1beta1.API + APIDefinition *v1alpha3.API ProdHTTPRoute *HTTPRouteState SandHTTPRoute *HTTPRouteState ProdGQLRoute *GQLRouteState diff --git a/adapter/internal/operator/synchronizer/zz_generated.deepcopy.go b/adapter/internal/operator/synchronizer/zz_generated.deepcopy.go index 22057cc26..84e61c561 100644 --- a/adapter/internal/operator/synchronizer/zz_generated.deepcopy.go +++ b/adapter/internal/operator/synchronizer/zz_generated.deepcopy.go @@ -26,7 +26,6 @@ import ( "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" - "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" "sigs.k8s.io/gateway-api/apis/v1" apisv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) @@ -36,7 +35,7 @@ func (in *APIState) DeepCopyInto(out *APIState) { *out = *in if in.APIDefinition != nil { in, out := &in.APIDefinition, &out.APIDefinition - *out = new(v1beta1.API) + *out = new(v1alpha3.API) (*in).DeepCopyInto(*out) } if in.ProdHTTPRoute != nil { @@ -111,6 +110,11 @@ func (in *APIState) DeepCopyInto(out *APIState) { (*out)[key] = *val.DeepCopy() } } + if in.AIProvider != nil { + in, out := &in.AIProvider, &out.AIProvider + *out = new(v1alpha3.AIProvider) + (*in).DeepCopyInto(*out) + } if in.InterceptorServiceMapping != nil { in, out := &in.InterceptorServiceMapping, &out.InterceptorServiceMapping *out = make(map[string]v1alpha1.InterceptorService, len(*in)) diff --git a/adapter/internal/operator/utils/utils.go b/adapter/internal/operator/utils/utils.go index 9cffae7dc..55e35afb8 100644 --- a/adapter/internal/operator/utils/utils.go +++ b/adapter/internal/operator/utils/utils.go @@ -36,7 +36,6 @@ import ( dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" dpv1alpha3 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" - dpv1beta1 "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -350,7 +349,7 @@ func GetResolvedBackendFromService(k8sService *corev1.Service, svcPort int) (*dp // ResolveAndAddBackendToMapping resolves backend from reference and adds it to the backendMapping. func ResolveAndAddBackendToMapping(ctx context.Context, client k8client.Client, backendMapping map[string]*dpv1alpha2.ResolvedBackend, - backendRef dpv1alpha1.BackendReference, interceptorServiceNamespace string, api *dpv1beta1.API) { + backendRef dpv1alpha1.BackendReference, interceptorServiceNamespace string, api *dpv1alpha3.API) { backendName := types.NamespacedName{ Name: backendRef.Name, Namespace: interceptorServiceNamespace, @@ -362,7 +361,7 @@ func ResolveAndAddBackendToMapping(ctx context.Context, client k8client.Client, } // ResolveRef this function will return k8client object and update owner -func ResolveRef(ctx context.Context, client k8client.Client, api *dpv1beta1.API, +func ResolveRef(ctx context.Context, client k8client.Client, api *dpv1alpha3.API, namespacedName types.NamespacedName, isReplace bool, obj k8client.Object, opts ...k8client.GetOption) error { err := client.Get(ctx, namespacedName, obj, opts...) return err @@ -370,7 +369,7 @@ func ResolveRef(ctx context.Context, client k8client.Client, api *dpv1beta1.API, // GetResolvedBackend resolves backend TLS configurations. func GetResolvedBackend(ctx context.Context, client k8client.Client, - backendNamespacedName types.NamespacedName, api *dpv1beta1.API) *dpv1alpha2.ResolvedBackend { + backendNamespacedName types.NamespacedName, api *dpv1alpha3.API) *dpv1alpha2.ResolvedBackend { resolvedBackend := dpv1alpha2.ResolvedBackend{} resolvedTLSConfig := dpv1alpha2.ResolvedTLSConfig{} var backend dpv1alpha2.Backend @@ -596,7 +595,7 @@ func RetrieveNamespaceListOptions(namespaces []string) k8client.ListOptions { // GetInterceptorService reads InterceptorService when interceptorReference is given func GetInterceptorService(ctx context.Context, client k8client.Client, namespace string, - interceptorReference *dpv1alpha3.InterceptorReference, api *dpv1beta1.API) *dpv1alpha1.InterceptorService { + interceptorReference *dpv1alpha3.InterceptorReference, api *dpv1alpha3.API) *dpv1alpha1.InterceptorService { interceptorService := &dpv1alpha1.InterceptorService{} interceptorRef := types.NamespacedName{ Namespace: namespace, @@ -612,7 +611,7 @@ func GetInterceptorService(ctx context.Context, client k8client.Client, namespac // GetBackendJWT reads BackendJWT when backendJWTReference is given func GetBackendJWT(ctx context.Context, client k8client.Client, namespace, - backendJWTReference string, api *dpv1beta1.API) *dpv1alpha1.BackendJWT { + backendJWTReference string, api *dpv1alpha3.API) *dpv1alpha1.BackendJWT { backendJWT := &dpv1alpha1.BackendJWT{} backendJWTRef := types.NamespacedName{ Namespace: namespace, @@ -628,7 +627,7 @@ func GetBackendJWT(ctx context.Context, client k8client.Client, namespace, // GetAIProvider reads AIProvider when aiProviderReference is given func GetAIProvider(ctx context.Context, client k8client.Client, namespace string, - aiProviderReference string, api *dpv1beta1.API) *dpv1alpha3.AIProvider { + aiProviderReference string, api *dpv1alpha3.API) *dpv1alpha3.AIProvider { aiProvider := &dpv1alpha3.AIProvider{} aiProviderRef := types.NamespacedName{ Namespace: namespace, @@ -645,21 +644,21 @@ func GetAIProvider(ctx context.Context, client k8client.Client, namespace string } // RetrieveAPIList retrieves API list from the given kubernetes client -func RetrieveAPIList(k8sclient k8client.Client) ([]dpv1beta1.API, error) { +func RetrieveAPIList(k8sclient k8client.Client) ([]dpv1alpha3.API, error) { ctx := context.Background() conf := config.ReadConfigs() namespaces := conf.Adapter.Operator.Namespaces - var apis []dpv1beta1.API + var apis []dpv1alpha3.API if namespaces == nil { - apiList := &dpv1beta1.APIList{} + apiList := &dpv1alpha3.APIList{} if err := k8sclient.List(ctx, apiList, &k8client.ListOptions{}); err != nil { return nil, err } - apis = make([]dpv1beta1.API, len(apiList.Items)) + apis = make([]dpv1alpha3.API, len(apiList.Items)) copy(apis[:], apiList.Items[:]) } else { for _, namespace := range namespaces { - apiList := &dpv1beta1.APIList{} + apiList := &dpv1alpha3.APIList{} if err := k8sclient.List(ctx, apiList, &k8client.ListOptions{Namespace: namespace}); err != nil { return nil, err } diff --git a/common-controller/go.mod b/common-controller/go.mod index 5e0e92001..d5a7c3108 100644 --- a/common-controller/go.mod +++ b/common-controller/go.mod @@ -22,7 +22,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/redis/go-redis/v9 v9.2.1 github.com/wso2/apk/adapter v0.0.0-20231214082511-af2c8b8a19f1 - github.com/wso2/apk/common-go-libs v0.0.0-20240304050809-a382bc6b0d82 + github.com/wso2/apk/common-go-libs v0.0.0-20240911043600-b84cd52d2bd3 google.golang.org/grpc v1.62.0 ) diff --git a/common-controller/internal/operator/config/crd/bases/dp.wso2.com_apis.yaml b/common-controller/internal/operator/config/crd/bases/dp.wso2.com_apis.yaml index 304529c66..d3bd7331b 100644 --- a/common-controller/internal/operator/config/crd/bases/dp.wso2.com_apis.yaml +++ b/common-controller/internal/operator/config/crd/bases/dp.wso2.com_apis.yaml @@ -259,8 +259,8 @@ spec: pattern: ^[/][a-zA-Z0-9~/_.-]*$ type: string definitionFileRef: - description: DefinitionFileRef contains the OpenAPI 3 or Swagger definition - of the API in a ConfigMap. + description: DefinitionFileRef contains the definition of the API + in a ConfigMap. type: string definitionPath: default: /api-definition @@ -285,13 +285,13 @@ spec: items: description: EnvConfig contains the environment specific configuration properties: - httpRouteRefs: - description: HTTPRouteRefs denotes the environment of the API. + routeRefs: + description: RouteRefs denotes the environment of the API. items: type: string type: array required: - - httpRouteRefs + - routeRefs type: object maxItems: 1 nullable: true @@ -302,13 +302,191 @@ spec: items: description: EnvConfig contains the environment specific configuration properties: - httpRouteRefs: - description: HTTPRouteRefs denotes the environment of the API. + routeRefs: + description: RouteRefs denotes the environment of the API. items: type: string type: array required: - - httpRouteRefs + - routeRefs + type: object + maxItems: 1 + nullable: true + type: array + systemAPI: + description: SystemAPI denotes if it is an internal system API. + type: boolean + required: + - apiName + - apiType + - apiVersion + - basePath + - definitionPath + type: object + status: + description: APIStatus defines the observed state of API + properties: + deploymentStatus: + description: DeploymentStatus denotes the deployment status of the + API + properties: + accepted: + description: Accepted represents whether the API is accepted or + not. + type: boolean + events: + description: Events contains a list of events related to the API. + items: + type: string + type: array + message: + description: Message represents a user friendly message that explains + the current state of the API. + type: string + status: + description: Status denotes the state of the API in its lifecycle. + Possible values could be Accepted, Invalid, Deploy etc. + type: string + transitionTime: + description: TransitionTime represents the last known transition + timestamp. + format: date-time + type: string + required: + - accepted + - status + - transitionTime + type: object + type: object + type: object + served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .spec.apiName + name: API Name + type: string + - jsonPath: .spec.apiVersion + name: Version + type: string + - jsonPath: .spec.basePath + name: BasePath + type: string + - jsonPath: .spec.organization + name: Organization + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha3 + schema: + openAPIV3Schema: + description: API is the Schema for the apis API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: APISpec defines the desired state of API + properties: + apiName: + description: APIName is the unique name of the API can be used to + uniquely identify an API. + maxLength: 60 + minLength: 1 + pattern: ^[^~!@#;:%^*()+={}|\<>"'',&$\[\]\/]*$ + type: string + apiProperties: + description: APIProperties denotes the custom properties of the API. + items: + description: Property holds key value pair of APIProperties + properties: + name: + type: string + value: + type: string + type: object + nullable: true + type: array + apiType: + description: APIType denotes the type of the API. Possible values + could be REST, GraphQL, GRPC + enum: + - REST + - GraphQL + - GRPC + type: string + apiVersion: + description: APIVersion is the version number of the API. + maxLength: 30 + minLength: 1 + pattern: ^[^~!@#;:%^*()+={}|\<>"'',&/$\[\]\s+\/]+$ + type: string + basePath: + description: 'BasePath denotes the basepath of the API. e.g: /pet-store-api/1.0.6' + pattern: ^[/][a-zA-Z0-9~/_.-]*$ + type: string + definitionFileRef: + description: DefinitionFileRef contains the definition of the API + in a ConfigMap. + type: string + definitionPath: + default: /api-definition + description: DefinitionPath contains the path to expose the API definition. + minLength: 1 + type: string + environment: + description: Environment denotes the environment of the API. + nullable: true + type: string + isDefaultVersion: + description: IsDefaultVersion indicates whether this API version should + be used as a default API + type: boolean + organization: + description: Organization denotes the organization. related to the + API + type: string + 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' + items: + description: EnvConfig contains the environment specific configuration + properties: + routeRefs: + description: RouteRefs denotes the environment of the API. + items: + type: string + type: array + required: + - routeRefs + type: object + maxItems: 1 + nullable: true + type: array + sandbox: + description: 'Sandbox 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' + items: + description: EnvConfig contains the environment specific configuration + properties: + routeRefs: + description: RouteRefs denotes the environment of the API. + items: + type: string + type: array + required: + - routeRefs type: object maxItems: 1 nullable: true diff --git a/common-controller/internal/operator/config/webhook/manifests.yaml b/common-controller/internal/operator/config/webhook/manifests.yaml index 7f4851708..233b8cad7 100644 --- a/common-controller/internal/operator/config/webhook/manifests.yaml +++ b/common-controller/internal/operator/config/webhook/manifests.yaml @@ -24,6 +24,26 @@ webhooks: resources: - apis sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-dp-wso2-com-v1alpha3-api + failurePolicy: Fail + name: mapi.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - apis + sideEffects: None - admissionReviewVersions: - v1 clientConfig: @@ -230,6 +250,26 @@ webhooks: resources: - apis sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-dp-wso2-com-v1alpha3-api + failurePolicy: Fail + name: vapi.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - apis + sideEffects: None - admissionReviewVersions: - v1 clientConfig: diff --git a/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go b/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go index c9350dde0..cf8b54658 100644 --- a/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go +++ b/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go @@ -47,7 +47,6 @@ import ( xds "github.com/wso2/apk/common-controller/internal/xds" dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" dpv1alpha3 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" - dpv1beta1 "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" "github.com/wso2/apk/common-go-libs/constants" ) @@ -88,7 +87,7 @@ func NewratelimitController(mgr manager.Manager, ratelimitStore *cache.Ratelimit conf := config.ReadConfigs() predicates := []predicate.Predicate{predicate.NewPredicateFuncs(utils.FilterByNamespaces(conf.CommonController.Operator.Namespaces))} - if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1beta1.API{}), + if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1alpha3.API{}), handler.EnqueueRequestsFromMapFunc(ratelimitReconciler.getRatelimitForAPI), predicates...); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2611, logging.BLOCKER, "Error watching API resources: %v", err)) @@ -190,7 +189,7 @@ func (ratelimitReconciler *RateLimitPolicyReconciler) Reconcile(ctx context.Cont } func (ratelimitReconciler *RateLimitPolicyReconciler) getRatelimitForAPI(ctx context.Context, obj k8client.Object) []reconcile.Request { - api, ok := obj.(*dpv1beta1.API) + api, ok := obj.(*dpv1alpha3.API) if !ok { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2622, logging.TRIVIAL, "Unexpected object type, bypassing reconciliation: %v", api)) @@ -275,7 +274,7 @@ func (ratelimitReconciler *RateLimitPolicyReconciler) marshelRateLimit(ctx conte ratelimitPolicy dpv1alpha3.RateLimitPolicy) ([]dpv1alpha1.ResolveRateLimitAPIPolicy, error) { policyList := []dpv1alpha1.ResolveRateLimitAPIPolicy{} - var api dpv1beta1.API + var api dpv1alpha3.API if err := ratelimitReconciler.client.Get(ctx, types.NamespacedName{ Namespace: ratelimitKey.Namespace, diff --git a/common-controller/internal/operator/operator.go b/common-controller/internal/operator/operator.go index dd5bd38fb..2ad1be40c 100644 --- a/common-controller/internal/operator/operator.go +++ b/common-controller/internal/operator/operator.go @@ -41,7 +41,6 @@ import ( dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" dpv1alpha3 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" - dpv1beta1 "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" @@ -68,7 +67,6 @@ func init() { utilruntime.Must(cpv1alpha2.AddToScheme(scheme)) utilruntime.Must(cpv1alpha3.AddToScheme(scheme)) utilruntime.Must(dpv1alpha3.AddToScheme(scheme)) - utilruntime.Must(dpv1beta1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -138,7 +136,7 @@ func InitOperator(metricsConfig config.Metrics) { "Unable to create webhook API, error: %v", err)) } - if err = (&dpv1beta1.API{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&dpv1alpha3.API{}).SetupWebhookWithManager(mgr); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2601, logging.MAJOR, "Unable to create webhook API, error: %v", err)) } diff --git a/common-go-libs/PROJECT b/common-go-libs/PROJECT index 6f323227e..39b37bd43 100644 --- a/common-go-libs/PROJECT +++ b/common-go-libs/PROJECT @@ -186,9 +186,10 @@ resources: domain: wso2.com group: dp kind: API - path: github.com/wso2/apk/common-go-libs/apis/dp/v1beta1 - version: v1beta1 + path: github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3 + version: v1alpha3 webhooks: + conversion: true defaulting: true validation: true webhookVersion: v1 diff --git a/common-go-libs/apis/dp/v1alpha1/api_conversion.go b/common-go-libs/apis/dp/v1alpha1/api_conversion.go index e6ffe0296..571556a11 100644 --- a/common-go-libs/apis/dp/v1alpha1/api_conversion.go +++ b/common-go-libs/apis/dp/v1alpha1/api_conversion.go @@ -18,15 +18,15 @@ package v1alpha1 import ( - "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" + "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" "sigs.k8s.io/controller-runtime/pkg/conversion" ) -// ConvertTo converts this API CR to the Hub version (v1beta1). -// src is v1alpha1.API and dst is v1beta1.API. +// ConvertTo converts this API CR to the Hub version (v1alpha3). +// src is v1alpha1.API and dst is v1alpha3.API. func (src *API) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v1beta1.API) + dst := dstRaw.(*v1alpha3.API) dst.ObjectMeta = src.ObjectMeta // Spec @@ -41,40 +41,40 @@ func (src *API) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.SystemAPI = src.Spec.SystemAPI if src.Spec.Production != nil { - dst.Spec.Production = []v1beta1.EnvConfig{} + dst.Spec.Production = []v1alpha3.EnvConfig{} for _, productionRef := range src.Spec.Production { - dst.Spec.Production = append(dst.Spec.Production, v1beta1.EnvConfig{ + dst.Spec.Production = append(dst.Spec.Production, v1alpha3.EnvConfig{ RouteRefs: productionRef.HTTPRouteRefs, }) } } if src.Spec.Sandbox != nil { - dst.Spec.Sandbox = []v1beta1.EnvConfig{} + dst.Spec.Sandbox = []v1alpha3.EnvConfig{} for _, sandboxRef := range src.Spec.Sandbox { - dst.Spec.Sandbox = append(dst.Spec.Sandbox, v1beta1.EnvConfig{ + dst.Spec.Sandbox = append(dst.Spec.Sandbox, v1alpha3.EnvConfig{ RouteRefs: sandboxRef.HTTPRouteRefs, }) } } // Convert []Property to []v1alpha2.Property - var properties []v1beta1.Property + var properties []v1alpha3.Property for _, p := range src.Spec.APIProperties { - properties = append(properties, v1beta1.Property(p)) + properties = append(properties, v1alpha3.Property(p)) } dst.Spec.APIProperties = properties // Status - dst.Status.DeploymentStatus = v1beta1.DeploymentStatus(src.Status.DeploymentStatus) + dst.Status.DeploymentStatus = v1alpha3.DeploymentStatus(src.Status.DeploymentStatus) return nil } -// ConvertFrom converts from the Hub version (v1beta1) to this version. -// src is v1alpha1.API and dst is v1beta1.API. +// ConvertFrom converts from the Hub version (v1alpha3) to this version. +// src is v1alpha1.API and dst is v1alpha3.API. func (src *API) ConvertFrom(srcRaw conversion.Hub) error { - dst := srcRaw.(*v1beta1.API) + dst := srcRaw.(*v1alpha3.API) src.ObjectMeta = dst.ObjectMeta // Spec diff --git a/common-go-libs/apis/dp/v1alpha2/api_conversion.go b/common-go-libs/apis/dp/v1alpha2/api_conversion.go index 5fd93d09b..3bcb5f4aa 100644 --- a/common-go-libs/apis/dp/v1alpha2/api_conversion.go +++ b/common-go-libs/apis/dp/v1alpha2/api_conversion.go @@ -18,15 +18,15 @@ package v1alpha2 import ( - "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1" + "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3" "sigs.k8s.io/controller-runtime/pkg/conversion" ) -// ConvertTo converts this API CR to the Hub version (v1beta1). -// src is v1alpha2.API and dst is v1beta1.API. +// ConvertTo converts this API CR to the Hub version (v1alpha3). +// src is v1alpha2.API and dst is v1alpha3.API. func (src *API) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v1beta1.API) + dst := dstRaw.(*v1alpha3.API) dst.ObjectMeta = src.ObjectMeta // Spec @@ -41,40 +41,40 @@ func (src *API) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.SystemAPI = src.Spec.SystemAPI if src.Spec.Production != nil { - dst.Spec.Production = []v1beta1.EnvConfig{} + dst.Spec.Production = []v1alpha3.EnvConfig{} for _, productionRef := range src.Spec.Production { - dst.Spec.Production = append(dst.Spec.Production, v1beta1.EnvConfig{ + dst.Spec.Production = append(dst.Spec.Production, v1alpha3.EnvConfig{ RouteRefs: productionRef.RouteRefs, }) } } if src.Spec.Sandbox != nil { - dst.Spec.Sandbox = []v1beta1.EnvConfig{} + dst.Spec.Sandbox = []v1alpha3.EnvConfig{} for _, sandboxRef := range src.Spec.Sandbox { - dst.Spec.Sandbox = append(dst.Spec.Sandbox, v1beta1.EnvConfig{ + dst.Spec.Sandbox = append(dst.Spec.Sandbox, v1alpha3.EnvConfig{ RouteRefs: sandboxRef.RouteRefs, }) } } // Convert []Property to []v1alpha2.Property - var properties []v1beta1.Property + var properties []v1alpha3.Property for _, p := range src.Spec.APIProperties { - properties = append(properties, v1beta1.Property(p)) + properties = append(properties, v1alpha3.Property(p)) } dst.Spec.APIProperties = properties // Status - dst.Status.DeploymentStatus = v1beta1.DeploymentStatus(src.Status.DeploymentStatus) + dst.Status.DeploymentStatus = v1alpha3.DeploymentStatus(src.Status.DeploymentStatus) return nil } -// ConvertFrom converts from the Hub version (v1beta1) to this version. -// src is v1alpha2.API and dst is v1beta1.API. +// ConvertFrom converts from the Hub version (v1alpha3) to this version. +// src is v1alpha2.API and dst is v1alpha3.API. func (src *API) ConvertFrom(srcRaw conversion.Hub) error { - dst := srcRaw.(*v1beta1.API) + dst := srcRaw.(*v1alpha3.API) src.ObjectMeta = dst.ObjectMeta // Spec diff --git a/common-go-libs/apis/dp/v1beta1/api_conversion.go b/common-go-libs/apis/dp/v1alpha3/api_conversion.go similarity index 97% rename from common-go-libs/apis/dp/v1beta1/api_conversion.go rename to common-go-libs/apis/dp/v1alpha3/api_conversion.go index 5564f83e0..1d9974522 100644 --- a/common-go-libs/apis/dp/v1beta1/api_conversion.go +++ b/common-go-libs/apis/dp/v1alpha3/api_conversion.go @@ -15,7 +15,7 @@ * */ -package v1beta1 +package v1alpha3 // Hub marks this type as a conversion hub. func (*API) Hub() {} diff --git a/common-go-libs/apis/dp/v1beta1/api_types.go b/common-go-libs/apis/dp/v1alpha3/api_types.go similarity index 99% rename from common-go-libs/apis/dp/v1beta1/api_types.go rename to common-go-libs/apis/dp/v1alpha3/api_types.go index 943e9a134..de1eba9b3 100644 --- a/common-go-libs/apis/dp/v1beta1/api_types.go +++ b/common-go-libs/apis/dp/v1alpha3/api_types.go @@ -15,7 +15,7 @@ * */ -package v1beta1 +package v1alpha3 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/common-go-libs/apis/dp/v1beta1/api_webhook.go b/common-go-libs/apis/dp/v1alpha3/api_webhook.go similarity index 95% rename from common-go-libs/apis/dp/v1beta1/api_webhook.go rename to common-go-libs/apis/dp/v1alpha3/api_webhook.go index 030374504..ceb312d0c 100644 --- a/common-go-libs/apis/dp/v1beta1/api_webhook.go +++ b/common-go-libs/apis/dp/v1alpha3/api_webhook.go @@ -15,7 +15,7 @@ * */ -package v1beta1 +package v1alpha3 import ( "bytes" @@ -62,7 +62,7 @@ func (r *API) SetupWebhookWithManager(mgr ctrl.Manager) error { // TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1beta1-api,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apis,verbs=create;update,versions=v1beta1,name=mapi.kb.io,admissionReviewVersions=v1 +//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1alpha3-api,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apis,verbs=create;update,versions=v1alpha3,name=mapi.kb.io,admissionReviewVersions=v1 var _ webhook.Defaulter = &API{} @@ -74,7 +74,7 @@ func (r *API) Default() { } // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1beta1-api,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apis,verbs=create;update,versions=v1beta1,name=vapi.kb.io,admissionReviewVersions=v1 +//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1alpha3-api,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apis,verbs=create;update,versions=v1alpha3,name=vapi.kb.io,admissionReviewVersions=v1 var _ webhook.Validator = &API{} diff --git a/common-go-libs/apis/dp/v1beta1/webhook_suite_test.go b/common-go-libs/apis/dp/v1alpha3/webhook_suite_test.go similarity index 97% rename from common-go-libs/apis/dp/v1beta1/webhook_suite_test.go rename to common-go-libs/apis/dp/v1alpha3/webhook_suite_test.go index 4c4395044..53ab76230 100644 --- a/common-go-libs/apis/dp/v1beta1/webhook_suite_test.go +++ b/common-go-libs/apis/dp/v1alpha3/webhook_suite_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * */ -package v1beta1 +package v1alpha3 import ( "context" diff --git a/common-go-libs/apis/dp/v1alpha3/zz_generated.deepcopy.go b/common-go-libs/apis/dp/v1alpha3/zz_generated.deepcopy.go index e0fda22ea..a840a027d 100644 --- a/common-go-libs/apis/dp/v1alpha3/zz_generated.deepcopy.go +++ b/common-go-libs/apis/dp/v1alpha3/zz_generated.deepcopy.go @@ -132,6 +132,65 @@ func (in *AIProviderStatus) DeepCopy() *AIProviderStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *API) DeepCopyInto(out *API) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new API. +func (in *API) DeepCopy() *API { + if in == nil { + return nil + } + out := new(API) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *API) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIList) DeepCopyInto(out *APIList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]API, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIList. +func (in *APIList) DeepCopy() *APIList { + if in == nil { + return nil + } + out := new(APIList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *APIPolicy) DeepCopyInto(out *APIPolicy) { *out = *in @@ -247,6 +306,56 @@ func (in *APIRateLimitPolicy) DeepCopy() *APIRateLimitPolicy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APISpec) DeepCopyInto(out *APISpec) { + *out = *in + if in.Production != nil { + in, out := &in.Production, &out.Production + *out = make([]EnvConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Sandbox != nil { + in, out := &in.Sandbox, &out.Sandbox + *out = make([]EnvConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.APIProperties != nil { + in, out := &in.APIProperties, &out.APIProperties + *out = make([]Property, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APISpec. +func (in *APISpec) DeepCopy() *APISpec { + if in == nil { + return nil + } + out := new(APISpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIStatus) DeepCopyInto(out *APIStatus) { + *out = *in + in.DeploymentStatus.DeepCopyInto(&out.DeploymentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIStatus. +func (in *APIStatus) DeepCopy() *APIStatus { + if in == nil { + return nil + } + out := new(APIStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BackendJWTToken) DeepCopyInto(out *BackendJWTToken) { *out = *in @@ -332,6 +441,50 @@ func (in *CustomRateLimitPolicy) DeepCopy() *CustomRateLimitPolicy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { + *out = *in + if in.TransitionTime != nil { + in, out := &in.TransitionTime, &out.TransitionTime + *out = (*in).DeepCopy() + } + if in.Events != nil { + in, out := &in.Events, &out.Events + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentStatus. +func (in *DeploymentStatus) DeepCopy() *DeploymentStatus { + if in == nil { + return nil + } + out := new(DeploymentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EnvConfig) DeepCopyInto(out *EnvConfig) { + *out = *in + if in.RouteRefs != nil { + in, out := &in.RouteRefs, &out.RouteRefs + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvConfig. +func (in *EnvConfig) DeepCopy() *EnvConfig { + if in == nil { + return nil + } + out := new(EnvConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InterceptorReference) DeepCopyInto(out *InterceptorReference) { *out = *in @@ -387,6 +540,21 @@ func (in *PolicySpec) DeepCopy() *PolicySpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Property) DeepCopyInto(out *Property) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Property. +func (in *Property) DeepCopy() *Property { + if in == nil { + return nil + } + out := new(Property) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RateLimitAPIPolicy) DeepCopyInto(out *RateLimitAPIPolicy) { *out = *in diff --git a/common-go-libs/apis/dp/v1beta1/groupversion_info.go b/common-go-libs/apis/dp/v1beta1/groupversion_info.go deleted file mode 100644 index 9f7ad3d00..000000000 --- a/common-go-libs/apis/dp/v1beta1/groupversion_info.go +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package v1beta1 contains API Schema definitions for the dp v1beta1 API group -// +kubebuilder:object:generate=true -// +groupName=dp.wso2.com -package v1beta1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "dp.wso2.com", Version: "v1beta1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/common-go-libs/apis/dp/v1beta1/zz_generated.deepcopy.go b/common-go-libs/apis/dp/v1beta1/zz_generated.deepcopy.go deleted file mode 100644 index 79cffd6db..000000000 --- a/common-go-libs/apis/dp/v1beta1/zz_generated.deepcopy.go +++ /dev/null @@ -1,195 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *API) DeepCopyInto(out *API) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new API. -func (in *API) DeepCopy() *API { - if in == nil { - return nil - } - out := new(API) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *API) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIList) DeepCopyInto(out *APIList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]API, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIList. -func (in *APIList) DeepCopy() *APIList { - if in == nil { - return nil - } - out := new(APIList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *APIList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APISpec) DeepCopyInto(out *APISpec) { - *out = *in - if in.Production != nil { - in, out := &in.Production, &out.Production - *out = make([]EnvConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Sandbox != nil { - in, out := &in.Sandbox, &out.Sandbox - *out = make([]EnvConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.APIProperties != nil { - in, out := &in.APIProperties, &out.APIProperties - *out = make([]Property, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APISpec. -func (in *APISpec) DeepCopy() *APISpec { - if in == nil { - return nil - } - out := new(APISpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIStatus) DeepCopyInto(out *APIStatus) { - *out = *in - in.DeploymentStatus.DeepCopyInto(&out.DeploymentStatus) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIStatus. -func (in *APIStatus) DeepCopy() *APIStatus { - if in == nil { - return nil - } - out := new(APIStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { - *out = *in - if in.TransitionTime != nil { - in, out := &in.TransitionTime, &out.TransitionTime - *out = (*in).DeepCopy() - } - if in.Events != nil { - in, out := &in.Events, &out.Events - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentStatus. -func (in *DeploymentStatus) DeepCopy() *DeploymentStatus { - if in == nil { - return nil - } - out := new(DeploymentStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *EnvConfig) DeepCopyInto(out *EnvConfig) { - *out = *in - if in.RouteRefs != nil { - in, out := &in.RouteRefs, &out.RouteRefs - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvConfig. -func (in *EnvConfig) DeepCopy() *EnvConfig { - if in == nil { - return nil - } - out := new(EnvConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Property) DeepCopyInto(out *Property) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Property. -func (in *Property) DeepCopy() *Property { - if in == nil { - return nil - } - out := new(Property) - in.DeepCopyInto(out) - return out -} diff --git a/common-go-libs/config/crd/bases/dp.wso2.com_apis.yaml b/common-go-libs/config/crd/bases/dp.wso2.com_apis.yaml index 1fa8ea672..d3bd7331b 100644 --- a/common-go-libs/config/crd/bases/dp.wso2.com_apis.yaml +++ b/common-go-libs/config/crd/bases/dp.wso2.com_apis.yaml @@ -379,7 +379,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1beta1 + name: v1alpha3 schema: openAPIV3Schema: description: API is the Schema for the apis API diff --git a/common-go-libs/config/samples/dp_v1beta1_api.yaml b/common-go-libs/config/samples/dp_v1alpha3_api.yaml similarity index 89% rename from common-go-libs/config/samples/dp_v1beta1_api.yaml rename to common-go-libs/config/samples/dp_v1alpha3_api.yaml index c84dd75cd..5e0505f10 100644 --- a/common-go-libs/config/samples/dp_v1beta1_api.yaml +++ b/common-go-libs/config/samples/dp_v1alpha3_api.yaml @@ -1,4 +1,4 @@ -apiVersion: dp.wso2.com/v1beta1 +apiVersion: dp.wso2.com/v1alpha3 kind: API metadata: labels: diff --git a/common-go-libs/config/webhook/manifests.yaml b/common-go-libs/config/webhook/manifests.yaml index 487ae0aae..f4a9f4cd1 100644 --- a/common-go-libs/config/webhook/manifests.yaml +++ b/common-go-libs/config/webhook/manifests.yaml @@ -10,9 +10,9 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-dp-wso2-com-v1alpha3-apipolicy + path: /mutate-dp-wso2-com-v1alpha3-api failurePolicy: Fail - name: mapipolicy.kb.io + name: mapi.kb.io rules: - apiGroups: - dp.wso2.com @@ -22,7 +22,7 @@ webhooks: - CREATE - UPDATE resources: - - apipolicies + - apis sideEffects: None - admissionReviewVersions: - v1 @@ -30,19 +30,19 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-dp-wso2-com-v1beta1-api + path: /mutate-dp-wso2-com-v1alpha3-apipolicy failurePolicy: Fail - name: mapi.kb.io + name: mapipolicy.kb.io rules: - apiGroups: - dp.wso2.com apiVersions: - - v1beta1 + - v1alpha3 operations: - CREATE - UPDATE resources: - - apis + - apipolicies sideEffects: None - admissionReviewVersions: - v1 @@ -216,9 +216,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-dp-wso2-com-v1alpha3-apipolicy + path: /validate-dp-wso2-com-v1alpha3-api failurePolicy: Fail - name: vapipolicy.kb.io + name: vapi.kb.io rules: - apiGroups: - dp.wso2.com @@ -228,7 +228,7 @@ webhooks: - CREATE - UPDATE resources: - - apipolicies + - apis sideEffects: None - admissionReviewVersions: - v1 @@ -236,19 +236,19 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-dp-wso2-com-v1beta1-api + path: /validate-dp-wso2-com-v1alpha3-apipolicy failurePolicy: Fail - name: vapi.kb.io + name: vapipolicy.kb.io rules: - apiGroups: - dp.wso2.com apiVersions: - - v1beta1 + - v1alpha3 operations: - CREATE - UPDATE resources: - - apis + - apipolicies sideEffects: None - admissionReviewVersions: - v1 diff --git a/common-go-libs/revive.toml b/common-go-libs/revive.toml index 2a89307bd..c1f3f2392 100644 --- a/common-go-libs/revive.toml +++ b/common-go-libs/revive.toml @@ -8,7 +8,7 @@ warningCode = 0 [rule.context-as-argument] [rule.context-keys-type] [rule.dot-imports] -exclude = ["apis/dp/v1alpha1/webhook_suite_test.go", "apis/dp/v1alpha2/webhook_suite_test.go", "apis/dp/v1beta1/webhook_suite_test.go"] +exclude = ["apis/dp/v1alpha1/webhook_suite_test.go", "apis/dp/v1alpha2/webhook_suite_test.go", "apis/dp/v1alpha3/webhook_suite_test.go"] [rule.error-return] [rule.error-strings] [rule.error-naming] diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/GRPCAPI.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/GRPCAPI.java index 970db479f..540d4d913 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/GRPCAPI.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/GRPCAPI.java @@ -54,7 +54,7 @@ public String init(Api api) { List resources = new ArrayList<>(); String mutualSSL = api.getMutualSSL(); - boolean applicationSecurity = api.getApplicationSecurity(); + Map applicationSecurity = api.getApplicationSecurityMap(); EndpointCluster endpoints = Utils.processEndpoints(api.getEndpoints()); EndpointSecurity[] endpointSecurity = APIProcessUtils.convertProtoEndpointSecurity( diff --git a/helm-charts/templates/crds/dp.wso2.com_apis.yaml b/helm-charts/templates/crds/dp.wso2.com_apis.yaml index 488a91b20..86c80490b 100644 --- a/helm-charts/templates/crds/dp.wso2.com_apis.yaml +++ b/helm-charts/templates/crds/dp.wso2.com_apis.yaml @@ -392,7 +392,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1beta1 + name: v1alpha3 schema: openAPIV3Schema: description: API is the Schema for the apis API diff --git a/helm-charts/templates/data-plane/config-deployer/wso2-apk-config-deployer-api.yaml b/helm-charts/templates/data-plane/config-deployer/wso2-apk-config-deployer-api.yaml index f81c8731d..46338fdca 100644 --- a/helm-charts/templates/data-plane/config-deployer/wso2-apk-config-deployer-api.yaml +++ b/helm-charts/templates/data-plane/config-deployer/wso2-apk-config-deployer-api.yaml @@ -15,7 +15,7 @@ # under the License. {{- if and .Values.wso2.apk.dp.enabled .Values.wso2.apk.dp.configdeployer.enabled }} kind: "API" -apiVersion: "dp.wso2.com/v1beta1" +apiVersion: "dp.wso2.com/v1alpha3" metadata: name: "{{ template "apk-helm.resource.prefix" . }}-wso2-apk-config-deployer-api" namespace: {{ .Release.Namespace }} diff --git a/helm-charts/templates/data-plane/config-deployer/wso2-apk-config-generator-api.yaml b/helm-charts/templates/data-plane/config-deployer/wso2-apk-config-generator-api.yaml index 3835db775..729311014 100644 --- a/helm-charts/templates/data-plane/config-deployer/wso2-apk-config-generator-api.yaml +++ b/helm-charts/templates/data-plane/config-deployer/wso2-apk-config-generator-api.yaml @@ -15,7 +15,7 @@ # under the License. {{- if and .Values.wso2.apk.dp.enabled .Values.wso2.apk.dp.configdeployer.enabled }} kind: "API" -apiVersion: "dp.wso2.com/v1beta1" +apiVersion: "dp.wso2.com/v1alpha3" metadata: name: "{{ template "apk-helm.resource.prefix" . }}-wso2-apk-config-generator-api" namespace: {{ .Release.Namespace }} diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/api/notification-api.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/api/notification-api.yaml index f6c677cc0..558f8af60 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/api/notification-api.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/api/notification-api.yaml @@ -16,7 +16,7 @@ {{- if and .Values.wso2.apk.dp.enabled .Values.wso2.apk.dp.commonController }} kind: "API" -apiVersion: "dp.wso2.com/v1beta1" +apiVersion: "dp.wso2.com/v1alpha3" metadata: name: "{{ template "apk-helm.resource.prefix" . }}-wso2-apk-notification-api" namespace: {{ .Release.Namespace }} diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml index 92a0934c8..f254504fd 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml @@ -31,14 +31,14 @@ webhooks: service: name: {{ template "apk-helm.resource.prefix" . }}-common-controller-service namespace: {{ .Release.Namespace }} - path: /mutate-dp-wso2-com-v1beta1-api + path: /mutate-dp-wso2-com-v1alpha3-api failurePolicy: Fail name: mapi.kb.io rules: - apiGroups: - dp.wso2.com apiVersions: - - v1beta1 + - v1alpha3 operations: - CREATE - UPDATE diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml index 6b0aa2146..3bec9878d 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml @@ -51,14 +51,14 @@ webhooks: service: name: {{ template "apk-helm.resource.prefix" . }}-common-controller-service namespace: {{ .Release.Namespace }} - path: /validate-dp-wso2-com-v1beta1-api + path: /validate-dp-wso2-com-v1alpha3-api failurePolicy: Fail name: vapi.kb.io rules: - apiGroups: - dp.wso2.com apiVersions: - - v1beta1 + - v1alpha3 operations: - CREATE - UPDATE diff --git a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/jwks-domain-api.yaml b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/jwks-domain-api.yaml index 4e97cb924..f88b83845 100644 --- a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/jwks-domain-api.yaml +++ b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/jwks-domain-api.yaml @@ -15,7 +15,7 @@ # under the License. {{- if .Values.idp.enabled }} kind: "API" -apiVersion: "dp.wso2.com/v1beta1" +apiVersion: "dp.wso2.com/v1alpha3" metadata: name: {{ template "apk-helm.resource.prefix" . }}-jwks-endpoint-ds-api namespace: {{ .Release.Namespace }} diff --git a/helm-charts/templates/idp/authenticationEndpoint-domain-api.yaml b/helm-charts/templates/idp/authenticationEndpoint-domain-api.yaml index 4d4325330..4e2195e42 100644 --- a/helm-charts/templates/idp/authenticationEndpoint-domain-api.yaml +++ b/helm-charts/templates/idp/authenticationEndpoint-domain-api.yaml @@ -15,7 +15,7 @@ # under the License. {{- if .Values.idp.enabled }} kind: "API" -apiVersion: "dp.wso2.com/v1beta1" +apiVersion: "dp.wso2.com/v1alpha3" metadata: name: {{ template "apk-helm.resource.prefix" . }}-authentication-endpoint-ds-api namespace: {{ .Release.Namespace }} diff --git a/helm-charts/templates/idp/commonoauth-domain-api.yaml b/helm-charts/templates/idp/commonoauth-domain-api.yaml index cdd7a2a6d..07a37772a 100644 --- a/helm-charts/templates/idp/commonoauth-domain-api.yaml +++ b/helm-charts/templates/idp/commonoauth-domain-api.yaml @@ -15,7 +15,7 @@ # under the License. {{- if .Values.idp.enabled }} kind: "API" -apiVersion: "dp.wso2.com/v1beta1" +apiVersion: "dp.wso2.com/v1alpha3" metadata: name: {{ template "apk-helm.resource.prefix" . }}-commonoauth-api namespace: {{ .Release.Namespace }} diff --git a/helm-charts/templates/idp/dcr-domain-api.yaml b/helm-charts/templates/idp/dcr-domain-api.yaml index aa6d70eb3..6507dccc7 100644 --- a/helm-charts/templates/idp/dcr-domain-api.yaml +++ b/helm-charts/templates/idp/dcr-domain-api.yaml @@ -15,7 +15,7 @@ # under the License. {{- if .Values.idp.enabled }} kind: "API" -apiVersion: "dp.wso2.com/v1beta1" +apiVersion: "dp.wso2.com/v1alpha3" metadata: name: {{ template "apk-helm.resource.prefix" . }}-dcr-api namespace: {{ .Release.Namespace }} diff --git a/helm-charts/templates/idp/oauth-domain-api.yaml b/helm-charts/templates/idp/oauth-domain-api.yaml index f67fecbb4..0a45aad4f 100644 --- a/helm-charts/templates/idp/oauth-domain-api.yaml +++ b/helm-charts/templates/idp/oauth-domain-api.yaml @@ -15,7 +15,7 @@ # under the License. {{- if .Values.idp.enabled }} kind: "API" -apiVersion: "dp.wso2.com/v1beta1" +apiVersion: "dp.wso2.com/v1alpha3" metadata: name: {{ template "apk-helm.resource.prefix" . }}-oauth-api namespace: {{ .Release.Namespace }} diff --git a/runtime/config-deployer-service/ballerina/K8sClient.bal b/runtime/config-deployer-service/ballerina/K8sClient.bal index f0d10722a..ed1219c0d 100644 --- a/runtime/config-deployer-service/ballerina/K8sClient.bal +++ b/runtime/config-deployer-service/ballerina/K8sClient.bal @@ -57,7 +57,7 @@ isolated function getConfigMapValueFromNameAndNamespace(string name, string name } isolated function deleteAPICR(string name, string namespace) returns http:Response|http:ClientError { - string endpoint = "/apis/dp.wso2.com/v1beta1/namespaces/" + namespace + "/apis/" + name; + string endpoint = "/apis/dp.wso2.com/v1alpha3/namespaces/" + namespace + "/apis/" + name; return k8sApiServerEp->delete(endpoint, targetType = http:Response); } @@ -112,12 +112,12 @@ isolated function deleteConfigMap(string name, string namespace) returns http:Re } isolated function deployAPICR(model:API api, string namespace) returns http:Response|http:ClientError { - string endpoint = "/apis/dp.wso2.com/v1beta1/namespaces/" + namespace + "/apis"; + string endpoint = "/apis/dp.wso2.com/v1alpha3/namespaces/" + namespace + "/apis"; return k8sApiServerEp->post(endpoint, api, targetType = http:Response); } isolated function updateAPICR(model:API api, string namespace) returns http:Response|http:ClientError { - string endpoint = "/apis/dp.wso2.com/v1beta1/namespaces/" + namespace + "/apis/" + api.metadata.name; + string endpoint = "/apis/dp.wso2.com/v1alpha3/namespaces/" + namespace + "/apis/" + api.metadata.name; return k8sApiServerEp->put(endpoint, api, targetType = http:Response); } @@ -152,7 +152,7 @@ isolated function updateGqlRoute(model:GQLRoute gqlroute, string namespace) retu } public isolated function getK8sAPIByNameAndNamespace(string name, string namespace) returns model:API?|commons:APKError { - string endpoint = "/apis/dp.wso2.com/v1beta1/namespaces/" + namespace + "/apis/" + name; + string endpoint = "/apis/dp.wso2.com/v1alpha3/namespaces/" + namespace + "/apis/" + name; do { http:Response response = check k8sApiServerEp->get(endpoint); if response.statusCode == 200 { diff --git a/runtime/config-deployer-service/ballerina/modules/model/API.bal b/runtime/config-deployer-service/ballerina/modules/model/API.bal index d7f6008b8..2fd19f850 100644 --- a/runtime/config-deployer-service/ballerina/modules/model/API.bal +++ b/runtime/config-deployer-service/ballerina/modules/model/API.bal @@ -18,7 +18,7 @@ public type API record { string kind = "API"; - string apiVersion = "dp.wso2.com/v1beta1"; + string apiVersion = "dp.wso2.com/v1alpha3"; Metadata metadata; APISpec spec; APIStatus? status = (); @@ -62,7 +62,7 @@ public type EnvConfig record { }; public type APIList record { - string apiVersion = "dp.wso2.com/v1beta1"; + string apiVersion = "dp.wso2.com/v1alpha3"; string kind = "APIList"; API[] items; ListMeta metadata; diff --git a/test/cucumber-tests/src/test/resources/artifacts/apk-confs/apikey/apikey-different-header.apk-conf b/test/cucumber-tests/src/test/resources/artifacts/apk-confs/apikey/apikey-different-header.apk-conf new file mode 100644 index 000000000..949e4829d --- /dev/null +++ b/test/cucumber-tests/src/test/resources/artifacts/apk-confs/apikey/apikey-different-header.apk-conf @@ -0,0 +1,32 @@ +name: "EmployeeServiceAPI" +basePath: "/employee" +version: "3.14" +id: "apikey-different-header" +type: "REST" +defaultVersion: false +endpointConfigurations: + production: + endpoint: "http://backend:80/anything" +operations: + - target: "/employee" + verb: "GET" + secured: false + scopes: [] + - target: "/employee" + verb: "POST" + secured: true + scopes: [] + - target: "/employee/{employeeId}" + verb: "PUT" + secured: true + scopes: [] + - target: "/employee/{employeeId}" + verb: "DELETE" + secured: true + scopes: [] +authentication: + - authType: APIKey + enabled: true + required: mandatory + headerEnable: true + headerName: "Test-Header" diff --git a/test/cucumber-tests/src/test/resources/artifacts/apk-confs/apikey/apikey-enabled.apk-conf b/test/cucumber-tests/src/test/resources/artifacts/apk-confs/apikey/apikey-enabled.apk-conf new file mode 100644 index 000000000..e3e3673de --- /dev/null +++ b/test/cucumber-tests/src/test/resources/artifacts/apk-confs/apikey/apikey-enabled.apk-conf @@ -0,0 +1,32 @@ +name: "EmployeeServiceAPI" +basePath: "/employee" +id: "apikey-enabled" +version: "3.14" +type: "REST" +defaultVersion: false +endpointConfigurations: + production: + endpoint: "http://backend:80/anything" +operations: + - target: "/employee" + verb: "GET" + secured: false + scopes: [] + - target: "/employee" + verb: "POST" + secured: true + scopes: [] + - target: "/employee/{employeeId}" + verb: "PUT" + secured: true + scopes: [] + - target: "/employee/{employeeId}" + verb: "DELETE" + secured: true + scopes: [] +authentication: + - authType: APIKey + enabled: true + required: mandatory + headerEnable: true + headerName: "APIKey"