Skip to content

Commit

Permalink
Merge pull request #2372 from DDH13/feature/grpc-version
Browse files Browse the repository at this point in the history
Feature/grpc version
  • Loading branch information
AmaliMatharaarachchi authored May 14, 2024
2 parents a74c656 + 67186ff commit b07da78
Show file tree
Hide file tree
Showing 50 changed files with 3,208 additions and 162 deletions.
4 changes: 2 additions & 2 deletions adapter/internal/oasparser/envoyconf/internal_dtos.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package envoyconf

import (
"github.com/wso2/apk/adapter/internal/oasparser/model"
dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2"
dpv1beta1 "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1"
)

// routeCreateParams is the DTO used to provide information to the envoy route create function
Expand All @@ -41,7 +41,7 @@ type routeCreateParams struct {
isDefaultVersion bool
createDefaultPath bool
apiLevelRateLimitPolicy *model.RateLimitPolicy
apiProperties []dpv1alpha2.Property
apiProperties []dpv1beta1.Property
environment string
envType string
}
Expand Down
4 changes: 2 additions & 2 deletions adapter/internal/oasparser/envoyconf/routes_with_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2"
dpv1beta1 "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1"
"google.golang.org/protobuf/proto"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)
Expand Down Expand Up @@ -1555,7 +1555,7 @@ func getUpgradeConfig(apiType string) []*routev3.RouteAction_UpgradeConfig {
return upgradeConfig
}

func getAPIProperties(apiPropertiesConfig []dpv1alpha2.Property) string {
func getAPIProperties(apiPropertiesConfig []dpv1beta1.Property) string {
var apiProperties = make(map[string]string)
for _, val := range apiPropertiesConfig {
apiProperties[val.Name] = val.Value
Expand Down
38 changes: 19 additions & 19 deletions adapter/internal/oasparser/envoyconf/routes_with_clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/wso2/apk/adapter/internal/operator/synchronizer"
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"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8types "k8s.io/apimachinery/pkg/types"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand All @@ -39,16 +39,16 @@ import (

func TestCreateRoutesWithClustersWithExactAndRegularExpressionRules(t *testing.T) {
apiState := synchronizer.APIState{}
apiDefinition := v1alpha2.API{
apiDefinition := v1beta1.API{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "test-api-2",
},
Spec: v1alpha2.APISpec{
Spec: v1beta1.APISpec{
APIName: "test-api-2",
APIVersion: "2.0.0",
BasePath: "/test-api/2.0.0",
Production: []v1alpha2.EnvConfig{
Production: []v1beta1.EnvConfig{
{
RouteRefs: []string{
"test-api-2-prod-http-route",
Expand Down Expand Up @@ -211,16 +211,16 @@ func TestExtractAPIDetailsFromHTTPRouteForSpecificEnvironment(t *testing.T) {
func generateSampleAPI(apiName string, apiVersion string, basePath string) synchronizer.APIState {

apiState := synchronizer.APIState{}
apiDefinition := v1alpha2.API{
apiDefinition := v1beta1.API{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: apiName,
},
Spec: v1alpha2.APISpec{
Spec: v1beta1.APISpec{
APIName: apiName,
APIVersion: apiVersion,
BasePath: basePath,
Production: []v1alpha2.EnvConfig{
Production: []v1beta1.EnvConfig{
{
RouteRefs: []string{
apiName + "-prod-http-route",
Expand Down Expand Up @@ -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 := v1alpha2.API{
apiDefinition := v1beta1.API{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "test-api-1",
},
Spec: v1alpha2.APISpec{
Spec: v1beta1.APISpec{
APIName: "test-api",
APIVersion: "1.0.0",
BasePath: "/test-api/1.0.0",
Production: []v1alpha2.EnvConfig{
Production: []v1beta1.EnvConfig{
{
RouteRefs: []string{
"test-api-1-prod-http-route",
Expand Down Expand Up @@ -423,16 +423,16 @@ func TestCreateRoutesWithClustersWithMultiplePathPrefixRules(t *testing.T) {

func TestCreateRoutesWithClustersWithBackendTLSConfigs(t *testing.T) {
apiState := synchronizer.APIState{}
apiDefinition := v1alpha2.API{
apiDefinition := v1beta1.API{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "test-api-3",
},
Spec: v1alpha2.APISpec{
Spec: v1beta1.APISpec{
APIName: "test-api-3",
APIVersion: "1.0.0",
BasePath: "/test-api-3/1.0.0",
Production: []v1alpha2.EnvConfig{
Production: []v1beta1.EnvConfig{
{
RouteRefs: []string{
"test-api-3-prod-http-route",
Expand Down Expand Up @@ -546,16 +546,16 @@ func TestCreateHealthEndpoint(t *testing.T) {

func TestCreateRoutesWithClustersDifferentBackendRefs(t *testing.T) {
apiState := synchronizer.APIState{}
apiDefinition := v1alpha2.API{
apiDefinition := v1beta1.API{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "test-api-different-backendrefs",
},
Spec: v1alpha2.APISpec{
Spec: v1beta1.APISpec{
APIName: "test-api-different-backendrefs",
APIVersion: "1.0.0",
BasePath: "/test-api-different-backendrefs/1.0.0",
Production: []v1alpha2.EnvConfig{
Production: []v1beta1.EnvConfig{
{
RouteRefs: []string{
"test-api-different-backendrefs-prod-http-route",
Expand Down Expand Up @@ -638,16 +638,16 @@ func TestCreateRoutesWithClustersDifferentBackendRefs(t *testing.T) {

func TestCreateRoutesWithClustersSameBackendRefs(t *testing.T) {
apiState := synchronizer.APIState{}
apiDefinition := v1alpha2.API{
apiDefinition := v1beta1.API{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "test-api-same-backendrefs",
},
Spec: v1alpha2.APISpec{
Spec: v1beta1.APISpec{
APIName: "test-api-same-backendrefs",
APIVersion: "1.0.0",
BasePath: "/test-api-same-backendrefs/1.0.0",
Production: []v1alpha2.EnvConfig{
Production: []v1beta1.EnvConfig{
{
RouteRefs: []string{
"test-api-same-backendrefs-prod-http-route",
Expand Down
3 changes: 2 additions & 1 deletion adapter/internal/oasparser/model/adapter_internal_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/wso2/apk/adapter/internal/operator/utils"
dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1"
dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2"
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"
Expand Down Expand Up @@ -73,7 +74,7 @@ type AdapterInternalAPI struct {
apiDefinitionFile []byte
apiDefinitionEndpoint string
subscriptionValidation bool
APIProperties []dpv1alpha2.Property
APIProperties []dpv1beta1.Property
// GraphQLSchema string
// GraphQLComplexities GraphQLComplexityYaml
IsSystemAPI bool
Expand Down
3 changes: 2 additions & 1 deletion adapter/internal/oasparser/model/http_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/wso2/apk/adapter/internal/operator/utils"
dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1"
dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2"
dpv1beta1 "github.com/wso2/apk/common-go-libs/apis/dp/v1beta1"
"k8s.io/apimachinery/pkg/types"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)
Expand Down Expand Up @@ -309,7 +310,7 @@ func getAllowedOperations(httpMethod *gwapiv1.HTTPMethod, policies OperationPoli
}

// SetInfoAPICR populates ID, ApiType, Version and XWso2BasePath of adapterInternalAPI.
func (swagger *AdapterInternalAPI) SetInfoAPICR(api dpv1alpha2.API) {
func (swagger *AdapterInternalAPI) SetInfoAPICR(api dpv1beta1.API) {
swagger.UUID = string(api.ObjectMeta.UID)
swagger.title = api.Spec.APIName
swagger.apiType = api.Spec.APIType
Expand Down
180 changes: 179 additions & 1 deletion adapter/internal/operator/config/crd/bases/dp.wso2.com_apis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,184 @@ spec:
type: object
type: object
served: true
storage: 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: v1beta1
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 Async
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 OpenAPI 3 or SDL file
in gzipped format. 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:
httpRouteRefs:
description: HTTPRouteRefs denotes the environment of the API.
items:
type: string
type: array
required:
- httpRouteRefs
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:
httpRouteRefs:
description: HTTPRouteRefs denotes the environment of the API.
items:
type: string
type: array
required:
- httpRouteRefs
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: true
subresources:
status: {}
Loading

0 comments on commit b07da78

Please sign in to comment.