@rocket.chat/houston 0.27.0-next.3 → 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 -194
- package/dist/outputCI.js +0 -59
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -28
- package/src/outputCI.ts +0 -12
- 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,482 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.LABELS = exports.REGISTERED = exports.ALIASES = exports.LEGACY_REPLICA_PARAM = exports.LEGACY_MULTI_PRESET = exports.DEPLOYMENT_ALIASES = exports.DEPLOYMENTS = exports.MICROSERVICES = exports.MULTI_INSTANCE = exports.MONOLITH = exports.KUBERNETES = exports.DOCKER = void 0;
|
|
37
|
+
exports.normalize = normalize;
|
|
38
|
+
exports.isRegistered = isRegistered;
|
|
39
|
+
exports.label = label;
|
|
40
|
+
exports.ofMeta = ofMeta;
|
|
41
|
+
exports.ofRepro = ofRepro;
|
|
42
|
+
exports.stamp = stamp;
|
|
43
|
+
exports.requireCompose = requireCompose;
|
|
44
|
+
exports.normalizeDeployment = normalizeDeployment;
|
|
45
|
+
exports.resolveAxes = resolveAxes;
|
|
46
|
+
exports.requireRegistered = requireRegistered;
|
|
47
|
+
exports.axesOfMeta = axesOfMeta;
|
|
48
|
+
/**
|
|
49
|
+
* Which runtime a workspace runs on.
|
|
50
|
+
*
|
|
51
|
+
* Until this module, the answer was structural rather than recorded: a repro WAS a
|
|
52
|
+
* `docker-compose.yml` on disk. That is true of every workspace this tool has ever made, and
|
|
53
|
+
* it is the assumption a second runtime has to displace -- so this makes the answer a value
|
|
54
|
+
* that can be read, rather than a shape that can only be inferred.
|
|
55
|
+
*
|
|
56
|
+
* **A missing value means docker.** Every workspace created before this key existed is a
|
|
57
|
+
* compose one, and there is no migration: `repro.json` files are not rewritten, not on
|
|
58
|
+
* read and not on the next `up`. The absent key is not ambiguous, it is older than the
|
|
59
|
+
* question. This is one of the two "absence is a version marker" fields, and the failure
|
|
60
|
+
* to guard against is exactly this one round-tripping "successfully" while turning an
|
|
61
|
+
* absent `extra.runtime` into an explicit `"docker"`.
|
|
62
|
+
*
|
|
63
|
+
* **Unknown values also mean docker, and that is deliberate.** `ofMeta` never throws. A
|
|
64
|
+
* workspace written by a NEWER houston naming a runtime this build has never heard of must
|
|
65
|
+
* still list, still show its ports and still tear down; the alternative is a repro that
|
|
66
|
+
* cannot be removed by the version installed. Refusing belongs at the point of USE --
|
|
67
|
+
* `requireCompose` -- where the operation is known and the message can say what to do
|
|
68
|
+
* instead. Reading is not use.
|
|
69
|
+
*
|
|
70
|
+
* `normalize` is the opposite and does throw, because it is only ever called on input a
|
|
71
|
+
* human just typed, where a silent fallback would boot the wrong thing.
|
|
72
|
+
*/
|
|
73
|
+
const config = __importStar(require("../lib/config"));
|
|
74
|
+
const errors_1 = require("../lib/errors");
|
|
75
|
+
const composite_1 = require("../lib/presets/composite");
|
|
76
|
+
const record_1 = require("./runner/record");
|
|
77
|
+
/** Canonical runtime names. These reach `repro.json` and are stable API. */
|
|
78
|
+
exports.DOCKER = 'docker';
|
|
79
|
+
exports.KUBERNETES = 'kubernetes';
|
|
80
|
+
/**
|
|
81
|
+
* Canonical deployment names -- HOW Rocket.Chat is arranged, as opposed to WHERE it runs.
|
|
82
|
+
* Which are legal depends on the runtime; see `DEPLOYMENTS`.
|
|
83
|
+
*/
|
|
84
|
+
exports.MONOLITH = 'monolith';
|
|
85
|
+
exports.MULTI_INSTANCE = 'multi-instance';
|
|
86
|
+
exports.MICROSERVICES = 'microservices';
|
|
87
|
+
/**
|
|
88
|
+
* The deployments each runtime can serve, first entry being its default.
|
|
89
|
+
*
|
|
90
|
+
* Kubernetes defaults to microservices because the chart's own default is
|
|
91
|
+
* `microservices.enabled: true` and it is the shape customers actually run;
|
|
92
|
+
* monolith-on-Kubernetes is the control experiment, not the common case.
|
|
93
|
+
*/
|
|
94
|
+
exports.DEPLOYMENTS = Object.freeze({
|
|
95
|
+
[exports.DOCKER]: Object.freeze([exports.MONOLITH, exports.MULTI_INSTANCE]),
|
|
96
|
+
[exports.KUBERNETES]: Object.freeze([exports.MICROSERVICES, exports.MONOLITH]),
|
|
97
|
+
});
|
|
98
|
+
/** Deployment spellings, same reasoning as the runtime aliases. */
|
|
99
|
+
exports.DEPLOYMENT_ALIASES = Object.freeze({
|
|
100
|
+
monolith: exports.MONOLITH,
|
|
101
|
+
monolithic: exports.MONOLITH,
|
|
102
|
+
single: exports.MONOLITH,
|
|
103
|
+
default: exports.MONOLITH,
|
|
104
|
+
'multi-instance': exports.MULTI_INSTANCE,
|
|
105
|
+
multi_instance: exports.MULTI_INSTANCE,
|
|
106
|
+
multiinstance: exports.MULTI_INSTANCE,
|
|
107
|
+
microservices: exports.MICROSERVICES,
|
|
108
|
+
microservice: exports.MICROSERVICES,
|
|
109
|
+
micro: exports.MICROSERVICES,
|
|
110
|
+
});
|
|
111
|
+
/**
|
|
112
|
+
* The preset that IS a deployment rather than a scenario, and the `--set` key it used to
|
|
113
|
+
* take. Both spellings keep working; see `resolveAxes`.
|
|
114
|
+
*/
|
|
115
|
+
exports.LEGACY_MULTI_PRESET = 'multi-instance';
|
|
116
|
+
exports.LEGACY_REPLICA_PARAM = 'instances';
|
|
117
|
+
/**
|
|
118
|
+
* What a human may type. Values are canonical names; keys are lowercased before lookup.
|
|
119
|
+
* `compose` and `k8s` are here because they are what people actually write, and a tool
|
|
120
|
+
* that rejects `--runtime k8s` is being pedantic at the user's expense.
|
|
121
|
+
*/
|
|
122
|
+
exports.ALIASES = Object.freeze({
|
|
123
|
+
docker: exports.DOCKER,
|
|
124
|
+
compose: exports.DOCKER,
|
|
125
|
+
'docker-compose': exports.DOCKER,
|
|
126
|
+
dockercompose: exports.DOCKER,
|
|
127
|
+
kubernetes: exports.KUBERNETES,
|
|
128
|
+
k8s: exports.KUBERNETES,
|
|
129
|
+
kube: exports.KUBERNETES,
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* Runtimes this build can actually create. Kubernetes joined once the whole sequence --
|
|
133
|
+
* cluster, namespace, MongoDB with an initiated replica set, the chart, a port-forward --
|
|
134
|
+
* was proven on a live cluster rather than in stubs.
|
|
135
|
+
*/
|
|
136
|
+
exports.REGISTERED = new Set([exports.DOCKER, exports.KUBERNETES]);
|
|
137
|
+
/** Human labels, for a message or a GUI row. */
|
|
138
|
+
exports.LABELS = Object.freeze({
|
|
139
|
+
[exports.DOCKER]: 'Docker Compose',
|
|
140
|
+
[exports.KUBERNETES]: 'Kubernetes',
|
|
141
|
+
});
|
|
142
|
+
/**
|
|
143
|
+
* A table's OWN entry for `key`. Indexing a plain object also finds its prototype's names:
|
|
144
|
+
* `--runtime constructor` found Object's constructor, a function, where the established
|
|
145
|
+
* answer refuses an unknown runtime.
|
|
146
|
+
*/
|
|
147
|
+
function own(table, key) {
|
|
148
|
+
return Object.hasOwn(table, key) ? table[key] : undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Canonical runtime name for something a human typed.
|
|
152
|
+
*
|
|
153
|
+
* Empty means the default, which is docker -- omitting `--runtime` is not an error, it is
|
|
154
|
+
* the common case. An unrecognised spelling throws, because it is a typo the caller can
|
|
155
|
+
* fix and guessing would boot the wrong topology.
|
|
156
|
+
*/
|
|
157
|
+
function normalize(value) {
|
|
158
|
+
const text = String(value ?? '')
|
|
159
|
+
.trim()
|
|
160
|
+
.toLowerCase();
|
|
161
|
+
if (!text)
|
|
162
|
+
return exports.DOCKER;
|
|
163
|
+
const found = own(exports.ALIASES, text);
|
|
164
|
+
if (found === undefined) {
|
|
165
|
+
const known = [...new Set(Object.values(exports.ALIASES))].sort().join(', ');
|
|
166
|
+
throw new errors_1.ValidationError(`unknown runtime '${text}'. Known runtimes: ${known}.`);
|
|
167
|
+
}
|
|
168
|
+
return found;
|
|
169
|
+
}
|
|
170
|
+
/** Whether this build can create workspaces on that runtime. */
|
|
171
|
+
function isRegistered(name) {
|
|
172
|
+
return exports.REGISTERED.has(name);
|
|
173
|
+
}
|
|
174
|
+
/** A human-readable name, falling back to the raw value for an unknown one. */
|
|
175
|
+
function label(name) {
|
|
176
|
+
return exports.LABELS[name] ?? (name || exports.DOCKER);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The runtime a workspace's metadata records. NEVER throws -- see the module docstring for
|
|
180
|
+
* why an unreadable or unknown value reads as docker.
|
|
181
|
+
*/
|
|
182
|
+
function ofMeta(meta) {
|
|
183
|
+
const extra = meta?.extra;
|
|
184
|
+
if (typeof extra !== 'object' || extra === null || Array.isArray(extra))
|
|
185
|
+
return exports.DOCKER;
|
|
186
|
+
const raw = String(extra[config.EXTRA_RUNTIME] ?? '')
|
|
187
|
+
.trim()
|
|
188
|
+
.toLowerCase();
|
|
189
|
+
return own(exports.ALIASES, raw) ?? exports.DOCKER;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The runtime of a named workspace.
|
|
193
|
+
*
|
|
194
|
+
* Tolerant of a workspace that is missing or mid-write: this must never be the thing that
|
|
195
|
+
* breaks an operation. If the metadata cannot be read, the answer that preserves today's
|
|
196
|
+
* behaviour is docker, and the caller's own existence check reports the real problem a
|
|
197
|
+
* moment later with a better message.
|
|
198
|
+
*/
|
|
199
|
+
async function ofRepro(name) {
|
|
200
|
+
try {
|
|
201
|
+
return ofMeta(await (0, record_1.readMeta)(name));
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return exports.DOCKER;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Record the runtime in an `extra` bag, returning it for chaining.
|
|
209
|
+
*
|
|
210
|
+
* Written on every create, INCLUDING compose ones. Stamping only the new runtime would
|
|
211
|
+
* leave "absent" meaning two different things -- an old workspace and a new compose one --
|
|
212
|
+
* and the first question asked of any workspace field is eventually "is this missing
|
|
213
|
+
* because it is old, or because it is false?".
|
|
214
|
+
*/
|
|
215
|
+
function stamp(extra, runtime = exports.DOCKER) {
|
|
216
|
+
const bag = typeof extra === 'object' && extra !== null && !Array.isArray(extra)
|
|
217
|
+
? extra
|
|
218
|
+
: {};
|
|
219
|
+
bag[config.EXTRA_RUNTIME] = runtime;
|
|
220
|
+
return bag;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Refuse an operation that only Docker Compose can serve.
|
|
224
|
+
*
|
|
225
|
+
* The guard lives at the operation, not at the front door, because most of the tool is
|
|
226
|
+
* runtime-agnostic -- `seed`, `api`, `token` and `config-import` all speak REST to a URL
|
|
227
|
+
* and do not care what is behind it. Only the handful of commands that reach for a compose
|
|
228
|
+
* project need this.
|
|
229
|
+
*
|
|
230
|
+
* `instead` is the Kubernetes equivalent, when there is one. Saying only "not supported"
|
|
231
|
+
* leaves the user to search for the alternative that the person writing the refusal
|
|
232
|
+
* already knew.
|
|
233
|
+
*/
|
|
234
|
+
async function requireCompose(name, operation, { instead = '' } = {}) {
|
|
235
|
+
const runtime = await ofRepro(name);
|
|
236
|
+
if (runtime === exports.DOCKER)
|
|
237
|
+
return;
|
|
238
|
+
const tail = instead ? ` ${instead}` : '';
|
|
239
|
+
throw new errors_1.ValidationError(`${operation} reads the Docker Compose project, and '${name}' runs on ` +
|
|
240
|
+
`${label(runtime)}.${tail}`);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Canonical deployment name, checked against what the runtime can serve.
|
|
244
|
+
*
|
|
245
|
+
* Empty means that runtime's default. An unknown spelling throws; so does a legal-elsewhere
|
|
246
|
+
* one, and that refusal names the runtime it IS legal on -- "unknown deployment
|
|
247
|
+
* 'microservices'" would be a lie, since it is a real deployment that this runtime simply
|
|
248
|
+
* cannot host.
|
|
249
|
+
*/
|
|
250
|
+
function normalizeDeployment(value, runtime) {
|
|
251
|
+
const text = String(value ?? '')
|
|
252
|
+
.trim()
|
|
253
|
+
.toLowerCase();
|
|
254
|
+
const legal = exports.DEPLOYMENTS[runtime];
|
|
255
|
+
if (!text)
|
|
256
|
+
return legal[0];
|
|
257
|
+
const found = own(exports.DEPLOYMENT_ALIASES, text);
|
|
258
|
+
if (found === undefined) {
|
|
259
|
+
const known = [...new Set(Object.values(exports.DEPLOYMENT_ALIASES))].sort().join(', ');
|
|
260
|
+
throw new errors_1.ValidationError(`unknown deployment '${text}'. Known deployments: ${known}.`);
|
|
261
|
+
}
|
|
262
|
+
if (!legal.includes(found)) {
|
|
263
|
+
const other = Object.entries(exports.DEPLOYMENTS).find(([, d]) => d.includes(found))?.[0] ?? '';
|
|
264
|
+
const where = other ? ` It is available on --runtime ${other}.` : '';
|
|
265
|
+
throw new errors_1.ValidationError(`${label(runtime)} cannot run a '${found}' deployment.${where}`);
|
|
266
|
+
}
|
|
267
|
+
return found;
|
|
268
|
+
}
|
|
269
|
+
/** The pre-axes spellings -- the multi-instance preset and its replica param. */
|
|
270
|
+
function absorbLegacySpellings(out, rawDeployment, rawPreset, replicas) {
|
|
271
|
+
// `--preset multi-instance` is the deployment axis wearing last year's name.
|
|
272
|
+
if (rawPreset === exports.LEGACY_MULTI_PRESET) {
|
|
273
|
+
if (rawDeployment && own(exports.DEPLOYMENT_ALIASES, rawDeployment) !== exports.MULTI_INSTANCE) {
|
|
274
|
+
throw new errors_1.ValidationError(`--preset ${exports.LEGACY_MULTI_PRESET} and --deployment ${rawDeployment} ask for two ` +
|
|
275
|
+
'different deployments. Drop the --preset; it is now spelled --deployment ' +
|
|
276
|
+
'multi-instance.');
|
|
277
|
+
}
|
|
278
|
+
rawDeployment = exports.MULTI_INSTANCE;
|
|
279
|
+
rawPreset = 'default';
|
|
280
|
+
out.hints.push('--preset multi-instance is now --deployment multi-instance ' +
|
|
281
|
+
'(the old spelling still works)');
|
|
282
|
+
}
|
|
283
|
+
// `--set instances=N` is `--replicas N` wearing the same.
|
|
284
|
+
const legacyN = out.params[exports.LEGACY_REPLICA_PARAM];
|
|
285
|
+
if (legacyN !== undefined && legacyN !== null && legacyN !== '' && !replicas) {
|
|
286
|
+
out.hints.push(`--set ${exports.LEGACY_REPLICA_PARAM}=${String(legacyN)} is now --replicas ${String(legacyN)} ` +
|
|
287
|
+
'(the old spelling still works)');
|
|
288
|
+
}
|
|
289
|
+
return [legacyN, rawDeployment, rawPreset];
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* A value read as an integer the established way, which is not `Number()` and not
|
|
293
|
+
* `parseInt`.
|
|
294
|
+
*
|
|
295
|
+
* Measured rather than assumed, because the three disagree exactly where a replica count
|
|
296
|
+
* comes from a JSON payload rather than from a command line:
|
|
297
|
+
*
|
|
298
|
+
* 3.7 -> 3 truncates toward zero
|
|
299
|
+
* "3.7" -> null a STRING must be a whole number
|
|
300
|
+
* " 4 " -> 4 surrounding space is fine
|
|
301
|
+
* "" -> null
|
|
302
|
+
* true -> 1
|
|
303
|
+
*
|
|
304
|
+
* `Number("3.7")` is 3.7 and `parseInt("3.7")` is 3, so either one alone gets a case
|
|
305
|
+
* wrong. Returns null where the value is not an integer, and the caller decides what that
|
|
306
|
+
* means.
|
|
307
|
+
*/
|
|
308
|
+
function toInt(value) {
|
|
309
|
+
if (typeof value === 'boolean')
|
|
310
|
+
return value ? 1 : 0;
|
|
311
|
+
if (typeof value === 'number') {
|
|
312
|
+
if (!Number.isFinite(value))
|
|
313
|
+
return null;
|
|
314
|
+
return Math.trunc(value);
|
|
315
|
+
}
|
|
316
|
+
const text = String(value ?? '').trim();
|
|
317
|
+
if (!/^[+-]?\d+$/u.test(text))
|
|
318
|
+
return null;
|
|
319
|
+
return Number.parseInt(text, 10);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The value as that one message quotes it: text in single quotes, anything else bare.
|
|
323
|
+
*
|
|
324
|
+
* `--set instances='2.5'` is what the user typed, and the quotes are what tell them the
|
|
325
|
+
* value arrived as text. A bare `2.5` in the message would read as a number houston chose.
|
|
326
|
+
*/
|
|
327
|
+
function quotedText(value) {
|
|
328
|
+
return typeof value === 'string' ? `'${value}'` : String(value);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* How many app instances, and whether asking for more than one makes sense.
|
|
332
|
+
*
|
|
333
|
+
* A lone Compose monolith cannot be replicated -- there is no load balancer in front of it
|
|
334
|
+
* and no NATS mesh between them, so `--replicas 3` there would silently produce one.
|
|
335
|
+
* Refusing names the flag that would make it work.
|
|
336
|
+
*/
|
|
337
|
+
function resolveReplicas(replicas, legacyN, axes) {
|
|
338
|
+
let want = Number(replicas || 0);
|
|
339
|
+
if (!want && legacyN !== undefined && legacyN !== null && legacyN !== '') {
|
|
340
|
+
const parsed = toInt(legacyN);
|
|
341
|
+
if (parsed === null) {
|
|
342
|
+
throw new errors_1.ValidationError(`--set ${exports.LEGACY_REPLICA_PARAM}=${quotedText(legacyN)} expects a whole number`);
|
|
343
|
+
}
|
|
344
|
+
want = parsed;
|
|
345
|
+
}
|
|
346
|
+
if (want && want < 1)
|
|
347
|
+
throw new errors_1.ValidationError('--replicas must be at least 1.');
|
|
348
|
+
if (axes.deployment === exports.MONOLITH && want > 1) {
|
|
349
|
+
const alt = axes.runtime === exports.DOCKER ? '--deployment multi-instance' : '--deployment microservices';
|
|
350
|
+
throw new errors_1.ValidationError(`a ${label(axes.runtime)} monolith runs one Rocket.Chat, so --replicas ${want} ` +
|
|
351
|
+
`would silently give you one. Add ${alt}.`);
|
|
352
|
+
}
|
|
353
|
+
// The multi-instance preset's own default.
|
|
354
|
+
if (axes.deployment === exports.MULTI_INSTANCE)
|
|
355
|
+
return want || 2;
|
|
356
|
+
return want || 1;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Decide runtime x deployment x scenario, in one place.
|
|
360
|
+
*
|
|
361
|
+
* Every refusal in the matrix lives here rather than at a call site, because the
|
|
362
|
+
* combinations are what a user gets wrong and a rule enforced in two places eventually
|
|
363
|
+
* disagrees with itself.
|
|
364
|
+
*
|
|
365
|
+
* The old spellings are PERMANENT ALIASES, not a deprecation with a deadline: they cost
|
|
366
|
+
* one lookup each, and breaking a command line that is pasted into support tickets buys
|
|
367
|
+
* nothing.
|
|
368
|
+
*/
|
|
369
|
+
function resolveAxes(options = {}) {
|
|
370
|
+
const { runtime = '', deployment = '', replicas = 0, preset = '', params = null } = options;
|
|
371
|
+
const out = {
|
|
372
|
+
runtime: exports.DOCKER,
|
|
373
|
+
deployment: exports.MONOLITH,
|
|
374
|
+
replicas: 1,
|
|
375
|
+
preset: 'default',
|
|
376
|
+
params: { ...(params ?? {}) },
|
|
377
|
+
hints: [],
|
|
378
|
+
};
|
|
379
|
+
let rawPreset = String(preset || '').trim() || 'default';
|
|
380
|
+
let rawDeployment = String(deployment || '')
|
|
381
|
+
.trim()
|
|
382
|
+
.toLowerCase();
|
|
383
|
+
// `multi-instance` named among several presets is the deployment axis too, absorbed by the
|
|
384
|
+
// same rule as the single legacy spelling; the rest stay presets.
|
|
385
|
+
const named = (0, composite_1.namesOf)(rawPreset);
|
|
386
|
+
const listed = named.length > 1 && named.includes(exports.LEGACY_MULTI_PRESET);
|
|
387
|
+
const rest = (0, composite_1.compositeName)(named.filter((name) => name !== exports.LEGACY_MULTI_PRESET));
|
|
388
|
+
// `--deployment microservices` with no --runtime implies Kubernetes. There is no other
|
|
389
|
+
// runtime it could mean.
|
|
390
|
+
const implied = own(exports.DEPLOYMENT_ALIASES, rawDeployment) === exports.MICROSERVICES && !runtime;
|
|
391
|
+
out.runtime = implied ? exports.KUBERNETES : normalize(runtime);
|
|
392
|
+
if (implied)
|
|
393
|
+
out.hints.push('--deployment microservices implies --runtime kubernetes');
|
|
394
|
+
const [legacyN, absorbedDeployment, absorbedPreset] = absorbLegacySpellings(out, rawDeployment, listed ? exports.LEGACY_MULTI_PRESET : rawPreset, replicas);
|
|
395
|
+
rawDeployment = absorbedDeployment;
|
|
396
|
+
rawPreset = listed ? rest : absorbedPreset;
|
|
397
|
+
out.deployment = normalizeDeployment(rawDeployment, out.runtime);
|
|
398
|
+
out.preset = rawPreset;
|
|
399
|
+
out.replicas = resolveReplicas(replicas, legacyN, out);
|
|
400
|
+
if (out.deployment === exports.MULTI_INSTANCE) {
|
|
401
|
+
// Reached through the preset loader exactly as before -- see `Axes`. A scenario on top
|
|
402
|
+
// composes with it: every instance gets the scenario's settings, which the compose
|
|
403
|
+
// build applies to each clone.
|
|
404
|
+
out.preset = (0, composite_1.compositeName)([
|
|
405
|
+
...(0, composite_1.namesOf)(out.preset).filter((name) => name !== 'default'),
|
|
406
|
+
exports.LEGACY_MULTI_PRESET,
|
|
407
|
+
]);
|
|
408
|
+
// A typed --replicas wins, as it does in `resolveReplicas`: the record's own count, carried
|
|
409
|
+
// back as a param, made `up --force --replicas 4` rebuild a 3-instance workspace with 3.
|
|
410
|
+
if (out.params[exports.LEGACY_REPLICA_PARAM] === undefined || Number(replicas || 0) > 0) {
|
|
411
|
+
out.params[exports.LEGACY_REPLICA_PARAM] = out.replicas;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return out;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Refuse a runtime this build cannot yet create.
|
|
418
|
+
*
|
|
419
|
+
* Kept apart from `resolveAxes` on purpose. Resolving answers "what did you ask for", which
|
|
420
|
+
* a GUI needs in order to show Kubernetes as an option that is visible but not yet
|
|
421
|
+
* available; this answers "can I do it", which only the create path asks. Folding them
|
|
422
|
+
* together would mean the GUI could not name a runtime without also failing on it.
|
|
423
|
+
*/
|
|
424
|
+
function requireRegistered(runtime) {
|
|
425
|
+
if (isRegistered(runtime))
|
|
426
|
+
return;
|
|
427
|
+
throw new errors_1.ValidationError(`${label(runtime)} workspaces are not available in this build yet. Use --runtime docker.`);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* The axes a workspace was created with, as `CreateReq` fields.
|
|
431
|
+
*
|
|
432
|
+
* Two paths rebuild a request from an existing workspace -- `restore` and the GUI's
|
|
433
|
+
* recreate-a-downed-workspace button -- and both used to pass `preset=meta.preset`. For a
|
|
434
|
+
* multi-instance workspace that is the LEGACY spelling, so rebuilding one would print
|
|
435
|
+
* "--preset multi-instance is now --deployment multi-instance" at a user who typed neither
|
|
436
|
+
* and merely clicked Start. Reconstructing the axes properly means the deprecation hint
|
|
437
|
+
* only ever appears for a spelling someone actually used.
|
|
438
|
+
*
|
|
439
|
+
* Workspaces older than the deployment key are not lost: for those the deployment WAS the
|
|
440
|
+
* preset name, which is exactly the ambiguity the split removed going forward.
|
|
441
|
+
*/
|
|
442
|
+
function axesOfMeta(meta) {
|
|
443
|
+
const rawExtra = meta?.extra;
|
|
444
|
+
const extra = typeof rawExtra === 'object' && rawExtra !== null && !Array.isArray(rawExtra)
|
|
445
|
+
? rawExtra
|
|
446
|
+
: {};
|
|
447
|
+
const runtime = ofMeta(meta);
|
|
448
|
+
let preset = String(meta?.preset ?? '') || 'default';
|
|
449
|
+
const recorded = String(extra[config.EXTRA_DEPLOYMENT] ?? '')
|
|
450
|
+
.trim()
|
|
451
|
+
.toLowerCase();
|
|
452
|
+
let deployment = own(exports.DEPLOYMENT_ALIASES, recorded) ?? '';
|
|
453
|
+
if (!deployment) {
|
|
454
|
+
deployment =
|
|
455
|
+
preset === exports.LEGACY_MULTI_PRESET
|
|
456
|
+
? exports.MULTI_INSTANCE
|
|
457
|
+
: exports.DEPLOYMENTS[runtime][0];
|
|
458
|
+
}
|
|
459
|
+
// It is the deployment axis, not a scenario; any scenarios composed with it stay.
|
|
460
|
+
if (deployment === exports.MULTI_INSTANCE) {
|
|
461
|
+
preset = (0, composite_1.compositeName)((0, composite_1.namesOf)(preset).filter((name) => name !== exports.LEGACY_MULTI_PRESET));
|
|
462
|
+
}
|
|
463
|
+
// The recorded count read as an integer, 0 when it is absent, empty or not an integer.
|
|
464
|
+
const raw = extra[exports.LEGACY_REPLICA_PARAM];
|
|
465
|
+
const replicas = (raw === undefined || raw === null || raw === '' ? 0 : toInt(raw)) ?? 0;
|
|
466
|
+
// The CLUSTER is an axis too, and leaving it out silently RETARGETS. Both callers rebuild
|
|
467
|
+
// a CreateReq from this -- `restore`, and the GUI's start-a-downed-workspace button --
|
|
468
|
+
// and a request with no context sends `planCluster` back through its own four steps. On a
|
|
469
|
+
// box with the `kind` binary that means step 2: a workspace living in a remote cluster
|
|
470
|
+
// would be rebuilt by BUILDING A LOCAL CLUSTER for it. Empty stays empty, so a workspace
|
|
471
|
+
// older than `--context` keeps resolving exactly as it always did.
|
|
472
|
+
const out = { runtime, deployment, preset, replicas };
|
|
473
|
+
const context = String(extra[config.EXTRA_CONTEXT] ?? '').trim();
|
|
474
|
+
if (context)
|
|
475
|
+
out.context = context;
|
|
476
|
+
// Who runs MongoDB is an axis too: rebuilt without it, a workspace whose database the
|
|
477
|
+
// operator runs had houston's own MongoDB applied over it, and the apply failed. Absent
|
|
478
|
+
// otherwise, as `context` is.
|
|
479
|
+
if (extra.mongo_managed_by === 'operator')
|
|
480
|
+
out.mongoOperator = true;
|
|
481
|
+
return out;
|
|
482
|
+
}
|