-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathform.vue
553 lines (522 loc) · 12.4 KB
/
form.vue
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
<template>
<v-form>
<v-container>
<v-tabs
v-model="tab"
style="margin-bottom: 30px;"
>
<v-tab value="general">General</v-tab>
<v-tab value="podsizes">Podsizes</v-tab>
<v-tab value="runpacks">Runpacks</v-tab>
<v-tab value="deployment">Deployment</v-tab>
<v-tab value="templates">Templates</v-tab>
<v-tab value="notifications">Notifications</v-tab>
</v-tabs>
<v-window v-model="tab">
<v-window-item value="general">
<FormGeneral :settings="settings.settings" :secrets="settings.secrets"></FormGeneral>
</v-window-item>
<v-window-item value="podsizes">
<FormPodsizes :settings="settings.settings"></FormPodsizes>
</v-window-item>
<v-window-item value="runpacks">
<FormBuildpacks :settings="settings.settings"></FormBuildpacks>
</v-window-item>
<v-window-item value="deployment">
<FormDeployment :settings="settings"></FormDeployment>
</v-window-item>
<v-window-item value="templates">
<FormTemplates :settings="settings.settings"></FormTemplates>
</v-window-item>
<v-window-item value="notifications">
<FormNotifications :settings="settings.settings"></FormNotifications>
</v-window-item>
</v-window>
<v-btn
color="primary"
@click="saveSettings"
style="margin-left: 10px; margin-top: 20px;"
>update configuration</v-btn>
</v-container>
</v-form>
</template>
<script lang="ts">
import axios from "axios";
import { defineComponent } from 'vue'
import FormGeneral from './form-general.vue'
import FormPodsizes from './form-podsizes.vue'
import FormBuildpacks from './form-buildpacks.vue'
import FormDeployment from './form-deployment.vue'
import FormTemplates from './form-templates.vue'
import FormNotifications from './form-notifications.vue'
// types & interfaces
export interface Secrets {
GITHUB_BASEURL: string;
GITHUB_PERSONAL_ACCESS_TOKEN: string;
GITEA_PERSONAL_ACCESS_TOKEN: string;
GITEA_BASEURL: string;
GITLAB_PERSONAL_ACCESS_TOKEN: string;
GITLAB_BASEURL: string;
BITBUCKET_APP_PASSWORD: string;
BITBUCKET_USERNAME: string;
GOGS_PERSONAL_ACCESS_TOKEN: string;
GOGS_BASEURL: string;
KUBERO_WEBHOOK_SECRET: string;
GITHUB_CLIENT_SECRET: string;
OAUTH2_CLIENT_SECRET: string;
}
export interface Settings {
settings: Kuberoes;
secrets: Secrets;
/*
repositoryProviders: RepositoryProviders;
webhook: Webhook;
/*
podSizeList?: (PodSize)[] | null;
kubero: Kubero;
buildpacks?: (Buildpack)[] | null;
templates: Templates;
auth: Auth;
auditLogs: AuditLogs;
env: Env;
*/
}
export interface Kuberoes {
affinity: any;
fullnameOverride: string;
image: Image;
imagePullSecrets?: (null)[] | null;
ingress: Ingress;
kubero: Kubero1;
nameOverride: string;
nodeSelector: any;
podAnnotations: any;
podSecurityContext: any;
registry: Registry;
replicaCount: number;
resources: any;
securityContext: any;
service: Service;
serviceAccount: ServiceAccount;
tolerations?: (null)[] | null;
}
export interface Image {
pullPolicy: string;
repository: string;
tag: string;
}
export interface Ingress {
annotations: any;
className: string;
enabled: boolean;
hosts?: (HostsEntity)[] | null;
tls?: (null)[] | null;
}
export interface HostsEntity {
host: string;
paths?: (PathsEntity)[] | null;
}
export interface PathsEntity {
path: string;
pathType: string;
}
export interface Kubero1 {
auditLogs: AuditLogs;
auth: Auth;
config: Config;
context: string;
debug: string;
namespace: string;
sessionKey: string;
webhook_url: string;
}
export interface AuditLogs {
accessModes?: (string)[] | null;
enabled: boolean;
limit: string;
size: string;
storageClassName: string;
}
export interface Github {
enabled: boolean;
id: string;
org: string;
secret: string;
callbackUrl: string;
}
export interface Oauth2 {
enabled: boolean;
name: string;
id: string;
authUrl: string;
tokenUrl: string;
secret: string;
callbackUrl: string;
scopes: string;
}
export interface Config {
buildpacks?: (Buildpack)[] | null;
clusterissuer: string;
kubero: Kubero;
podSizeList?: (PodSize)[] | null;
templates: Templates;
}
export type Buildpack = {
advanced?: boolean,
name: string,
language: string,
fetch: BuildpackStage,
build: BuildpackStage,
run: BuildpackStage
}
export type SecurityContext = {
runAsUser: number
runAsGroup: number
runAsNonRoot: boolean
readOnlyRootFilesystem: boolean
allowPrivilegeEscalation: boolean
capabilities: {
add: string[]
drop: string[]
}
}
export type BuildpackStage = {
repository: string,
tag: string,
command: string
readOnlyAppStorage: boolean
securityContext: SecurityContext
}
export interface Fetch {
repository: string;
securityContext: SecurityContext;
tag: string;
}
export interface Build {
command: string;
repository: string;
securityContext: SecurityContext;
tag: string;
}
export interface Run {
command: string;
readOnlyAppStorage: boolean;
repository: string;
securityContext: SecurityContext;
tag: string;
}
export interface Kubero {
banner: Banner;
console: {
enabled: boolean;
}
admin: {
disabled: boolean;
}
readonly: boolean;
}
export interface Banner {
bgcolor: string;
fontcolor: string;
message: string;
show: boolean;
}
export type PodSize = {
name: string,
description: string,
editable?: boolean,
default?: boolean,
resources: {
requests: {
cpu: string,
memory: string,
},
limits: {
cpu: string,
memory: string,
}
}
}
export interface Resources {
requests: RequestsOrLimits;
limits: RequestsOrLimits;
}
export interface RequestsOrLimits {
memory: string;
cpu: string;
}
export interface Templates {
catalogs?: (CatalogsEntity)[] | null;
enabled: boolean;
}
export interface CatalogsEntity {
description: string;
index: Index;
name: string;
templateBasePath: string;
}
export interface Index {
format: string;
url: string;
}
export interface Registry {
account: Account;
create: boolean;
enabled: boolean;
host: string;
port: number;
storage: string;
storageClassName?: null;
}
export interface Account {
hash: string;
password: string;
username: string;
}
export interface Service {
port: number;
type: string;
}
export interface ServiceAccount {
annotations: any;
create: boolean;
name: string;
}
export interface Webhook {
url: string;
secret: string;
}
export interface Auth {
github: Github;
oauth2: Oauth2;
}
export interface Oauth2 {
enabled: boolean;
name: string;
id: string;
authUrl: string;
tokenUrl: string;
secret: string;
callbackUrl: string;
scopes: string;
}
export interface AuditLogs {
enabled: boolean;
storageClassName: string;
accessModes?: (string)[] | null;
size: string;
limit: string;
}
export interface RepositoryProviders {
github: Github2;
gitea: GiteaOrGitlabOrGogs;
gitlab: GiteaOrGitlabOrGogs;
bitbucket: Bitbucket;
gogs: GiteaOrGitlabOrGogs;
}
export interface Github2 {
personalAccessToken: string;
}
export interface GiteaOrGitlabOrGogs {
personalAccessToken: string;
baseUrl: string;
}
export interface Bitbucket {
personalAccessToken: string;
username: string;
}
export type Catalog = {
name: string,
description: string,
templateBasePath: string,
index: {
url: string,
format: string
}
}
export type INotificationSlack = {
url: string;
channel: string;
}
export type INotificationWebhook = {
url: string;
secret: string;
}
export type INotificationDiscord = {
url: string;
}
export type Notification = {
name: string,
enabled: boolean,
type: 'slack' | 'webhook' | 'discord',
events: string[],
config: INotificationSlack | INotificationWebhook | INotificationDiscord,
}
export default defineComponent({
sockets: {
},
mounted() {
this.loadSettings();
},
data: () => ({
tab: "general",
show: false,
settings: {
secrets: {
GITHUB_BASEURL: '',
GITHUB_PERSONAL_ACCESS_TOKEN: '',
GITEA_PERSONAL_ACCESS_TOKEN: '',
GITEA_BASEURL: '',
GITLAB_PERSONAL_ACCESS_TOKEN: '',
GITLAB_BASEURL: '',
GOGS_PERSONAL_ACCESS_TOKEN: '',
GOGS_BASEURL: '',
BITBUCKET_APP_PASSWORD: '',
BITBUCKET_USERNAME: '',
KUBERO_WEBHOOK_SECRET: '',
GITHUB_CLIENT_SECRET: '',
OAUTH2_CLIENT_SECRET: '',
} as Secrets,
settings: {
affinity: {} as any,
fullnameOverride: '' as string,
image: {
pullPolicy: '',
repository: '',
tag: '',
} as Image,
imagePullSecrets: [],
ingress: {
annotations: {},
className: '',
enabled: false,
hosts: [],
tls: [],
} as Ingress,
kubero: {
namespace: '',
auditLogs: {
accessModes: ["ReadWriteOnce"],
enabled: false,
limit: '1000',
size: '0.1Gi',
storageClassName: '',
} as AuditLogs,
auth: {
github: {
enabled: false,
id: '',
secret: '',
callbackUrl: '',
org: '',
} as Github,
oauth2: {
enabled: false,
name: '',
id: '',
authUrl: '',
tokenUrl: '',
secret: '',
callbackUrl: '',
scopes: '',
} as Oauth2,
} as Auth,
config: {
buildpacks: [] as Buildpack[],
clusterissuer: '' as string,
notifications: [] as Notification[],
kubero: {
banner: {
bgcolor: '',
fontcolor: '',
message: '',
show: false,
} as Banner,
console: {
enabled: false,
},
admin: {
disabled: false,
},
readonly: false,
} as Kubero,
podSizeList: [] as PodSize[],
templates: {
catalogs: [] as Catalog[],
enabled: false,
} as Templates,
},
},
nameOverride: '',
nodeSelector: {} as any,
podAnnotations: {} as any,
podSecurityContext: {} as any,
registry: {
account: {
hash: '',
password: '',
username: '',
},
create: false,
enabled: false,
host: '',
port: 0,
storage: '',
storageClassName: null,
} as Registry,
replicaCount: 0,
resources: {} as any,
securityContext: {} as any,
service: {
port: 0,
type: '',
} as Service,
serviceAccount: {
annotations: {} as any,
create: false,
name: '',
} as ServiceAccount,
tolerations: [] as any,
},
},
}),
components: {
FormGeneral,
FormPodsizes,
FormBuildpacks,
FormDeployment,
FormTemplates,
FormNotifications,
},
methods: {
saveSettings() {
const self = this;
self.settings.settings.kubero.config.podSizeList.forEach((podSize: PodSize) => {
delete podSize.editable;
});
self.settings.settings.kubero.config.buildpacks.forEach((buildpack: Buildpack) => {
delete buildpack.advanced;
});
axios.post(`/api/settings`, self.settings)
.then(response => {
console.log('saveSettings', response);
})
.catch(error => {
console.log('saveSettings', error);
});
},
async loadSettings() {
const self = this;
axios.get(`/api/settings`)
.then(response => {
self.settings = response.data;
})
.catch(error => {
console.log('loadSettings', error);
});
}
},
})
</script>
<style lang="scss">
</style>