diff --git a/common-go-libs/apis/dp/v1alpha1/api_conversion.go b/common-go-libs/apis/dp/v1alpha1/api_conversion.go index 4de702be00..a1a1f90873 100644 --- a/common-go-libs/apis/dp/v1alpha1/api_conversion.go +++ b/common-go-libs/apis/dp/v1alpha1/api_conversion.go @@ -87,6 +87,24 @@ func (src *API) ConvertFrom(srcRaw conversion.Hub) error { src.Spec.Organization = dst.Spec.Organization src.Spec.SystemAPI = dst.Spec.SystemAPI + if dst.Spec.Production != nil { + src.Spec.Production = []EnvConfig{} + for _, productionRef := range dst.Spec.Production { + src.Spec.Production = append(src.Spec.Production, EnvConfig{ + HTTPRouteRefs: productionRef.RouteRefs, + }) + } + } + + if dst.Spec.Sandbox != nil { + src.Spec.Sandbox = []EnvConfig{} + for _, sandboxRef := range dst.Spec.Sandbox { + src.Spec.Sandbox = append(src.Spec.Sandbox, EnvConfig{ + HTTPRouteRefs: sandboxRef.RouteRefs, + }) + } + } + // Convert []Property to []v1alpha1.Property var properties []Property for _, p := range dst.Spec.APIProperties { diff --git a/test/integration/integration/tests/resources/tests/prod-and-sand-apis.yaml b/test/integration/integration/tests/resources/tests/prod-and-sand-apis.yaml index 82c99b6402..8f0fb1da50 100644 --- a/test/integration/integration/tests/resources/tests/prod-and-sand-apis.yaml +++ b/test/integration/integration/tests/resources/tests/prod-and-sand-apis.yaml @@ -14,7 +14,7 @@ # specific language governing permissions and limitations # under the License. -apiVersion: dp.wso2.com/v1alpha2 +apiVersion: dp.wso2.com/v1alpha1 kind: API metadata: name: prod-and-sand-apis @@ -26,7 +26,7 @@ spec: basePath: /prod-sand-test-api/v1 #definitionFileRef: definition-file production: - - routeRefs: + - httpRouteRefs: - prod-httproute organization: wso2-org --- @@ -116,7 +116,7 @@ spec: port: 8080 --- # To test whether we can successfully update already existing API with sandbox endpoints. -apiVersion: dp.wso2.com/v1alpha2 +apiVersion: dp.wso2.com/v1alpha1 kind: API metadata: name: prod-and-sand-apis @@ -128,9 +128,9 @@ spec: basePath: /prod-sand-test-api/v1 #definitionFileRef: definition-file production: - - routeRefs: + - httpRouteRefs: - prod-httproute sandbox: - - routeRefs: + - httpRouteRefs: - sand-httproute organization: wso2-org