-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeno-runner.componentdefinition.yaml
233 lines (233 loc) · 7.03 KB
/
deno-runner.componentdefinition.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Based on https://github.com/bhavyastar/Napptive-OAM
# OAM component to run deno code from a given Git repository through a launcher container.
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
annotations:
definition.oam.dev/description: Component to deploy a deno application from a git repository.
name: deno-runner
spec:
schematic:
cue:
template: |
envs: [
{
name: "REPO_URL"
value: parameter.repoUrl
},
{
name: "ALLOW_NET"
if parameter["allowNet"] != _|_ {
value: "true"
}
if parameter["allowNet"] == _|_ {
value: ""
}
},
{
name: "ALLOW_SYS"
if parameter["allowSys"] != _|_ {
value: "true"
}
if parameter["allowSys"] == _|_ {
value: ""
}
},
{
name: "ALLOW_ENV"
if parameter["allowEnv"] != _|_ {
value: "true"
}
if parameter["allowEnv"] == _|_ {
value: ""
}
},
{
name: "ALLOW_HRTIME"
if parameter["allowhrTime"] != _|_ {
value: "true"
}
if parameter["allowhrTime"] == _|_ {
value: ""
}
},
{
name: "ALLOW_FFI"
if parameter["allowFfi"] != _|_ {
value: "true"
}
if parameter["allowFfi"] == _|_ {
value: ""
}
},
{
name: "ALLOW_READ"
if parameter["allowRead"] != _|_ {
value: "true"
}
if parameter["allowRead"] == _|_ {
value: ""
}
},
{
name: "ALLOW_WRITE"
if parameter["allowWrite"] != _|_ {
value: "true"
}
if parameter["allowWrite"] == _|_ {
value: ""
}
},
{
name: "ALLOW_RUN"
if parameter["allowRun"] != _|_ {
value: "true"
}
if parameter["allowRun"] == _|_ {
value: ""
}
},
{
name: "ALLOW_All"
if parameter["allowAll"] != _|_ {
value: "true"
}
if parameter["allowAll"] == _|_ {
value: ""
}
},
{
name: "DENO_PATH"
if parameter["denoPath"] != _|_ {
value: parameter.denoPath
}
if parameter["denoPath"] == _|_ {
value: ""
}
},
{
name: "ENTRYPOINT"
value: parameter.entryPoint
}
]
exposePortsMap: {
for v in parameter.ports {
"\(v.port)" : v.port,
}
for v in parameter.ingresses {
"\(v.targetPort)" : v.targetPort,
}
}
totalPorts: {
exposePorts: *[
for k, v in exposePortsMap {
{
port: v
targetPort: v
name: "port-" + k
}
},
] | []
}
containerPorts: {
exposePorts: *[
for k, v in exposePortsMap {
{
containerPort: v
protocol: "TCP"
name: "port-" + k
}
},
] | []
}
output: {
apiVersion: "apps/v1"
kind: "Deployment"
spec: {
selector: matchLabels: { "app.oam.dev/component": context.name }
template: {
metadata: labels: {
"app.oam.dev/name": context.appName
"app.oam.dev/component": context.name
}
spec: {
containers: [{
name: context.name
image: "napptive/deno-runner:1.35.3"
ports: containerPorts.exposePorts
env: envs
}]
}
}
}
}
outputs: {
if parameter["ports"] != _|_ || parameter["ingresses"] != _|_ {
serviceExpose: {
apiVersion: "v1"
kind: "Service"
metadata: name: context.name
spec: {
selector: "app.oam.dev/component": context.name
ports: totalPorts.exposePorts
}
}
}
if parameter["ingresses"] != _|_ {
for v, i in parameter.ingresses {
"objects-\(i.targetPort)": {
apiVersion: "core.napptive.com/v1alpha1"
kind: "Ingress"
metadata: name: context.name
spec: {
selector: "app.oam.dev/component": context.name
path: "/"
port: i.targetPort
protocol: "HTTP"
targetServiceName: context.name
}
}
}
}
}
parameter: {
// +usage=URL of the git repository
repoUrl: string
// +usage=Deno path indicates the path inside the repository where the deno code is found and should be used as working directory
denoPath?: string
// +usage=Which ports expect incoming traffic
ports: [...{
// +usage=Port to be exposed to accept incoming traffic in the environment
port: int
}]
// +usage=Allow network access
allowNet?: string
// +usage=Allow access to APIs that provide information about user’s operating system
allowSys?: string
// +usage=Allow environment access for things like getting and setting of environment variables
allowEnv?: string
// +usage=Allow high-resolution time measurement
allowhrTime?: string
// +usage=Allow loading of dynamic libraries
allowFfi?: string
// +usage=Allow file system read access
allowRead?: string
// +usage=Allow file system write access
allowWrite?: string
// +usage=Allow running subprocesses
allowRun?: string
// +usage=Allow all permissions
allowAll?: string
// +usage=File that must be passed to the deno run command as argument
entryPoint: string
// +usage=Which ports do you want to expose externally
ingresses: [...{
// +usage=Port to be exposed to the outside with an ingress
targetPort: int
}]
}
workload:
definition:
apiVersion: apps/v1
kind: Deployment
type: deployments.apps