Skip to content

Commit 48b0c59

Browse files
author
krish
committed
few
1 parent 124b78e commit 48b0c59

13 files changed

+3170
-0
lines changed

test/Ballerina.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
org = "tharindud"
3+
name = "runtime_domain_service"
4+
version = "0.1.0"
5+
distribution = "2201.2.0"
6+
7+
[build-options]
8+
observabilityIncluded = true

test/Dependencies.toml

+301
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
# AUTO-GENERATED FILE. DO NOT MODIFY.
2+
3+
# This file is auto-generated by Ballerina for managing dependency versions.
4+
# It should not be modified by hand.
5+
6+
[ballerina]
7+
dependencies-toml-version = "2"
8+
9+
[[package]]
10+
org = "ballerina"
11+
name = "auth"
12+
version = "2.4.0"
13+
dependencies = [
14+
{org = "ballerina", name = "crypto"},
15+
{org = "ballerina", name = "jballerina.java"},
16+
{org = "ballerina", name = "lang.array"},
17+
{org = "ballerina", name = "lang.string"},
18+
{org = "ballerina", name = "log"},
19+
{org = "ballerina", name = "regex"}
20+
]
21+
22+
[[package]]
23+
org = "ballerina"
24+
name = "cache"
25+
version = "3.2.2"
26+
dependencies = [
27+
{org = "ballerina", name = "jballerina.java"},
28+
{org = "ballerina", name = "task"},
29+
{org = "ballerina", name = "time"}
30+
]
31+
32+
[[package]]
33+
org = "ballerina"
34+
name = "constraint"
35+
version = "1.0.0"
36+
dependencies = [
37+
{org = "ballerina", name = "jballerina.java"}
38+
]
39+
modules = [
40+
{org = "ballerina", packageName = "constraint", moduleName = "constraint"}
41+
]
42+
43+
[[package]]
44+
org = "ballerina"
45+
name = "crypto"
46+
version = "2.2.2"
47+
dependencies = [
48+
{org = "ballerina", name = "jballerina.java"},
49+
{org = "ballerina", name = "time"}
50+
]
51+
52+
[[package]]
53+
org = "ballerina"
54+
name = "file"
55+
version = "1.4.0"
56+
dependencies = [
57+
{org = "ballerina", name = "io"},
58+
{org = "ballerina", name = "jballerina.java"},
59+
{org = "ballerina", name = "log"},
60+
{org = "ballerina", name = "os"},
61+
{org = "ballerina", name = "regex"},
62+
{org = "ballerina", name = "time"}
63+
]
64+
65+
[[package]]
66+
org = "ballerina"
67+
name = "http"
68+
version = "2.4.3"
69+
dependencies = [
70+
{org = "ballerina", name = "auth"},
71+
{org = "ballerina", name = "cache"},
72+
{org = "ballerina", name = "constraint"},
73+
{org = "ballerina", name = "crypto"},
74+
{org = "ballerina", name = "file"},
75+
{org = "ballerina", name = "io"},
76+
{org = "ballerina", name = "jballerina.java"},
77+
{org = "ballerina", name = "jwt"},
78+
{org = "ballerina", name = "lang.array"},
79+
{org = "ballerina", name = "lang.decimal"},
80+
{org = "ballerina", name = "lang.int"},
81+
{org = "ballerina", name = "lang.runtime"},
82+
{org = "ballerina", name = "lang.string"},
83+
{org = "ballerina", name = "lang.value"},
84+
{org = "ballerina", name = "log"},
85+
{org = "ballerina", name = "mime"},
86+
{org = "ballerina", name = "oauth2"},
87+
{org = "ballerina", name = "observe"},
88+
{org = "ballerina", name = "regex"},
89+
{org = "ballerina", name = "time"},
90+
{org = "ballerina", name = "url"}
91+
]
92+
modules = [
93+
{org = "ballerina", packageName = "http", moduleName = "http"}
94+
]
95+
96+
[[package]]
97+
org = "ballerina"
98+
name = "io"
99+
version = "1.3.0"
100+
dependencies = [
101+
{org = "ballerina", name = "jballerina.java"},
102+
{org = "ballerina", name = "lang.value"}
103+
]
104+
modules = [
105+
{org = "ballerina", packageName = "io", moduleName = "io"}
106+
]
107+
108+
[[package]]
109+
org = "ballerina"
110+
name = "jballerina.java"
111+
version = "0.0.0"
112+
113+
[[package]]
114+
org = "ballerina"
115+
name = "jwt"
116+
version = "2.4.0"
117+
dependencies = [
118+
{org = "ballerina", name = "cache"},
119+
{org = "ballerina", name = "crypto"},
120+
{org = "ballerina", name = "jballerina.java"},
121+
{org = "ballerina", name = "lang.int"},
122+
{org = "ballerina", name = "lang.string"},
123+
{org = "ballerina", name = "log"},
124+
{org = "ballerina", name = "regex"},
125+
{org = "ballerina", name = "time"}
126+
]
127+
128+
[[package]]
129+
org = "ballerina"
130+
name = "lang.__internal"
131+
version = "0.0.0"
132+
dependencies = [
133+
{org = "ballerina", name = "jballerina.java"},
134+
{org = "ballerina", name = "lang.object"}
135+
]
136+
137+
[[package]]
138+
org = "ballerina"
139+
name = "lang.array"
140+
version = "0.0.0"
141+
dependencies = [
142+
{org = "ballerina", name = "jballerina.java"},
143+
{org = "ballerina", name = "lang.__internal"}
144+
]
145+
146+
[[package]]
147+
org = "ballerina"
148+
name = "lang.decimal"
149+
version = "0.0.0"
150+
dependencies = [
151+
{org = "ballerina", name = "jballerina.java"}
152+
]
153+
154+
[[package]]
155+
org = "ballerina"
156+
name = "lang.int"
157+
version = "0.0.0"
158+
dependencies = [
159+
{org = "ballerina", name = "jballerina.java"}
160+
]
161+
162+
[[package]]
163+
org = "ballerina"
164+
name = "lang.object"
165+
version = "0.0.0"
166+
167+
[[package]]
168+
org = "ballerina"
169+
name = "lang.runtime"
170+
version = "0.0.0"
171+
dependencies = [
172+
{org = "ballerina", name = "jballerina.java"}
173+
]
174+
175+
[[package]]
176+
org = "ballerina"
177+
name = "lang.string"
178+
version = "0.0.0"
179+
dependencies = [
180+
{org = "ballerina", name = "jballerina.java"}
181+
]
182+
183+
[[package]]
184+
org = "ballerina"
185+
name = "lang.value"
186+
version = "0.0.0"
187+
dependencies = [
188+
{org = "ballerina", name = "jballerina.java"}
189+
]
190+
191+
[[package]]
192+
org = "ballerina"
193+
name = "log"
194+
version = "2.4.1"
195+
dependencies = [
196+
{org = "ballerina", name = "io"},
197+
{org = "ballerina", name = "jballerina.java"},
198+
{org = "ballerina", name = "lang.value"},
199+
{org = "ballerina", name = "observe"}
200+
]
201+
202+
[[package]]
203+
org = "ballerina"
204+
name = "mime"
205+
version = "2.4.0"
206+
dependencies = [
207+
{org = "ballerina", name = "io"},
208+
{org = "ballerina", name = "jballerina.java"},
209+
{org = "ballerina", name = "lang.int"}
210+
]
211+
212+
[[package]]
213+
org = "ballerina"
214+
name = "oauth2"
215+
version = "2.4.1"
216+
dependencies = [
217+
{org = "ballerina", name = "cache"},
218+
{org = "ballerina", name = "crypto"},
219+
{org = "ballerina", name = "jballerina.java"},
220+
{org = "ballerina", name = "log"},
221+
{org = "ballerina", name = "time"}
222+
]
223+
224+
[[package]]
225+
org = "ballerina"
226+
name = "observe"
227+
version = "1.0.5"
228+
dependencies = [
229+
{org = "ballerina", name = "jballerina.java"}
230+
]
231+
232+
[[package]]
233+
org = "ballerina"
234+
name = "os"
235+
version = "1.4.0"
236+
dependencies = [
237+
{org = "ballerina", name = "io"},
238+
{org = "ballerina", name = "jballerina.java"}
239+
]
240+
241+
[[package]]
242+
org = "ballerina"
243+
name = "regex"
244+
version = "1.3.0"
245+
dependencies = [
246+
{org = "ballerina", name = "jballerina.java"},
247+
{org = "ballerina", name = "lang.string"}
248+
]
249+
250+
[[package]]
251+
org = "ballerina"
252+
name = "task"
253+
version = "2.2.2"
254+
dependencies = [
255+
{org = "ballerina", name = "jballerina.java"},
256+
{org = "ballerina", name = "time"}
257+
]
258+
259+
[[package]]
260+
org = "ballerina"
261+
name = "time"
262+
version = "2.2.2"
263+
dependencies = [
264+
{org = "ballerina", name = "jballerina.java"}
265+
]
266+
267+
[[package]]
268+
org = "ballerina"
269+
name = "url"
270+
version = "2.2.2"
271+
dependencies = [
272+
{org = "ballerina", name = "jballerina.java"}
273+
]
274+
275+
[[package]]
276+
org = "ballerinai"
277+
name = "observe"
278+
version = "0.0.0"
279+
dependencies = [
280+
{org = "ballerina", name = "jballerina.java"},
281+
{org = "ballerina", name = "observe"}
282+
]
283+
modules = [
284+
{org = "ballerinai", packageName = "observe", moduleName = "observe"}
285+
]
286+
287+
[[package]]
288+
org = "tharindud"
289+
name = "runtime_domain_service"
290+
version = "0.1.0"
291+
dependencies = [
292+
{org = "ballerina", name = "constraint"},
293+
{org = "ballerina", name = "http"},
294+
{org = "ballerina", name = "io"},
295+
{org = "ballerinai", name = "observe"}
296+
]
297+
modules = [
298+
{org = "tharindud", packageName = "runtime_domain_service", moduleName = "runtime_domain_service"}
299+
]
300+
301+

test/Dockerfile

Whitespace-only changes.

test/K8sClient.bal

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import ballerina/http;
2+
import ballerina/io;
3+
4+
const string K8S_API_ENDPOINT = "/api/v1";
5+
final http:Client k8sApiServerEp = check initializeK8sClient();
6+
final string k8sHost = "kubernetes.default";
7+
final string token = check io:fileReadString("/var/run/secrets/kubernetes.io/serviceaccount/token");
8+
9+
function init() {
10+
}
11+
12+
function initializeK8sClient() returns http:Client|error {
13+
http:Client k8sApiClient = check new ("https://" + k8sHost + "/ " + K8S_API_ENDPOINT,
14+
auth = {
15+
token: token
16+
},
17+
secureSocket = {
18+
cert: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
19+
20+
}
21+
);
22+
return k8sApiClient;
23+
}
24+
25+
isolated function getServicesListFromK8s(string namespace) returns ServiceList|error {
26+
Service[] serviceNames = [];
27+
string endpoint = "namespaces/" + namespace + "/services";
28+
error|json serviceResp = k8sApiServerEp->get(endpoint, targetType = json);
29+
if (serviceResp is json) {
30+
json[] serviceArr = <json[]>check serviceResp.items;
31+
foreach json i in serviceArr {
32+
Service serviceData = {
33+
name: <string>check i.metadata.name,
34+
namespace: <string>check i.metadata.namespace,
35+
'type: <string>check i.spec.'type
36+
};
37+
serviceNames.push(serviceData);
38+
}
39+
ServiceList serviceList = {
40+
list: serviceNames
41+
};
42+
return serviceList;
43+
}
44+
return error("error while retrieving service list from K8s API server for namespace : " +
45+
namespace);
46+
}

test/PetStore1.pdf

-150 KB
Binary file not shown.

0 commit comments

Comments
 (0)