forked from biersoeckli/QuickStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchisel.template.ts
More file actions
82 lines (76 loc) · 2.75 KB
/
chisel.template.ts
File metadata and controls
82 lines (76 loc) · 2.75 KB
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
import { Constants } from "@/shared/utils/constants";
import { AppTemplateContentModel, AppTemplateModel } from "../../model/app-template.model";
import { AppExtendedModel } from "@/shared/model/app-extended.model";
import crypto from "crypto";
export function getChiselAppTemplate(config?: {
appName?: string,
username?: string,
password?: string
}): AppTemplateContentModel {
return {
inputSettings: [
{
key: "containerImageSource",
label: "Container Image",
value: "jpillora/chisel:latest",
isEnvVar: false,
randomGeneratedIfEmpty: false,
},
{
key: "CHISEL_USER",
label: "Username",
value: config?.username || "chisel",
isEnvVar: true,
randomGeneratedIfEmpty: false,
},
{
key: "CHISEL_PASSWORD",
label: "Password",
value: config?.password || "",
isEnvVar: true,
randomGeneratedIfEmpty: true,
},
],
appModel: {
name: config?.appName || "Chisel Tunnel",
appType: 'APP',
sourceType: 'CONTAINER',
containerImageSource: "",
replicas: 1,
ingressNetworkPolicy: Constants.DEFAULT_INGRESS_NETWORK_POLICY_APPS,
egressNetworkPolicy: Constants.DEFAULT_EGRESS_NETWORK_POLICY_APPS,
envVars: ``,
useNetworkPolicy: true,
healthCheckPeriodSeconds: Constants.DEFAULT_HEALTH_CHECK_PERIOD_SECONDS,
healthCheckTimeoutSeconds: Constants.DEFAULT_HEALTH_CHECK_TIMEOUT_SECONDS,
healthCheckFailureThreshold: Constants.DEFAULT_HEALTH_CHECK_FAILURE_THRESHOLD,
containerArgs: '["server", "--keyfile", "/etc/chisel/chisel.key", "--auth", "$(CHISEL_USER):$(CHISEL_PASSWORD)", "--reverse"]',
},
appDomains: [],
appVolumes: [],
appFileMounts: [],
appPorts: [{
port: 8080,
}],
};
}
export const chiselAppTemplate: AppTemplateModel = {
name: "Chisel Tunnel",
iconName: 'chisel.svg',
templates: [
getChiselAppTemplate()
],
};
export const postCreateChiselAppTemplate = async (createdApps: AppExtendedModel[]): Promise<AppExtendedModel[]> => {
const app = createdApps[0];
const { privateKey } = crypto.generateKeyPairSync('ec', {
namedCurve: 'P-256',
privateKeyEncoding: { type: 'sec1', format: 'pem' },
publicKeyEncoding: { type: 'spki', format: 'pem' },
});
app.appFileMounts.push({
containerMountPath: '/etc/chisel/chisel.key',
content: privateKey,
} as any);
return [app];
};