Skip to content

Commit 049ff65

Browse files
authored
Merge pull request #595 from renuka-fernando/200-scenarios
Add Scenarios Resources
2 parents aaffa56 + 4ee90ce commit 049ff65

File tree

12 files changed

+522
-26
lines changed

12 files changed

+522
-26
lines changed

api-operator/deploy/sample-definitions/wso2_v1alpha2_api_cr.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ metadata:
2121
spec:
2222
swaggerConfigMapName: petstore-cm
2323
paramsValues: params-cm
24-
certsValues: certs-cm
24+
certsValues: certs-cm

api-operator/deploy/sample-definitions/wso2_v1alpha2_targetendpoint_cr.yaml

+10-9
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@
1717
apiVersion: wso2.com/v1alpha2
1818
kind: TargetEndpoint
1919
metadata:
20-
name: products-privatejet
20+
name: products
2121
labels:
22-
app: wso2
22+
app: products-backend
2323
spec:
2424
applicationProtocol: http
2525
ports:
2626
- name: prod-ep
2727
port: 80
28-
targetPort: 9090
28+
targetPort: 8080
2929
deploy:
30-
name: products-pj-service
31-
dockerImage: pubudu/products:1.0.0
30+
name: products
31+
dockerImage: cakebakery/products:v1
3232
minReplicas: 2
3333
maxReplicas: 3
34-
requestCPU: "60m"
35-
reqMemory: "32Mi"
36-
cpuLimit: "120m"
37-
mode: privateJet
34+
requestCPU: "2m"
35+
reqMemory: "10Mi"
36+
cpuLimit: "5m"
37+
memoryLimit: "20Mi"
38+
mode: privateJet

api-operator/pkg/envoy/constants.go

+16
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,19 @@ const (
3939
apiOperatorConfigHome = "API_OPERATOR_CONFIG_HOME"
4040
apiOperatorDefaultConfigHome = "/usr/local/bin"
4141
)
42+
43+
// constants related to API-CTL project
44+
// TODO: use API-CTL code to init project
45+
const (
46+
apiYamlFile = "api.yaml"
47+
swaggerDefinitionFile = "Definitions/swagger.yaml"
48+
deploymentEnvFile = "deployment_environments.yaml"
49+
// TODO: use API-CTL code to init project
50+
deploymentEnvFileData = `type: deployment_environments
51+
version: v4.0.0
52+
data:
53+
-
54+
displayOnDevportal: true
55+
deploymentEnvironment: Default
56+
`
57+
)

api-operator/pkg/envoy/utils.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ func getSwaggerData(config *corev1.ConfigMap) (string, func(), error) {
231231
}
232232

233233
swaggerDirectory, _ := ioutil.TempDir("", "api-swagger-dir*")
234-
apiYamlPath := filepath.Join(swaggerDirectory, filepath.FromSlash("api.yaml"))
235-
swaggerSavePath := filepath.Join(swaggerDirectory, filepath.FromSlash("Definitions/swagger.yaml"))
234+
apiYamlPath := filepath.Join(swaggerDirectory, filepath.FromSlash(apiYamlFile))
235+
swaggerSavePath := filepath.Join(swaggerDirectory, filepath.FromSlash(swaggerDefinitionFile))
236+
deploymentEnvPath := filepath.Join(swaggerDirectory, filepath.FromSlash(deploymentEnvFile))
236237
errCreateDirectory := createDirectories(swaggerDirectory)
237238
if errCreateDirectory != nil {
238239
return "", nil, errCreateDirectory
@@ -245,6 +246,10 @@ func getSwaggerData(config *corev1.ConfigMap) (string, func(), error) {
245246
if err != nil {
246247
return "", nil, err
247248
}
249+
err = ioutil.WriteFile(deploymentEnvPath, []byte(deploymentEnvFileData), os.ModePerm)
250+
if err != nil {
251+
return "", nil, err
252+
}
248253
swaggerZipFile, err, cleanupFunc := utils.CreateZipFileFromProject(swaggerDirectory, false)
249254
if err != nil {
250255
return "", nil, err

operatorhub-resources/api-operator/2.0.0/api-operator.v2.0.0.clusterserviceversion.yaml

+1-13
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,7 @@ spec:
192192
requests:
193193
cpu: 250m
194194
memory: 250Mi
195-
volumeMounts:
196-
- mountPath: /home/wso2/security/
197-
name: operator-vol
198195
serviceAccountName: api-operator
199-
volumes:
200-
- name: operator-vol
201-
secret:
202-
items:
203-
- key: tls.key
204-
path: tls.key
205-
- key: tls.crt
206-
path: tls.crt
207-
secretName: operator-secret
208196
permissions:
209197
- rules:
210198
- apiGroups:
@@ -340,7 +328,7 @@ spec:
340328
maintainers:
341329
342330
name: WSO2 product releases
343-
maturity: 2.x-stable
331+
maturity: stable
344332
provider:
345333
name: WSO2
346334
version: 2.0.0

operatorhub-resources/api-operator/api-operator.package.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
packageName: api-operator
1818
channels:
19-
- name: stable
19+
- name: 1.x-stable
2020
currentCSV: api-operator.v1.2.2
2121
- name: 2.x-stable
2222
currentCSV: api-operator.v2.0.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2021 WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
2+
#
3+
# WSO2 Inc. licenses this file to you under the Apache License,
4+
# Version 2.0 (the "License"); you may not use this file except
5+
# in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http:www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing,
11+
# software distributed under the License is distributed on an
12+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
# KIND, either express or implied. See the License for the
14+
# specific language governing permissions and limitations
15+
# under the License.
16+
17+
apiVersion: wso2.com/v1alpha2
18+
kind: API
19+
metadata:
20+
name: products-api
21+
spec:
22+
swaggerConfigMapName: products-cm
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Copyright (c) 2021 WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
2+
#
3+
# WSO2 Inc. licenses this file to you under the Apache License,
4+
# Version 2.0 (the "License"); you may not use this file except
5+
# in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http:www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing,
11+
# software distributed under the License is distributed on an
12+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
# KIND, either express or implied. See the License for the
14+
# specific language governing permissions and limitations
15+
# under the License.
16+
17+
openapi: 3.0.0
18+
servers:
19+
- description: Localhost
20+
url: http://localhost:8080
21+
info:
22+
description: This is a sample backend - products
23+
version: v1
24+
title: Products
25+
contact:
26+
27+
tags:
28+
- name: product
29+
description: Products of store
30+
x-wso2-production-endpoints:
31+
urls:
32+
- http://products
33+
type: http
34+
x-wso2-sandbox-endpoints:
35+
urls:
36+
- http://products
37+
type: http
38+
x-wso2-basePath: /products-api/v1
39+
paths:
40+
/products:
41+
get:
42+
tags:
43+
- product
44+
summary: All Products
45+
description: All products of the store
46+
responses:
47+
200:
48+
description: Successful operation
49+
content:
50+
application/json:
51+
schema:
52+
type: array
53+
items:
54+
$ref: "#/components/schemas/Product"
55+
post:
56+
tags:
57+
- product
58+
summary: Add Product
59+
description: Add new products to the store
60+
requestBody:
61+
content:
62+
applicatoin/json:
63+
schema:
64+
$ref: "#/components/schemas/Product"
65+
66+
responses:
67+
200:
68+
description: Successful operation
69+
content:
70+
application/json:
71+
schema:
72+
$ref: "#/components/schemas/Product"
73+
400:
74+
description: Invalid Product
75+
/products/{id}:
76+
get:
77+
tags:
78+
- product
79+
summary: Find product by ID
80+
description: Returns a single product
81+
parameters:
82+
- name: id
83+
in: path
84+
description: ID of product to return
85+
required: true
86+
schema:
87+
type: integer
88+
format: int64
89+
example: 3
90+
responses:
91+
200:
92+
description: successful operation
93+
content:
94+
application/json:
95+
schema:
96+
$ref: "#/components/schemas/Product"
97+
400:
98+
description: Invalid ID supplied
99+
404:
100+
description: Product not found
101+
put:
102+
tags:
103+
- product
104+
summary: Update product by ID
105+
description: Update a product
106+
parameters:
107+
- name: id
108+
in: path
109+
description: ID of product to update
110+
required: true
111+
schema:
112+
type: integer
113+
format: int64
114+
example: 3
115+
requestBody:
116+
content:
117+
applicatoin/json:
118+
schema:
119+
$ref: "#/components/schemas/Product"
120+
responses:
121+
200:
122+
description: successful operation
123+
content:
124+
application/json:
125+
schema:
126+
$ref: "#/components/schemas/Product"
127+
400:
128+
description: Invalid ID supplied
129+
404:
130+
description: Product not found
131+
delete:
132+
tags:
133+
- product
134+
summary: Delete product by ID
135+
description: Delete a product
136+
parameters:
137+
- name: id
138+
in: path
139+
description: ID of product to delete
140+
required: true
141+
schema:
142+
type: integer
143+
format: int64
144+
example: 3
145+
responses:
146+
200:
147+
description: successful operation
148+
content:
149+
application/json:
150+
schema:
151+
$ref: "#/components/schemas/Result"
152+
400:
153+
description: Invalid ID supplied
154+
404:
155+
description: Product not found
156+
components:
157+
schemas:
158+
Product:
159+
type: object
160+
required:
161+
- name
162+
- category
163+
- price
164+
properties:
165+
id:
166+
type: integer
167+
format: int64
168+
example: 3
169+
name:
170+
type: string
171+
example: ABC Smart TV
172+
category:
173+
type: string
174+
example: Electronics
175+
price:
176+
type: integer
177+
format: int64
178+
example: 39999
179+
Result:
180+
type: object
181+
properties:
182+
result:
183+
type: string
184+
example: success
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (c) 2021 WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
2+
#
3+
# WSO2 Inc. licenses this file to you under the Apache License,
4+
# Version 2.0 (the "License"); you may not use this file except
5+
# in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http:www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing,
11+
# software distributed under the License is distributed on an
12+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
# KIND, either express or implied. See the License for the
14+
# specific language governing permissions and limitations
15+
# under the License.
16+
17+
apiVersion: wso2.com/v1alpha2
18+
kind: TargetEndpoint
19+
metadata:
20+
name: products
21+
labels:
22+
app: products-backend
23+
spec:
24+
applicationProtocol: http
25+
ports:
26+
- name: prod-ep
27+
port: 80
28+
targetPort: 8080
29+
deploy:
30+
name: products
31+
dockerImage: cakebakery/products:v1
32+
minReplicas: 2
33+
maxReplicas: 3
34+
requestCPU: "2m"
35+
reqMemory: "10Mi"
36+
cpuLimit: "5m"
37+
memoryLimit: "20Mi"
38+
mode: privateJet
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2021 WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
2+
#
3+
# WSO2 Inc. licenses this file to you under the Apache License,
4+
# Version 2.0 (the "License"); you may not use this file except
5+
# in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http:www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing,
11+
# software distributed under the License is distributed on an
12+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
# KIND, either express or implied. See the License for the
14+
# specific language governing permissions and limitations
15+
# under the License.
16+
17+
apiVersion: wso2.com/v1alpha2
18+
kind: API
19+
metadata:
20+
name: cert-products
21+
spec:
22+
certsValues: cert-products-certs
23+
paramsValues: cert-products-params
24+
swaggerConfigMapName: cert-products-cm

0 commit comments

Comments
 (0)