Skip to content

Commit

Permalink
Fix issues in the version of v1alpha1 of API CR
Browse files Browse the repository at this point in the history
  • Loading branch information
pubudu538 committed Mar 13, 2024
1 parent e77cbef commit c8c1669
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
18 changes: 18 additions & 0 deletions common-go-libs/apis/dp/v1alpha1/api_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,7 +26,7 @@ spec:
basePath: /prod-sand-test-api/v1
#definitionFileRef: definition-file
production:
- routeRefs:
- httpRouteRefs:
- prod-httproute
organization: wso2-org
---
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit c8c1669

Please sign in to comment.