-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-values.ts
122 lines (113 loc) · 2.64 KB
/
generate-values.ts
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
// deno-lint-ignore-file no-explicit-any
import { stringify } from "https://deno.land/[email protected]/encoding/yaml.ts";
import { encode } from "https://deno.land/[email protected]/encoding/hex.ts";
function randomHex(lenght = 16): string {
const bs = new Uint8Array(lenght);
crypto.getRandomValues(bs);
return new TextDecoder().decode(encode(bs));
}
function buildValues(): any {
const namespace = prompt("Namespace:");
const name = prompt("Name: ");
const host = new URL(prompt("Enter host:")!);
const values: any = {
common: {
config: {
protocol: host.protocol,
hostname: host.hostname,
port: host.port || 443,
},
},
core: {
config: {
jwtSecret: randomHex(),
},
},
eat: {
config: {
sessionSecret: randomHex(),
},
},
runner: {
config: {
hmacSecret: randomHex(),
},
},
mysql: {
auth: {
password: randomHex(),
rootPassword: randomHex(),
},
},
runnerMysql: {
auth: {
password: randomHex(),
rootPassword: randomHex(),
},
},
runnerPostgres: {
auth: {
password: randomHex(),
postgresPassword: randomHex(),
},
},
runnerPlaygroundPostgres: {
auth: {
password: randomHex(),
postgresPassword: randomHex(),
},
},
checkerMongodb: {
auth: {
password: randomHex(),
rootPassword: randomHex(),
},
},
minio: {
auth: {
rootPassword: randomHex(),
},
},
digitalClassroom: {
enabled: false,
},
playgroundSharePostgres: {
auth: {
password: randomHex(),
postgresPassword: randomHex(),
},
},
};
if (confirm("Configure digital classroom:")) {
const internal = confirm("Launch internal digital classroom:");
if (internal) {
values.digitalClassroom.config = {
jwtSecret: randomHex(),
secret: randomHex(),
bbb: {
url: prompt("Enter BBB Url:"),
secret: prompt("Enter BBB Secret:"),
},
};
} else {
values.core.config.digitalClassroom = {
url: prompt("Enter Classroom Url:"),
secret: prompt("Enter Classroom Secret:"),
};
}
}
return { namespace, name, values };
}
if (Deno.args.length < 1) {
throw new Error("argument for output is required");
}
const { name, namespace, values } = buildValues();
Deno.writeFileSync(
Deno.args[0],
new TextEncoder().encode(stringify(values)),
);
console.log(
`Install with helm install -f ${
Deno.args[0]
} -n ${namespace} --create-namespace ${name} <chart name>`,
);