@rocket.chat/houston 0.27.0-next.2 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +108 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +168 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +39 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +344 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +691 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +753 -0
- package/dist/core/lifecycle/request.js +525 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +868 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +369 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +67 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -192
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -25
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,896 @@
|
|
|
1
|
+
import { ctx } from "./shared.js";
|
|
2
|
+
|
|
3
|
+
// ---- where a workspace runs: the places, shared by Create and the Clusters page ----
|
|
4
|
+
// Populated from /api/settings, never from a list written here: two places deciding
|
|
5
|
+
// the same thing is how the dialog ends up offering a combination the service refuses.
|
|
6
|
+
let RUNTIMES = [];
|
|
7
|
+
|
|
8
|
+
const RUNTIME_LABEL = { docker: "Docker", kubernetes: "Kubernetes" };
|
|
9
|
+
function runtimeLabel(name) { return RUNTIME_LABEL[name] || name; }
|
|
10
|
+
|
|
11
|
+
// What the ARRANGEMENT builds, said under the control that chooses it. What a runtime
|
|
12
|
+
// cannot do is said once, by the absence line in More options, which is generated from
|
|
13
|
+
// the server's refusal registry.
|
|
14
|
+
const DEPLOYMENT_NOTE = {
|
|
15
|
+
monolith: "One Rocket.Chat process.",
|
|
16
|
+
"multi-instance": "Several Rocket.Chat containers behind a load balancer. Live updates "
|
|
17
|
+
+ "across them need an Enterprise license: without one, a message shows on the other "
|
|
18
|
+
+ "instances only after a reload.",
|
|
19
|
+
microservices: "Rocket.Chat plus presence, ddp-streamer, account, authorization "
|
|
20
|
+
+ "and stream-hub, each its own deployment. Needs an Enterprise license: without one, "
|
|
21
|
+
+ "every Rocket.Chat replica after the first stops.",
|
|
22
|
+
};
|
|
23
|
+
// The words on the Shape control. The VALUE is still the deployment name the CLI
|
|
24
|
+
// takes; only what a person reads is plain.
|
|
25
|
+
const SHAPE_LABEL = {
|
|
26
|
+
docker: { monolith: "One instance", "multi-instance": "Several instances" },
|
|
27
|
+
kubernetes: { microservices: "Microservices", monolith: "One pod" },
|
|
28
|
+
};
|
|
29
|
+
const DEPLOYMENT_LABEL = { monolith: "monolith", "multi-instance": "multi-instance", microservices: "microservices" };
|
|
30
|
+
|
|
31
|
+
function fmtGb(mb) {
|
|
32
|
+
return mb >= 1000 ? `${(mb / 1000).toFixed(1)} GB` : `${mb} MB`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The rows behind the cluster choice: the ones the GUI shows (local and AWS), and ALL
|
|
36
|
+
// of them -- the second only so "is the box default one the GUI cannot show" can be
|
|
37
|
+
// answered, which decides whether an empty context can be described truthfully.
|
|
38
|
+
let KUBE_CLUSTERS = [];
|
|
39
|
+
let ALL_KUBE_CLUSTERS = [];
|
|
40
|
+
// This machine's memory, from /api/machine: room per runtime, shown on the cards for
|
|
41
|
+
// the places that are on this machine and nowhere else.
|
|
42
|
+
let MACHINE_ROOM = null;
|
|
43
|
+
|
|
44
|
+
function clusterLabel(c) {
|
|
45
|
+
// `short` and `region` come from the SERVER: an EKS context is sixty-odd characters
|
|
46
|
+
// of ARN, and the name and region are the two a person needs.
|
|
47
|
+
const name = (c && c.short) || (c && c.context) || "";
|
|
48
|
+
const region = (c && c.region) || "";
|
|
49
|
+
return region ? `${name} (${region})` : name;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const PLACE_ICON = {
|
|
53
|
+
docker: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="3" y="10" width="18" height="9" rx="2"/><path d="M7 10V6h4v4M11 10V6h4v4"/></svg>',
|
|
54
|
+
k8s: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path d="M12 2.5 20.5 7v10L12 21.5 3.5 17V7z"/><circle cx="12" cy="12" r="3"/></svg>',
|
|
55
|
+
aws: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path d="M7 18h10a4 4 0 0 0 .6-7.96A6 6 0 0 0 6.1 9.2 4.5 4.5 0 0 0 7 18z"/></svg>',
|
|
56
|
+
plus: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>',
|
|
57
|
+
};
|
|
58
|
+
const icon = (name) => ctx.el("span", { class: "ico", html: PLACE_ICON[name] || "" });
|
|
59
|
+
const plural = (n, word) => `${n === 0 ? "No" : n} ${word}${n === 1 ? "" : "s"}`;
|
|
60
|
+
const perDay = (st) => (st && st.cost && st.cost.usd_hr ? st.cost.usd_hr * 24 : null);
|
|
61
|
+
|
|
62
|
+
// A cluster's state in the words both pages use, and the pill colour that goes with it.
|
|
63
|
+
function placeState(st) {
|
|
64
|
+
// "Reading…" only while a read is in flight: after a failed one it would never end.
|
|
65
|
+
if (!st) return ctx.CLSTATE && ctx.CLSTATE.overviewError ? ["off", "Not read"] : ["off", "Reading…"];
|
|
66
|
+
if (st.gone) return ["off", "Gone in AWS"];
|
|
67
|
+
if (st.reachable) return ["ok", "Running"];
|
|
68
|
+
if (st.reach_status === "denied") return ["warn", "Refusing"];
|
|
69
|
+
return ["warn", "Not answering"];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// What makes an EKS cluster want somebody, as one line. Not cost: a cluster you are
|
|
73
|
+
// deliberately paying for is doing its job. Idle AND billing is the exception, because
|
|
74
|
+
// that is money buying nothing.
|
|
75
|
+
function placeWarn(st) {
|
|
76
|
+
if (!st || st.gone) return "";
|
|
77
|
+
if (!st.reachable) return st.reach_why ? `${st.reach_why}.` : "";
|
|
78
|
+
// A reminder wants you once it is DUE, not three days out: a build given a short
|
|
79
|
+
// reminder was flagged the minute it was ready, above the DNS record it actually needed.
|
|
80
|
+
const d = st.expires_in_days;
|
|
81
|
+
if (typeof d === "number" && d < 0) return `Past its reminder date ${-d} day${d === -1 ? "" : "s"} ago. It keeps billing until someone deletes it.`;
|
|
82
|
+
if (d === 0) return "Its reminder date is today. It keeps billing until someone deletes it.";
|
|
83
|
+
// Before "holds no workspaces": a new cluster holds none BECAUSE its names do not answer
|
|
84
|
+
// yet, so the record is the next step, not deleting it.
|
|
85
|
+
if (st.zone && st.ready && st.ready.dns_answers === false) return `Public names under ${st.zone} do not answer yet.`;
|
|
86
|
+
const day = perDay(st);
|
|
87
|
+
if (day && st.made_by_houston === true && Array.isArray(st.workspaces) && !st.workspaces.length) {
|
|
88
|
+
return `Holds no workspaces and still bills ~$${day.toFixed(2)} a day. Delete it when you are done.`;
|
|
89
|
+
}
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function roomFor(runtime) {
|
|
94
|
+
const cap = MACHINE_ROOM;
|
|
95
|
+
if (!cap || !cap.known) return "";
|
|
96
|
+
if (runtime === "docker") return `room for ${cap.room} more`;
|
|
97
|
+
const spec = RUNTIMES.find((r) => r.name === "kubernetes");
|
|
98
|
+
const dep = spec ? spec.default_deployment : "microservices";
|
|
99
|
+
const n = (cap.room_by_runtime || {})[`kubernetes-${dep}`];
|
|
100
|
+
return typeof n === "number" ? `room for ${n} more` : "";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Where a workspace with no cluster named lands. The server tries its saved default first,
|
|
104
|
+
// then the cluster `up` picks on its own -- houston's own kind, else whatever kubectl points
|
|
105
|
+
// at if it answers -- which is what /api/kubernetes reports as `context`. Null when neither
|
|
106
|
+
// is known and answering. Reading only the saved default, a member was told "Unavailable"
|
|
107
|
+
// on a box whose k3s took every such workspace (measured on a k3s playground).
|
|
108
|
+
function emptyContextRow() {
|
|
109
|
+
const def = ALL_KUBE_CLUSTERS.find((c) => c.is_default);
|
|
110
|
+
if (def) return def;
|
|
111
|
+
const k = ctx.KUBE;
|
|
112
|
+
if (!k || !k.reachable || !k.context) return null;
|
|
113
|
+
return ALL_KUBE_CLUSTERS.find((c) => c.context === k.context) || null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Every place a workspace can go, as data: the Clusters page and step 1 of Create both
|
|
117
|
+
// draw these, so the two can never describe the same place differently.
|
|
118
|
+
function places({ inventory = false } = {}) {
|
|
119
|
+
const status = (ctx.CLSTATE && ctx.CLSTATE.status) || {};
|
|
120
|
+
const k = ctx.KUBE;
|
|
121
|
+
const here = [];
|
|
122
|
+
const aws = [];
|
|
123
|
+
const repros = ctx.ALL_REPROS || [];
|
|
124
|
+
if (!RUNTIMES.length || RUNTIMES.some((r) => r.name === "docker")) {
|
|
125
|
+
const n = repros.filter((r) => (r.runtime || "docker") === "docker").length;
|
|
126
|
+
here.push({ key: "docker", runtime: "docker", context: "", ico: "docker", nm: "Docker", wh: "On this server",
|
|
127
|
+
pill: ctx.DOCKER_OK === false ? ["warn", "Not answering"] : ["ok", "Ready"],
|
|
128
|
+
ds: ctx.DOCKER_OK === false ? "Docker is not answering on the server. houston doctor says why."
|
|
129
|
+
: "The quickest way to run Rocket.Chat. Right for most workspaces.",
|
|
130
|
+
facts: [plural(n, "workspace"), roomFor("docker")].filter(Boolean), usable: ctx.DOCKER_OK !== false });
|
|
131
|
+
}
|
|
132
|
+
const kube = !RUNTIMES.length || RUNTIMES.some((r) => r.name === "kubernetes");
|
|
133
|
+
if (!kube) return { here, aws, hiddenDefault: false };
|
|
134
|
+
const def = ALL_KUBE_CLUSTERS.find((c) => c.is_default);
|
|
135
|
+
const hiddenDefault = !!def && def.where === "elsewhere";
|
|
136
|
+
const may = inventory || ctx.MAY_SET_PRIVILEGED === true;
|
|
137
|
+
const clusterCard = (c) => {
|
|
138
|
+
const st = status[c.context];
|
|
139
|
+
const local = c.where === "local";
|
|
140
|
+
const held = st && Array.isArray(st.workspaces) ? plural(st.workspaces.length, "workspace") : "";
|
|
141
|
+
const dist = (st && st.distribution) || (c.ours ? "kind" : "");
|
|
142
|
+
const day = perDay(st);
|
|
143
|
+
return { key: (local ? "k8s:" : "eks:") + c.context, runtime: "kubernetes", context: c.context,
|
|
144
|
+
ico: local ? "k8s" : "aws", nm: local ? "Kubernetes" : (c.short || c.context),
|
|
145
|
+
wh: local ? ["On this server", dist, c.short || c.context].filter(Boolean).join(" · ")
|
|
146
|
+
: `Amazon EKS · ${(st && st.region) || c.region || "?"}`,
|
|
147
|
+
pill: placeState(st), cost: local ? null : day, costKnown: !local && !!st,
|
|
148
|
+
ds: local ? "Real pods and Helm charts on this server. Use it when what you are testing depends on Kubernetes." : "",
|
|
149
|
+
facts: [held, local ? roomFor("kubernetes") : clNodesText(st)].filter(Boolean),
|
|
150
|
+
warn: local ? "" : placeWarn(st), usable: !st || (!!st.reachable && !st.gone), row: c };
|
|
151
|
+
};
|
|
152
|
+
if (!may) {
|
|
153
|
+
// The box policy keeps the cluster choice to admins, so the form cannot send one: one
|
|
154
|
+
// card, "the server's default" -- and only where it can be said where that goes. A
|
|
155
|
+
// default the GUI does not show, or none and no kind to make one, is said, not offered.
|
|
156
|
+
const lands = emptyContextRow();
|
|
157
|
+
const known = !!lands && lands.where !== "elsewhere";
|
|
158
|
+
const makes = !lands && k && k.can_provision;
|
|
159
|
+
// With no saved default, where it lands is what the probe says -- and until the probe
|
|
160
|
+
// has answered that is unknown, not "Unavailable".
|
|
161
|
+
const reading = !lands && !ctx.KUBE_READ;
|
|
162
|
+
const card = { key: "k8s-default", runtime: "kubernetes", context: "", ico: lands && lands.where === "aws" ? "aws" : "k8s",
|
|
163
|
+
nm: "Kubernetes", wh: known ? `This server's default · ${clusterLabel(lands)}` : "This server's default cluster",
|
|
164
|
+
pill: known || makes ? ["ok", "Ready"] : reading ? ["off", "Reading…"] : ["off", "Unavailable"],
|
|
165
|
+
ds: known || makes ? "Choosing a cluster is kept to admins on this server, so this uses its default."
|
|
166
|
+
: reading ? "Reading this server's Kubernetes…"
|
|
167
|
+
: "Choosing a cluster is kept to admins on this server, and its default is set from the command line.",
|
|
168
|
+
facts: [], usable: !!(known || makes) };
|
|
169
|
+
if (lands && lands.where === "aws") aws.push(card); else here.push(card);
|
|
170
|
+
return { here, aws, hiddenDefault: !!lands && lands.where === "elsewhere", limited: true };
|
|
171
|
+
}
|
|
172
|
+
const locals = KUBE_CLUSTERS.filter((c) => c.where === "local");
|
|
173
|
+
for (const c of locals) here.push(clusterCard(c));
|
|
174
|
+
// The Clusters page draws before its list arrives, and a list it could not read is no list:
|
|
175
|
+
// neither is "no cluster on this machine" -- the card said so about a running k3s.
|
|
176
|
+
const unread = inventory && !locals.length && !ctx.CLUSTERS;
|
|
177
|
+
// A list that WAS read but from a kubeconfig the server could not open is no list
|
|
178
|
+
// either: a `chmod 000` on a running k3s's config was shown as "No cluster on this
|
|
179
|
+
// machine, and kind is not installed", while the server had sent the reason.
|
|
180
|
+
const unreadable = !locals.length && ctx.CLUSTERS && ctx.CLUSTERS.unreadable;
|
|
181
|
+
if (unreadable) {
|
|
182
|
+
here.push({ key: "k8s-none", runtime: "kubernetes", context: "", ico: "k8s", nm: "Kubernetes", wh: "On this server",
|
|
183
|
+
pill: ["warn", "Unreadable"], facts: [], usable: false,
|
|
184
|
+
ds: `This server's kubeconfig could not be read: ${unreadable}` });
|
|
185
|
+
} else if (unread) {
|
|
186
|
+
const why = ctx.CLSTATE && ctx.CLSTATE.listError;
|
|
187
|
+
here.push({ key: "k8s-none", runtime: "kubernetes", context: "", ico: "k8s", nm: "Kubernetes", wh: "On this server",
|
|
188
|
+
pill: why ? ["warn", "Not answering"] : ["off", "Reading…"], facts: [], usable: false,
|
|
189
|
+
ds: why ? `This server's Kubernetes contexts could not be read: ${why}. houston doctor says why.`
|
|
190
|
+
: "Reading this server's Kubernetes contexts…" });
|
|
191
|
+
} else if (!locals.length) {
|
|
192
|
+
// AN EMPTY CONTEXT IS OFFERED ONLY WHEN IT CAN BE SAID WHERE IT GOES. The server
|
|
193
|
+
// resolves "" to the box default first, so with a default set -- a remote cluster
|
|
194
|
+
// the GUI does not show, or an EKS one -- "a local cluster will be created" would be
|
|
195
|
+
// a false sentence about a real workspace.
|
|
196
|
+
const canMake = k && k.can_provision && !def;
|
|
197
|
+
if (canMake) {
|
|
198
|
+
here.push({ key: "k8s-new", runtime: "kubernetes", context: "", ico: "k8s", nm: "Kubernetes", wh: "On this server",
|
|
199
|
+
pill: ["off", "Not set up yet"], facts: [roomFor("kubernetes")].filter(Boolean), usable: true,
|
|
200
|
+
ds: "Houston sets up a cluster on this server the first time you create a Kubernetes workspace: about 3 minutes and 600 MB of memory." });
|
|
201
|
+
} else {
|
|
202
|
+
// Whether kind could make one is the probe's answer; before it, nothing is known.
|
|
203
|
+
const reading = !def && !ctx.KUBE_READ;
|
|
204
|
+
here.push({ key: "k8s-none", runtime: "kubernetes", context: "", ico: "k8s", nm: "Kubernetes", wh: "On this server",
|
|
205
|
+
pill: ["off", reading ? "Reading…" : k === null ? "Not checked" : "Unavailable"], facts: [], usable: false,
|
|
206
|
+
ds: def ? "No cluster on this server. Its default cluster is set elsewhere, so houston does not make one here."
|
|
207
|
+
: reading ? "Reading this server's Kubernetes…"
|
|
208
|
+
: k && k.tools_ready ? "No cluster on this server, and kind is not installed to make one. houston doctor shows what is missing."
|
|
209
|
+
: "Needs kubectl and helm on the server. houston doctor shows what is missing." });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
for (const c of KUBE_CLUSTERS.filter((x) => x.where === "aws")) aws.push(clusterCard(c));
|
|
213
|
+
return { here, aws, hiddenDefault };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function clNodesText(st) {
|
|
217
|
+
const shapes = st && st.instance_types ? Object.entries(st.instance_types) : [];
|
|
218
|
+
return shapes.length ? shapes.map(([t, n]) => `${n} × ${t || "unlabelled"}`).join(", ") : "";
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// One place, as a card body: the same markup on the Clusters page and in Create.
|
|
222
|
+
function placeBody(p) {
|
|
223
|
+
const out = [ctx.el("div", { class: "ph" }, icon(p.ico),
|
|
224
|
+
ctx.el("div", {}, ctx.el("div", { class: "nm" }, p.nm), ctx.el("div", { class: "wh" }, p.wh)))];
|
|
225
|
+
out.push(ctx.el("div", {}, ctx.el("span", { class: `pill ${p.pill[0]}` }, p.pill[1])));
|
|
226
|
+
if (p.cost !== null && p.cost !== undefined) {
|
|
227
|
+
out.push(ctx.el("div", { class: "cost" }, `~$${p.cost.toFixed(2)} `, ctx.el("small", {}, "a day" + (p.lastKnown ? ", last known" : ""))));
|
|
228
|
+
} else if (p.costKnown === false && p.ico === "aws") {
|
|
229
|
+
out.push(ctx.el("div", { class: "cost" }, ctx.el("small", {}, "bills by the hour")));
|
|
230
|
+
}
|
|
231
|
+
if (p.ds) out.push(ctx.el("p", { class: "ds" }, p.ds));
|
|
232
|
+
if (typeof p.progress === "number") out.push(ctx.el("div", { class: "progress" }, ctx.el("i", { style: `width:${p.progress}%` })));
|
|
233
|
+
if (p.facts && p.facts.length) out.push(ctx.el("div", { class: "facts" }, ...p.facts.map((f) => ctx.el("span", {}, f))));
|
|
234
|
+
if (p.warn) out.push(ctx.el("div", { class: "warnline" }, `▲ ${p.warn}`));
|
|
235
|
+
return out;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ---- Create a workspace: step 1, where it runs -----------------------------------
|
|
239
|
+
let DEST = ""; // the chosen place's key
|
|
240
|
+
let CREATE_STEP = 1;
|
|
241
|
+
let cardsAskedForOverview = false;
|
|
242
|
+
|
|
243
|
+
function destFor(key) {
|
|
244
|
+
const { here, aws } = places();
|
|
245
|
+
return [...here, ...aws].find((p) => p.key === key) || null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function zoneHead(title, tag, money) {
|
|
249
|
+
return ctx.el("div", { class: "zone-h" }, ctx.el("h2", {}, title),
|
|
250
|
+
ctx.el("span", { class: "tag" + (money ? " money" : "") }, tag));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function renderDestinations() {
|
|
254
|
+
const box = ctx.$("#dest-cards");
|
|
255
|
+
if (!box) return;
|
|
256
|
+
const { here, aws, hiddenDefault, limited } = places();
|
|
257
|
+
const all = [...here, ...aws];
|
|
258
|
+
if (!all.some((p) => p.key === DEST && p.usable)) DEST = (all.find((p) => p.usable) || { key: "" }).key;
|
|
259
|
+
const pick = (p) => {
|
|
260
|
+
const input = ctx.el("input", { type: "radio", name: "dest", value: p.key, "aria-label": `${p.nm}, ${p.wh}` });
|
|
261
|
+
input.checked = p.key === DEST;
|
|
262
|
+
input.disabled = !p.usable;
|
|
263
|
+
input.addEventListener("change", () => pickDest(p.key));
|
|
264
|
+
return ctx.el("label", { class: "pcard place", "data-dest": p.key }, input, ctx.el("span", { class: "radio" }), ...placeBody(p));
|
|
265
|
+
};
|
|
266
|
+
box.innerHTML = "";
|
|
267
|
+
box.append(zoneHead("On this server", "Free"), ctx.el("div", { class: "places" }, ...here.map(pick)));
|
|
268
|
+
const awsCards = aws.map(pick);
|
|
269
|
+
if (ctx.canAdmin() && !limited) {
|
|
270
|
+
awsCards.push(ctx.el("button", { type: "button", class: "pcard place add click", "data-dest": "add",
|
|
271
|
+
onclick: () => { ctx.$("#create-dialog").close(); ctx.openEksSetup(); } },
|
|
272
|
+
icon("plus"), ctx.el("div", { class: "nm" }, aws.length ? "Add an EKS cluster" : "Set up Amazon EKS"),
|
|
273
|
+
ctx.el("p", { class: "ds" }, "Opens the guided setup. This workspace waits.")));
|
|
274
|
+
} else if (!aws.length) {
|
|
275
|
+
awsCards.push(ctx.el("div", { class: "pcard place muted" }, ctx.el("div", { class: "nm" }, "Amazon EKS isn't set up"),
|
|
276
|
+
ctx.el("p", { class: "ds" }, limited ? "Choosing a cluster is kept to admins on this server."
|
|
277
|
+
: "An admin sets it up on the Clusters page.")));
|
|
278
|
+
}
|
|
279
|
+
box.append(zoneHead("In AWS", "Costs money", true), ctx.el("div", { class: "places" }, ...awsCards));
|
|
280
|
+
if (hiddenDefault) {
|
|
281
|
+
box.append(ctx.el("p", { class: "hint" }, "Other Kubernetes clusters on this server are used from the command line (",
|
|
282
|
+
ctx.el("code", {}, "--context"), ")."));
|
|
283
|
+
}
|
|
284
|
+
applyDest();
|
|
285
|
+
// What a cluster card says -- running, and for EKS what it costs -- comes from the
|
|
286
|
+
// overview; ask for it once if a card is still without it. Not only for EKS: a local
|
|
287
|
+
// k3s card said "Reading…" for as long as the dialog stayed open.
|
|
288
|
+
if (!cardsAskedForOverview && ctx.loadClusterOverview && !(ctx.CLSTATE && ctx.CLSTATE.overview)
|
|
289
|
+
&& KUBE_CLUSTERS.length) {
|
|
290
|
+
cardsAskedForOverview = true;
|
|
291
|
+
ctx.loadClusterOverview().then((ov) => { if (ov && CREATE_STEP === 1 && ctx.$("#create-dialog").open) renderDestinations(); }).catch(() => {});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function pickDest(key) {
|
|
296
|
+
DEST = key;
|
|
297
|
+
applyDest();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// The chosen place into the two fields the form sends, and what choosing it means.
|
|
301
|
+
function applyDest() {
|
|
302
|
+
const p = destFor(DEST);
|
|
303
|
+
const rt = ctx.$("#runtime-value");
|
|
304
|
+
const csel = ctx.$("#context-select");
|
|
305
|
+
if (p) {
|
|
306
|
+
if (rt.value !== p.runtime) {
|
|
307
|
+
rt.value = p.runtime;
|
|
308
|
+
// The new runtime's DEFAULT arrangement, unconditionally: `--runtime k8s` on the
|
|
309
|
+
// CLI defaults to microservices, and keeping Compose's monolith would diverge.
|
|
310
|
+
const spec = RUNTIMES.find((r) => r.name === p.runtime);
|
|
311
|
+
ctx.$("#deployment-value").value = spec ? spec.default_deployment : "";
|
|
312
|
+
}
|
|
313
|
+
if (csel) {
|
|
314
|
+
if (p.context && ![...csel.options].some((o) => o.value === p.context)) {
|
|
315
|
+
csel.append(ctx.el("option", { value: p.context }, p.context));
|
|
316
|
+
}
|
|
317
|
+
csel.value = p.context;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const note = ctx.$("#dest-note");
|
|
321
|
+
if (!note) return;
|
|
322
|
+
note.innerHTML = "";
|
|
323
|
+
note.className = "callout";
|
|
324
|
+
if (p && p.ico === "aws") {
|
|
325
|
+
note.classList.add("money");
|
|
326
|
+
note.append("▲ ", ctx.el("b", {}, p.nm), ` is shared and costs ${p.cost ? `about ~$${p.cost.toFixed(2)} a day` : "money by the hour"}`
|
|
327
|
+
+ " whether or not this workspace runs. Deleting the workspace doesn't stop the charge.");
|
|
328
|
+
note.hidden = false;
|
|
329
|
+
} else if (p && p.key === "k8s-new") {
|
|
330
|
+
note.classList.add("info");
|
|
331
|
+
note.append("Houston sets up a Kubernetes cluster on this server first (about 3 minutes), then creates the workspace on it.");
|
|
332
|
+
note.hidden = false;
|
|
333
|
+
} else note.hidden = true;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function whereText(p) {
|
|
337
|
+
if (!p) return "";
|
|
338
|
+
if (p.ico === "aws") return `${p.nm} · Amazon EKS`;
|
|
339
|
+
if (p.key === "docker") return "Docker · this server";
|
|
340
|
+
if (p.key === "k8s-new") return "Kubernetes · a new cluster on this server";
|
|
341
|
+
if (p.key === "k8s-default") return "Kubernetes · this server's default";
|
|
342
|
+
const rest = p.wh.replace(/^On this server( · )?/u, "");
|
|
343
|
+
return `Kubernetes${rest ? ` · ${rest}` : ""} · this server`;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// ---- Create a workspace: the steps ----------------------------------------------
|
|
347
|
+
function setCreateStep(n, back = false) {
|
|
348
|
+
CREATE_STEP = n;
|
|
349
|
+
for (const i of [1, 2, 3]) { const s = ctx.$(`#create-step-${i}`); if (s) s.hidden = i !== n; }
|
|
350
|
+
const sec = ctx.$(`#create-step-${n}`);
|
|
351
|
+
if (sec) { sec.classList.remove("anim", "back"); void sec.offsetWidth; sec.classList.add("anim"); if (back) sec.classList.add("back"); }
|
|
352
|
+
const steps = ctx.$("#create-steps");
|
|
353
|
+
steps.innerHTML = "";
|
|
354
|
+
["Where it runs", "Details"].forEach((label, i) => {
|
|
355
|
+
const at = i + 1;
|
|
356
|
+
const cls = n === 3 || at < n ? "done" : at === n ? "on" : "";
|
|
357
|
+
if (i) steps.append(ctx.el("span", { class: "ln" }));
|
|
358
|
+
steps.append(ctx.el("span", { class: cls }, ctx.el("i", {}, cls === "done" ? "✓" : String(at)), label));
|
|
359
|
+
});
|
|
360
|
+
const show = (id, on) => { const b = ctx.$(id); if (b) b.hidden = !on; };
|
|
361
|
+
show("#create-back", n === 2);
|
|
362
|
+
show("#create-cancel", n !== 2);
|
|
363
|
+
ctx.$("#create-cancel").textContent = n === 3 ? "Close" : "Cancel";
|
|
364
|
+
show("#create-next", n === 1);
|
|
365
|
+
show("#create-submit", n === 2);
|
|
366
|
+
show("#create-open-ws", false);
|
|
367
|
+
show("#create-open-rc", false);
|
|
368
|
+
show("#create-stop", false); // streamJob offers it once the job says it may stop
|
|
369
|
+
const hint = ctx.$("#create-foot-hint");
|
|
370
|
+
const p = destFor(DEST);
|
|
371
|
+
if (n === 1) hint.textContent = "Next: the Rocket.Chat version and what to set up.";
|
|
372
|
+
else if (n === 2) hint.textContent = createSummaryLine();
|
|
373
|
+
else hint.textContent = "You can close this; the workspace keeps starting and shows in the list.";
|
|
374
|
+
if (n === 2) {
|
|
375
|
+
const sum = ctx.$("#create-summary");
|
|
376
|
+
sum.innerHTML = "";
|
|
377
|
+
sum.append("Runs on ", ctx.el("b", {}, whereText(p)));
|
|
378
|
+
if (p && p.ico === "aws" && p.cost) sum.append(` · ~$${p.cost.toFixed(2)}/day, shared`);
|
|
379
|
+
renderRuntimeAxes();
|
|
380
|
+
syncHttpsFields();
|
|
381
|
+
// The place decides which presets it can take: one with no Kubernetes adapter is not
|
|
382
|
+
// offered on Kubernetes.
|
|
383
|
+
ctx.renderOptions();
|
|
384
|
+
}
|
|
385
|
+
const focus = n === 2 ? ctx.$("#create-form").version : sec && sec.querySelector(".wzd-q");
|
|
386
|
+
if (focus) focus.focus({ preventScroll: true });
|
|
387
|
+
ctx.$("#create-body").scrollTop = 0;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function createSummaryLine() {
|
|
391
|
+
const f = ctx.$("#create-form");
|
|
392
|
+
return [f.version.value.trim(), ctx.optionsPresetText() || "default", whereText(destFor(DEST))].filter(Boolean).join(" · ");
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// The arrangement control, for the chosen runtime, and the fields that follow it.
|
|
396
|
+
function renderRuntimeAxes() {
|
|
397
|
+
const rt = ctx.$("#runtime-value").value || (RUNTIMES[0] && RUNTIMES[0].name) || "docker";
|
|
398
|
+
const spec = RUNTIMES.find((r) => r.name === rt);
|
|
399
|
+
const seg = ctx.$("#deployment-seg");
|
|
400
|
+
seg.innerHTML = "";
|
|
401
|
+
const deployments = spec ? spec.deployments : [];
|
|
402
|
+
if (!deployments.includes(ctx.$("#deployment-value").value)) {
|
|
403
|
+
ctx.$("#deployment-value").value = spec ? spec.default_deployment : "";
|
|
404
|
+
}
|
|
405
|
+
for (const d of deployments) {
|
|
406
|
+
seg.append(ctx.el("button", { type: "button", "data-deployment": d,
|
|
407
|
+
"aria-pressed": String(ctx.$("#deployment-value").value === d), onclick: () => pickDeployment(d) },
|
|
408
|
+
(SHAPE_LABEL[rt] || {})[d] || d));
|
|
409
|
+
}
|
|
410
|
+
ctx.$("#runtime-hint").textContent = DEPLOYMENT_NOTE[ctx.$("#deployment-value").value] || "";
|
|
411
|
+
// The one control a runtime ADDS: whether this workspace's MongoDB requires a password.
|
|
412
|
+
const extra = ctx.$("#runtime-extra");
|
|
413
|
+
const ticked = !!(ctx.$("#mongo-operator") && ctx.$("#mongo-operator").checked);
|
|
414
|
+
extra.innerHTML = "";
|
|
415
|
+
if (rt === "kubernetes") {
|
|
416
|
+
const box = ctx.el("input", { type: "checkbox", name: "mongo_operator", id: "mongo-operator" });
|
|
417
|
+
box.checked = ticked;
|
|
418
|
+
extra.append(ctx.el("label", {}, box, " MongoDB with a password, via the official operator (MongoDB 6.0 or later)"));
|
|
419
|
+
}
|
|
420
|
+
syncAdvancedForRuntime(spec);
|
|
421
|
+
syncDeploymentFields();
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function pickRuntime(name) {
|
|
425
|
+
// Kept for callers that name a runtime rather than a place: the first usable place
|
|
426
|
+
// of that runtime.
|
|
427
|
+
const { here, aws } = places();
|
|
428
|
+
const p = [...here, ...aws].find((x) => x.runtime === name && x.usable);
|
|
429
|
+
if (p) pickDest(p.key);
|
|
430
|
+
renderRuntimeAxes();
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function pickDeployment(name) {
|
|
434
|
+
ctx.$("#deployment-value").value = name;
|
|
435
|
+
renderRuntimeAxes();
|
|
436
|
+
ctx.$("#create-foot-hint").textContent = createSummaryLine();
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const ADV_GONE_LABEL = {
|
|
440
|
+
https: "HTTPS", domain: "a public domain",
|
|
441
|
+
fresh: "rebuild and DELETE data",
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
function runsOnThisMachine() {
|
|
445
|
+
const p = destFor(DEST);
|
|
446
|
+
if (p) return p.ico !== "aws";
|
|
447
|
+
const csel = ctx.$("#context-select");
|
|
448
|
+
const chosen = csel && csel.value ? KUBE_CLUSTERS.find((c) => c.context === csel.value) : null;
|
|
449
|
+
return !chosen || !chosen.billable;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function syncLocalCaOption() {
|
|
453
|
+
// "Local certificate" cannot work on a cluster that is not on this machine: it would
|
|
454
|
+
// copy houston's CA PRIVATE KEY into somebody else's cluster, which the server refuses
|
|
455
|
+
// with GATE_UNAPPROVED_CLUSTER. Removed rather than left to be refused -- but only
|
|
456
|
+
// when we positively know, so uncertainty keeps a working choice.
|
|
457
|
+
const mode = ctx.$("#https-mode");
|
|
458
|
+
if (!mode) return;
|
|
459
|
+
const here = runsOnThisMachine();
|
|
460
|
+
const has = [...mode.options].some((o) => o.value === "local");
|
|
461
|
+
if (!here && has) {
|
|
462
|
+
if (mode.value === "local") { mode.value = ""; }
|
|
463
|
+
[...mode.options].find((o) => o.value === "local").remove();
|
|
464
|
+
syncHttpsFields();
|
|
465
|
+
} else if (here && !has) {
|
|
466
|
+
mode.append(ctx.el("option", { value: "local" },
|
|
467
|
+
"Local certificate: a browser on this server only, no domain (run houston trust-ca once)"));
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// The cluster this create goes to, or null for Docker.
|
|
472
|
+
function chosenCluster() {
|
|
473
|
+
const csel = ctx.$("#context-select");
|
|
474
|
+
if (!csel) return null;
|
|
475
|
+
return csel.value
|
|
476
|
+
? KUBE_CLUSTERS.find((c) => c.context === csel.value) || null
|
|
477
|
+
: (ctx.$("#runtime-value").value === "kubernetes" ? KUBE_CLUSTERS.find((c) => c.is_default) || null : null);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// The zone the SERVER will name this workspace from, or "". The server defaults
|
|
481
|
+
// <name>.<zone> only for a cluster named in the request -- an empty context is the box
|
|
482
|
+
// default, which it does not -- and reads the zone from THIS box's build note, which a
|
|
483
|
+
// cluster built elsewhere and connected here does not have. The dialog promising a name
|
|
484
|
+
// in either case sent a request the server answered without one.
|
|
485
|
+
function chosenZone() {
|
|
486
|
+
const csel = ctx.$("#context-select");
|
|
487
|
+
const chosen = chosenCluster();
|
|
488
|
+
if (!csel || !csel.value || !chosen || chosen.made_by_houston !== true) return "";
|
|
489
|
+
return ((ctx.CLSTATE && ctx.CLSTATE.status[chosen.context]) || {}).zone || "";
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// ON A CLUSTER WITH A DNS ZONE EVERY NEW WORKSPACE GETS A PUBLIC NAME: the server fills in
|
|
493
|
+
// <name>.<zone> when no domain is typed, and that name is served by Let's Encrypt, which
|
|
494
|
+
// needs a contact email. "Off" was offered there and the create then failed on the email
|
|
495
|
+
// nobody was asked for; it goes, Let's Encrypt is chosen, and the domain becomes optional.
|
|
496
|
+
let OFF_OPTION = null;
|
|
497
|
+
let ZONE_CHOSE_ACME = false;
|
|
498
|
+
function syncZoneHttps(zone) {
|
|
499
|
+
const mode = ctx.$("#https-mode");
|
|
500
|
+
if (!mode) return;
|
|
501
|
+
const domain = ctx.$("#create-form") && ctx.$("#create-form").domain;
|
|
502
|
+
const off = [...mode.options].find((o) => o.value === "");
|
|
503
|
+
const acme = [...mode.options].some((o) => o.value === "acme");
|
|
504
|
+
if (zone && acme) {
|
|
505
|
+
// Read BEFORE removing it: removing the selected option makes the browser select the
|
|
506
|
+
// first one left, Let's Encrypt, so "was it ours to change" could never be answered.
|
|
507
|
+
const wasOther = mode.value !== "acme";
|
|
508
|
+
if (off) { OFF_OPTION = off; off.remove(); }
|
|
509
|
+
if (wasOther) { mode.value = "acme"; ZONE_CHOSE_ACME = true; }
|
|
510
|
+
if (domain) domain.placeholder = `leave empty for <name>.${zone}`;
|
|
511
|
+
} else {
|
|
512
|
+
if (!off) mode.prepend(OFF_OPTION || ctx.el("option", { value: "" }, "Off: plain http on a port of this server, no certificate"));
|
|
513
|
+
if (ZONE_CHOSE_ACME) { mode.value = ""; ZONE_CHOSE_ACME = false; }
|
|
514
|
+
if (domain) domain.placeholder = "rc1.example.com";
|
|
515
|
+
}
|
|
516
|
+
syncHttpsFields();
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// What a managed cluster means for how the workspace is REACHED, said in Access where
|
|
520
|
+
// that is decided. The money was said in step 1, where the cluster was chosen.
|
|
521
|
+
function syncClusterNote() {
|
|
522
|
+
syncLocalCaOption();
|
|
523
|
+
syncZoneHttps(chosenZone());
|
|
524
|
+
const note = ctx.$("#cluster-note");
|
|
525
|
+
const csel = ctx.$("#context-select");
|
|
526
|
+
if (!note || !csel) return;
|
|
527
|
+
const chosen = chosenCluster();
|
|
528
|
+
if (!chosen || !chosen.billable) { note.hidden = true; return; }
|
|
529
|
+
const domain = ctx.$("#create-form").domain;
|
|
530
|
+
const hasDomain = !!(domain && domain.value.trim());
|
|
531
|
+
note.hidden = false;
|
|
532
|
+
note.innerHTML = "";
|
|
533
|
+
// One load balancer per cluster, made by Prepare: every public name goes through it.
|
|
534
|
+
note.append("A workspace on this cluster adds an EBS volume. Its public name goes through the cluster's "
|
|
535
|
+
+ "load balancer, which is already there.");
|
|
536
|
+
const zone = chosenZone();
|
|
537
|
+
if (!hasDomain && zone) {
|
|
538
|
+
note.append(ctx.el("br", {}), `Its public name is <name>.${zone} unless you type a domain below. `
|
|
539
|
+
+ "Let's Encrypt gives it a certificate, so it needs a contact email once.");
|
|
540
|
+
} else if (!hasDomain) {
|
|
541
|
+
note.append(ctx.el("br", {}), "Without a domain it opens only in a browser on the server itself, "
|
|
542
|
+
+ "through a port-forward that ends when its pod restarts. ");
|
|
543
|
+
note.append(ctx.el("button", { type: "button", class: "btn sm",
|
|
544
|
+
onclick: () => {
|
|
545
|
+
const mode = ctx.$("#https-mode");
|
|
546
|
+
if (mode && [...mode.options].some((o) => o.value === "acme")) { mode.value = "acme"; syncHttpsFields(); }
|
|
547
|
+
const d = ctx.$("#create-form").domain;
|
|
548
|
+
if (d) { d.scrollIntoView({ block: "center" }); d.focus(); }
|
|
549
|
+
} }, "Set a domain"));
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function syncAdvancedForRuntime(spec) {
|
|
554
|
+
const gone = new Set(((spec && spec.unsupported) || []).map((u) => u.field));
|
|
555
|
+
// HTTPS goes entirely only when HTTPS itself is refused; Kubernetes serves --https
|
|
556
|
+
// through the chart's Ingress and cannot do --domain, so only that mode goes.
|
|
557
|
+
const https = ctx.$("#create-https-block");
|
|
558
|
+
if (https) https.hidden = gone.has("https");
|
|
559
|
+
syncClusterNote();
|
|
560
|
+
const mode = ctx.$("#https-mode");
|
|
561
|
+
if (mode) {
|
|
562
|
+
const has = [...mode.options].some((o) => o.value === "acme");
|
|
563
|
+
if (gone.has("domain") && has) {
|
|
564
|
+
if (mode.value === "acme") mode.value = "";
|
|
565
|
+
[...mode.options].find((o) => o.value === "acme").remove();
|
|
566
|
+
syncHttpsFields();
|
|
567
|
+
} else if (!gone.has("domain") && !has) {
|
|
568
|
+
mode.append(ctx.el("option", { value: "acme" }, "Let's Encrypt: a public name that reaches this server"));
|
|
569
|
+
}
|
|
570
|
+
syncLocalCaOption();
|
|
571
|
+
}
|
|
572
|
+
// `fresh` is ONE OPTION of the existing-name select: reuse and force work on both
|
|
573
|
+
// runtimes, so the option goes and the control stays.
|
|
574
|
+
const existing = ctx.$("#create-form").existing;
|
|
575
|
+
if (existing) {
|
|
576
|
+
const has = [...existing.options].some((o) => o.value === "fresh");
|
|
577
|
+
if (gone.has("fresh") && has) {
|
|
578
|
+
if (existing.value === "fresh") existing.value = "reuse";
|
|
579
|
+
[...existing.options].find((o) => o.value === "fresh").remove();
|
|
580
|
+
} else if (!gone.has("fresh") && !has) {
|
|
581
|
+
existing.append(ctx.el("option", { value: "fresh" },
|
|
582
|
+
"Rebuild it and DELETE its data: users, channels, messages, uploads"));
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
const note = ctx.$("#adv-gone");
|
|
586
|
+
if (!note) return;
|
|
587
|
+
const named = [...gone].map((f) => ADV_GONE_LABEL[f] || f);
|
|
588
|
+
note.hidden = !named.length;
|
|
589
|
+
note.textContent = named.length
|
|
590
|
+
? "Not on this runtime: " + named.join(" · ")
|
|
591
|
+
+ ". Each is refused with its reason rather than accepted and dropped."
|
|
592
|
+
: "";
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function syncDeploymentFields() {
|
|
596
|
+
// --replicas means something on both runtimes, but nothing at all on a monolith.
|
|
597
|
+
// Offering a field that is silently ignored is how `--seed` and `--https` were
|
|
598
|
+
// quietly dropped on this runtime.
|
|
599
|
+
ctx.$("#replicas-row").hidden = ctx.$("#deployment-value").value === "monolith";
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// ---- HTTPS: certificate check ------------------------------------------------
|
|
603
|
+
const TLS_LABEL = {
|
|
604
|
+
local: "local CA (run trust-ca)",
|
|
605
|
+
acme: "Let's Encrypt",
|
|
606
|
+
own: "supplied certificate",
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
function doTlsStatus(name) {
|
|
610
|
+
return ctx.runAction(name, "Check the certificate", async () => {
|
|
611
|
+
const r = await ctx.api(`/api/repros/${name}/tls`);
|
|
612
|
+
const lines = [`${r.public_url}`, ""];
|
|
613
|
+
if (!r.serving) {
|
|
614
|
+
lines.push(`NOT serving TLS on this server's port ${r.port}`, ` ${r.error}`, "",
|
|
615
|
+
"This checks the TLS layer only, not Rocket.Chat itself.");
|
|
616
|
+
} else {
|
|
617
|
+
lines.push(`Issuer ${r.issuer || "?"}`, `Subject ${r.subject || "?"}`,
|
|
618
|
+
`Expires ${(r.dates || "").replace("notAfter=", "")}`, "");
|
|
619
|
+
if (r.fallback) {
|
|
620
|
+
// "NEVER SUCCEEDED" IS A CLAIM ABOUT THE PAST, and this check cannot see the
|
|
621
|
+
// past. An ingress controller serves its own placeholder for a name it has no
|
|
622
|
+
// certificate for YET, so on a fresh cluster this is the ordinary state for
|
|
623
|
+
// the first minute or three — the same thing the `self_signed` branch below
|
|
624
|
+
// already says correctly. Reported as a permanent failure it sends somebody
|
|
625
|
+
// hunting an ACME problem that resolves itself while they read the logs.
|
|
626
|
+
lines.push("This is the ingress controller's built-in placeholder "
|
|
627
|
+
+ "certificate, so cert-manager has not issued one for this name "
|
|
628
|
+
+ "yet.",
|
|
629
|
+
"On a fresh cluster that is normal for the first minute or three. "
|
|
630
|
+
+ "Check again; if it persists, the ACME order is stuck — the "
|
|
631
|
+
+ "workspace logs and `kubectl get certificate` in its namespace say "
|
|
632
|
+
+ "what it is waiting on.");
|
|
633
|
+
} else if (r.mode === "local") {
|
|
634
|
+
lines.push(r.trusted_via_ca ? "Serving houston's local CA."
|
|
635
|
+
: "WARNING: does not chain to houston's CA.");
|
|
636
|
+
lines.push(r.trusted ? "This server trusts it — trust-ca has been run."
|
|
637
|
+
: "Not trusted here yet: run `houston trust-ca` once.");
|
|
638
|
+
} else if (r.trusted) {
|
|
639
|
+
lines.push("Serving a certificate this server trusts.");
|
|
640
|
+
} else if (r.self_signed) {
|
|
641
|
+
// NOT a failure, and it used to be reported as one — "does not trust —
|
|
642
|
+
// normal for Let's Encrypt staging" on a workspace that was not using
|
|
643
|
+
// staging and had no certificate yet at all.
|
|
644
|
+
lines.push("Serving a self-signed certificate — nothing has issued one yet.",
|
|
645
|
+
"On Kubernetes the ingress serves its own until cert-manager "
|
|
646
|
+
+ "finishes, a minute or three after the workspace answers.");
|
|
647
|
+
} else if (r.staging) {
|
|
648
|
+
lines.push("Serving a real certificate that this server does not trust — "
|
|
649
|
+
+ "normal for Let's Encrypt staging.");
|
|
650
|
+
} else {
|
|
651
|
+
lines.push(`Serving a certificate this server does not trust, from `
|
|
652
|
+
+ `${r.issuer || "an unnamed issuer"}.`,
|
|
653
|
+
"That is neither staging nor a placeholder, so something else is "
|
|
654
|
+
+ "answering for this name — a proxy in front is the usual cause.");
|
|
655
|
+
}
|
|
656
|
+
if (r.public_issuer && r.public_issuer !== r.issuer) {
|
|
657
|
+
lines.push("", `The public name serves a DIFFERENT certificate (${r.public_issuer}).`,
|
|
658
|
+
"That is what a proxy in front looks like (Cloudflare orange cloud).");
|
|
659
|
+
} else if (r.public_error) {
|
|
660
|
+
lines.push("", `The public name is not reachable from here: ${r.public_error}`);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
ctx.$("#pat-title").textContent = `TLS: ${name}`;
|
|
664
|
+
ctx.$("#pat-body").textContent = lines.join("\n");
|
|
665
|
+
ctx.PAT_HEADERS = "";
|
|
666
|
+
ctx.$("#pat-dialog").showModal();
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// ---- HTTPS section of the create dialog -------------------------------------
|
|
671
|
+
// Two modes, and only one of them asks for anything: a domain and an email, the
|
|
672
|
+
// same pair the official Rocket.Chat compose takes as DOMAIN and LETSENCRYPT_EMAIL.
|
|
673
|
+
const HTTPS_MODE_HINT = {
|
|
674
|
+
"": "Only a browser on this server opens it, unless this server publishes workspaces beyond "
|
|
675
|
+
+ "loopback (Bind host).",
|
|
676
|
+
// What the name needs is said once, under the Domain field it is about.
|
|
677
|
+
acme: "Traefik obtains a real, publicly trusted certificate from Let's Encrypt.",
|
|
678
|
+
local: "A certificate signed by houston's own CA, for <name>.houston.localhost, which only"
|
|
679
|
+
+ " a browser on this server reaches. Works offline, no domain, no rate limits."
|
|
680
|
+
+ " Browsers warn until `houston trust-ca` has been run once. From your own computer,"
|
|
681
|
+
+ " or for a phone, use Let's Encrypt.",
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
function syncHttpsFields() {
|
|
685
|
+
const mode = ctx.$("#https-mode").value;
|
|
686
|
+
ctx.$("#https-mode-hint").textContent = HTTPS_MODE_HINT[mode] || "";
|
|
687
|
+
for (const el of document.querySelectorAll(".https-acme")) el.hidden = mode !== "acme";
|
|
688
|
+
const email = ctx.$("#create-form") && ctx.$("#create-form").acme_email;
|
|
689
|
+
if (email) {
|
|
690
|
+
email.required = mode === "acme" && !ctx.ACME_EMAIL_REMEMBERED;
|
|
691
|
+
email.placeholder = ctx.ACME_EMAIL_REMEMBERED
|
|
692
|
+
? "remembered — leave blank to reuse it"
|
|
693
|
+
: "you@example.com";
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
function applyHttpsToRequest(f, req) {
|
|
698
|
+
const mode = f.https_mode ? f.https_mode.value : "";
|
|
699
|
+
if (!mode) return true;
|
|
700
|
+
const val = (k) => (f[k] && f[k].value.trim()) || "";
|
|
701
|
+
if (mode === "local") { req.https = true; return true; }
|
|
702
|
+
// Not on a cluster with a zone: the server names the workspace <name>.<zone> itself.
|
|
703
|
+
if (!val("domain") && !chosenZone()) { ctx.toast("HTTPS: a domain is required for Let's Encrypt"); return false; }
|
|
704
|
+
if (!val("acme_email") && !ctx.ACME_EMAIL_REMEMBERED) {
|
|
705
|
+
ctx.toast("HTTPS: a contact email is required for Let's Encrypt");
|
|
706
|
+
return false;
|
|
707
|
+
}
|
|
708
|
+
req.domain = val("domain");
|
|
709
|
+
// The email may be blank when it is remembered in config. Everything else --
|
|
710
|
+
// the challenge, the port, whether to publish publicly -- is derived server-side,
|
|
711
|
+
// so the form does not ask for it.
|
|
712
|
+
if (val("acme_email")) req.acme_email = val("acme_email");
|
|
713
|
+
return true;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
async function submitCreate() {
|
|
717
|
+
const f = ctx.$("#create-form");
|
|
718
|
+
const req = {
|
|
719
|
+
version: f.version.value.trim(),
|
|
720
|
+
port: f.port.value ? parseInt(f.port.value, 10) : 0,
|
|
721
|
+
monitor: f.monitor.checked, seed: f.seed.checked, wait: f.wait.checked,
|
|
722
|
+
// Always sent, both of them: omitting `runtime` would let the service's default
|
|
723
|
+
// decide, which would silently stop matching what this dialog showed.
|
|
724
|
+
runtime: f.runtime ? f.runtime.value : "docker",
|
|
725
|
+
deployment: f.deployment ? f.deployment.value : "",
|
|
726
|
+
// The presets, each one's settings and the license (options.js).
|
|
727
|
+
...ctx.optionsRequest(),
|
|
728
|
+
};
|
|
729
|
+
if (f.replicas && !ctx.$("#replicas-row").hidden && f.replicas.value) {
|
|
730
|
+
req.replicas = parseInt(f.replicas.value, 10);
|
|
731
|
+
}
|
|
732
|
+
if (f.mongo_operator && f.mongo_operator.checked) req.mongo_operator = true;
|
|
733
|
+
if (f.seed.checked && f.seed_profile) req.seed_profile = f.seed_profile.value;
|
|
734
|
+
if (f.seed.checked) {
|
|
735
|
+
const selection = ctx.seedRequest(f, "seed_"); if (selection === null) return;
|
|
736
|
+
req.seed_scenarios = selection.scenarios;
|
|
737
|
+
if (selection.history_days !== undefined) req.seed_history_days = selection.history_days;
|
|
738
|
+
}
|
|
739
|
+
if (!req.version) { ctx.toast("version is required"); f.version.focus(); return; }
|
|
740
|
+
for (const k of ["name", "reg_token", "mongo", "rc_image", "bind", "root_url", "context"]) {
|
|
741
|
+
if (f[k] && f[k].value.trim()) req[k] = f[k].value.trim();
|
|
742
|
+
}
|
|
743
|
+
// --offline and --no-pull stay on the command line; the dialog does not offer them.
|
|
744
|
+
if (f.pin && f.pin.checked) req.pin = true;
|
|
745
|
+
if (!applyHttpsToRequest(f, req)) return; // validates before anything is sent
|
|
746
|
+
const existing = f.existing ? f.existing.value : "reuse";
|
|
747
|
+
if (existing === "force") req.force = true;
|
|
748
|
+
if (existing === "fresh") {
|
|
749
|
+
if (!confirm(`This DELETES ${req.name || "the existing workspace"}'s data volume — all users, `
|
|
750
|
+
+ `channels, messages and uploads — then rebuilds it.\n\nContinue?`)) return;
|
|
751
|
+
req.fresh = true;
|
|
752
|
+
}
|
|
753
|
+
// Until the server says which name it settled on (`named`): it derives one from the
|
|
754
|
+
// version and presets, and puts the account in front.
|
|
755
|
+
let label = req.name || req.version;
|
|
756
|
+
const where = whereText(destFor(DEST));
|
|
757
|
+
setCreateStep(3);
|
|
758
|
+
const title = ctx.$("#create-progress-title");
|
|
759
|
+
title.textContent = `Creating ${label} on ${where}`;
|
|
760
|
+
ctx.$("#create-progress").innerHTML = "";
|
|
761
|
+
ctx.$("#create-result").innerHTML = "";
|
|
762
|
+
try {
|
|
763
|
+
const { job_id } = await ctx.api("/api/repros", { method: "POST", body: JSON.stringify(req) });
|
|
764
|
+
// The job's title is what its toasts say once the dialog is closed: the workspace, as
|
|
765
|
+
// Activity names it, not the version asked for.
|
|
766
|
+
ctx.streamJob(job_id, `Creating ${label}`, (r) => renderCreateDone(r, label),
|
|
767
|
+
{ list: ctx.$("#create-progress"), title, dialog: ctx.$("#create-dialog"), stop: ctx.$("#create-stop"),
|
|
768
|
+
named: (name) => {
|
|
769
|
+
label = name;
|
|
770
|
+
title.textContent = `Creating ${label} on ${where}`;
|
|
771
|
+
ctx.JOB.title = `Creating ${label}`;
|
|
772
|
+
// Now its job answers to the name: shown as Creating, as after a reload, not `down`.
|
|
773
|
+
ctx.adoptRunningJobs();
|
|
774
|
+
},
|
|
775
|
+
failed: (data) => {
|
|
776
|
+
title.textContent = data && data.kind === "Stopped" ? `${label} was stopped` : `${label} could not be created`;
|
|
777
|
+
// It no longer "keeps starting": the job has ended.
|
|
778
|
+
ctx.$("#create-foot-hint").textContent = "";
|
|
779
|
+
} });
|
|
780
|
+
} catch (e) {
|
|
781
|
+
ctx.toast(e.message);
|
|
782
|
+
setCreateStep(2, true);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// What a finished create leaves in the dialog: where to go and how to sign in, then
|
|
787
|
+
// the preset's notes -- the same facts the CLI prints after `up`.
|
|
788
|
+
function renderCreateDone(r, label) {
|
|
789
|
+
const name = (r && r.name) || label;
|
|
790
|
+
ctx.$("#create-progress-title").textContent = `${name} is ready`;
|
|
791
|
+
const box = ctx.$("#create-result");
|
|
792
|
+
box.innerHTML = "";
|
|
793
|
+
const url = (r && (r.open_url || r.root_url)) || "";
|
|
794
|
+
if (url) {
|
|
795
|
+
const call = ctx.el("div", { class: "callout info" }, "Open ", ctx.el("b", { class: "mono" }, url));
|
|
796
|
+
if (r.login) call.append(" and sign in as ", ctx.el("b", {}, `${r.login.user} / ${r.login.password}`));
|
|
797
|
+
call.append(".");
|
|
798
|
+
box.append(call);
|
|
799
|
+
}
|
|
800
|
+
const kv = ctx.el("div", { class: "result-kv" });
|
|
801
|
+
if (r && r.rc_version) kv.append(ctx.el("b", {}, "Rocket.Chat"), ctx.el("span", {}, `${r.rc_version} · MongoDB ${r.mongo_tag || "?"} · ${r.preset || "default"}`));
|
|
802
|
+
for (const u of (r && r.instance_urls) || []) kv.append(ctx.el("b", {}, "Instance"), ctx.el("span", {}, u));
|
|
803
|
+
if (r && r.grafana_url) kv.append(ctx.el("b", {}, "Grafana"), ctx.el("span", {}, r.grafana_url));
|
|
804
|
+
if (kv.childElementCount) box.append(kv);
|
|
805
|
+
if (r && r.notes && r.notes.length) ctx.appendNotes(box, r.notes);
|
|
806
|
+
ctx.$("#create-foot-hint").textContent = "";
|
|
807
|
+
const ws = ctx.$("#create-open-ws");
|
|
808
|
+
ws.hidden = false;
|
|
809
|
+
ws.onclick = () => { ctx.$("#create-dialog").close(); ctx.selectRepro(name); };
|
|
810
|
+
const rc = ctx.$("#create-open-rc");
|
|
811
|
+
if (url) { rc.href = url; rc.hidden = false; }
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// ---- opening and moving through the dialog -----------------------------------------
|
|
815
|
+
function startCreate({ dest = "", step = 1 } = {}) {
|
|
816
|
+
// Every open starts from the first usable place (Docker) unless a place was named. A
|
|
817
|
+
// named place this person may not choose is said -- never quietly swapped for Docker.
|
|
818
|
+
const named = dest ? destFor(dest) : null;
|
|
819
|
+
DEST = named && named.usable ? dest : "";
|
|
820
|
+
renderDestinations();
|
|
821
|
+
if (dest && !(named && named.usable)) {
|
|
822
|
+
ctx.toast(named ? `${named.nm} cannot take a workspace right now.` : "Choosing a cluster is kept to admins on this server; pick where it runs.", "info");
|
|
823
|
+
}
|
|
824
|
+
setCreateStep(step === 2 && named && named.usable ? 2 : 1);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function createNext() {
|
|
828
|
+
const p = destFor(DEST);
|
|
829
|
+
if (!p || !p.usable) { ctx.toast("Pick where it runs first."); return; }
|
|
830
|
+
setCreateStep(2);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
ctx.$("#create-next").addEventListener("click", createNext);
|
|
834
|
+
ctx.$("#create-back").addEventListener("click", () => setCreateStep(1, true));
|
|
835
|
+
ctx.$("#create-change").addEventListener("click", () => setCreateStep(1, true));
|
|
836
|
+
ctx.$("#create-x").addEventListener("click", () => ctx.$("#create-dialog").close());
|
|
837
|
+
ctx.$("#create-form").addEventListener("keydown", (ev) => {
|
|
838
|
+
// Enter moves forward the way the button on screen would; it never submits step 1.
|
|
839
|
+
if (ev.key !== "Enter" || ev.target.tagName === "TEXTAREA" || ev.target.tagName === "BUTTON") return;
|
|
840
|
+
if (CREATE_STEP === 1) { ev.preventDefault(); createNext(); }
|
|
841
|
+
});
|
|
842
|
+
ctx.$("#create-form").version.addEventListener("input", () => {
|
|
843
|
+
if (CREATE_STEP === 2) ctx.$("#create-foot-hint").textContent = createSummaryLine();
|
|
844
|
+
});
|
|
845
|
+
// A create still running when the dialog is closed carries on, and says how it ended.
|
|
846
|
+
ctx.$("#create-dialog").addEventListener("close", () => {
|
|
847
|
+
const job = ctx.JOB;
|
|
848
|
+
if (job && job.view && job.view.dialog === ctx.$("#create-dialog")) {
|
|
849
|
+
ctx.closeJobStream();
|
|
850
|
+
if (!job.finished) ctx.watchDetachedJob(job);
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
Object.defineProperties(ctx, {
|
|
855
|
+
"RUNTIMES": { enumerable: true, get: () => RUNTIMES, set: value => { RUNTIMES = value; } },
|
|
856
|
+
"RUNTIME_LABEL": { enumerable: true, get: () => RUNTIME_LABEL },
|
|
857
|
+
"runtimeLabel": { enumerable: true, get: () => runtimeLabel },
|
|
858
|
+
"DEPLOYMENT_LABEL": { enumerable: true, get: () => DEPLOYMENT_LABEL },
|
|
859
|
+
"DEPLOYMENT_NOTE": { enumerable: true, get: () => DEPLOYMENT_NOTE },
|
|
860
|
+
"fmtGb": { enumerable: true, get: () => fmtGb },
|
|
861
|
+
"renderRuntimeAxes": { enumerable: true, get: () => renderRuntimeAxes },
|
|
862
|
+
"pickRuntime": { enumerable: true, get: () => pickRuntime },
|
|
863
|
+
"pickDeployment": { enumerable: true, get: () => pickDeployment },
|
|
864
|
+
"ADV_GONE_LABEL": { enumerable: true, get: () => ADV_GONE_LABEL },
|
|
865
|
+
"KUBE_CLUSTERS": { enumerable: true, get: () => KUBE_CLUSTERS, set: value => { KUBE_CLUSTERS = value; } },
|
|
866
|
+
"ALL_KUBE_CLUSTERS": { enumerable: true, get: () => ALL_KUBE_CLUSTERS, set: value => { ALL_KUBE_CLUSTERS = value; } },
|
|
867
|
+
"MACHINE_ROOM": { enumerable: true, get: () => MACHINE_ROOM, set: value => { MACHINE_ROOM = value; } },
|
|
868
|
+
"clusterLabel": { enumerable: true, get: () => clusterLabel },
|
|
869
|
+
"PLACE_ICON": { enumerable: true, get: () => PLACE_ICON },
|
|
870
|
+
"placeIcon": { enumerable: true, get: () => icon },
|
|
871
|
+
"places": { enumerable: true, get: () => places },
|
|
872
|
+
"placeBody": { enumerable: true, get: () => placeBody },
|
|
873
|
+
"placeState": { enumerable: true, get: () => placeState },
|
|
874
|
+
"placeWarn": { enumerable: true, get: () => placeWarn },
|
|
875
|
+
"perDay": { enumerable: true, get: () => perDay },
|
|
876
|
+
"plural": { enumerable: true, get: () => plural },
|
|
877
|
+
"emptyContextRow": { enumerable: true, get: () => emptyContextRow },
|
|
878
|
+
"zoneHead": { enumerable: true, get: () => zoneHead },
|
|
879
|
+
"renderDestinations": { enumerable: true, get: () => renderDestinations },
|
|
880
|
+
"pickDest": { enumerable: true, get: () => pickDest },
|
|
881
|
+
"startCreate": { enumerable: true, get: () => startCreate },
|
|
882
|
+
"setCreateStep": { enumerable: true, get: () => setCreateStep },
|
|
883
|
+
"runsOnThisMachine": { enumerable: true, get: () => runsOnThisMachine },
|
|
884
|
+
"syncLocalCaOption": { enumerable: true, get: () => syncLocalCaOption },
|
|
885
|
+
"syncClusterNote": { enumerable: true, get: () => syncClusterNote },
|
|
886
|
+
"syncAdvancedForRuntime": { enumerable: true, get: () => syncAdvancedForRuntime },
|
|
887
|
+
"syncDeploymentFields": { enumerable: true, get: () => syncDeploymentFields },
|
|
888
|
+
"TLS_LABEL": { enumerable: true, get: () => TLS_LABEL },
|
|
889
|
+
"doTlsStatus": { enumerable: true, get: () => doTlsStatus },
|
|
890
|
+
"HTTPS_MODE_HINT": { enumerable: true, get: () => HTTPS_MODE_HINT },
|
|
891
|
+
"syncHttpsFields": { enumerable: true, get: () => syncHttpsFields },
|
|
892
|
+
"applyHttpsToRequest": { enumerable: true, get: () => applyHttpsToRequest },
|
|
893
|
+
"submitCreate": { enumerable: true, get: () => submitCreate },
|
|
894
|
+
"createSummaryLine": { enumerable: true, get: () => createSummaryLine },
|
|
895
|
+
});
|
|
896
|
+
export { RUNTIMES, RUNTIME_LABEL, runtimeLabel, DEPLOYMENT_LABEL, DEPLOYMENT_NOTE, fmtGb, renderRuntimeAxes, pickRuntime, pickDeployment, ADV_GONE_LABEL, KUBE_CLUSTERS, ALL_KUBE_CLUSTERS, MACHINE_ROOM, clusterLabel, places, placeBody, renderDestinations, pickDest, startCreate, setCreateStep, runsOnThisMachine, syncLocalCaOption, syncClusterNote, syncAdvancedForRuntime, syncDeploymentFields, TLS_LABEL, doTlsStatus, HTTPS_MODE_HINT, syncHttpsFields, applyHttpsToRequest, submitCreate };
|