@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,562 @@
|
|
|
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.SETTING_PREFIX = void 0;
|
|
37
|
+
exports.prefixSettings = prefixSettings;
|
|
38
|
+
exports.asSetting = asSetting;
|
|
39
|
+
exports.warnBareSettings = warnBareSettings;
|
|
40
|
+
exports.parseSet = parseSet;
|
|
41
|
+
exports.checkNames = checkNames;
|
|
42
|
+
exports.envRows = envRows;
|
|
43
|
+
exports.composeEnvironment = composeEnvironment;
|
|
44
|
+
exports.current = current;
|
|
45
|
+
exports.envTarget = envTarget;
|
|
46
|
+
exports.setEnv = setEnv;
|
|
47
|
+
exports.applyToCompose = applyToCompose;
|
|
48
|
+
exports.mergedOverrides = mergedOverrides;
|
|
49
|
+
exports.setEnvLocked = setEnvLocked;
|
|
50
|
+
exports.shown = shown;
|
|
51
|
+
/**
|
|
52
|
+
* Change a running repro's Rocket.Chat environment — shared by CLI and web API.
|
|
53
|
+
*
|
|
54
|
+
* An env var cannot be changed inside a running container: the environment is fixed when the
|
|
55
|
+
* container is created. What CAN be done is rewrite the compose file and let
|
|
56
|
+
* `docker compose up -d` recreate just the Rocket.Chat service — Mongo is left running and
|
|
57
|
+
* its volume untouched, so no data is lost and it takes seconds (no image pull).
|
|
58
|
+
*
|
|
59
|
+
* Overrides are stored in the repro's metadata (`extra["env"]`), not only in the compose
|
|
60
|
+
* file, because `up --force` rebuilds compose from the spec — anything living only in the
|
|
61
|
+
* generated file is silently dropped on the next rebuild.
|
|
62
|
+
*
|
|
63
|
+
* Same shape as `core/monitor.ts`, which mutates a running repro the same way.
|
|
64
|
+
*/
|
|
65
|
+
const compose_1 = require("../lib/compose");
|
|
66
|
+
const config = __importStar(require("../lib/config"));
|
|
67
|
+
const errors_1 = require("../lib/errors");
|
|
68
|
+
const events_1 = require("../lib/events");
|
|
69
|
+
const format_1 = require("../lib/format");
|
|
70
|
+
const json_text_1 = require("../lib/json-text");
|
|
71
|
+
const redact_1 = require("../lib/redact");
|
|
72
|
+
const admin_1 = require("./lifecycle/admin");
|
|
73
|
+
const naming_1 = require("./lifecycle/naming");
|
|
74
|
+
const preconditions_1 = require("./lifecycle/preconditions");
|
|
75
|
+
const ready_1 = require("./lifecycle/ready");
|
|
76
|
+
const rcapi_1 = require("./rcapi");
|
|
77
|
+
const engine_1 = require("./runner/engine");
|
|
78
|
+
const locks_1 = require("./runner/locks");
|
|
79
|
+
const queries_1 = require("./runner/queries");
|
|
80
|
+
const record_1 = require("./runner/record");
|
|
81
|
+
const topology = __importStar(require("./topology"));
|
|
82
|
+
/** Sentinel for "this key is not in the container at all", which is not the same as it
|
|
83
|
+
* being there with an empty value. */
|
|
84
|
+
const MISSING = Symbol('missing');
|
|
85
|
+
/**
|
|
86
|
+
* A POSIX-ish environment variable name. Anything else produces a compose file docker
|
|
87
|
+
* will not accept, so it is refused rather than written out.
|
|
88
|
+
*/
|
|
89
|
+
const NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/u;
|
|
90
|
+
/**
|
|
91
|
+
* Overriding these breaks how houston itself talks to the repro. Allowed anyway —
|
|
92
|
+
* reproducing a broken configuration is the point of the tool — but never silently.
|
|
93
|
+
*/
|
|
94
|
+
const LOAD_BEARING = Object.freeze({
|
|
95
|
+
MONGO_URL: "houston's Mongo connection; Rocket.Chat will not start if it is wrong",
|
|
96
|
+
PORT: 'the container port houston publishes; the workspace becomes unreachable',
|
|
97
|
+
ROOT_URL: 'set from --root-url/--https; overriding it here will fight those',
|
|
98
|
+
TRANSPORTER: 'the multi-instance NATS mesh',
|
|
99
|
+
});
|
|
100
|
+
exports.SETTING_PREFIX = 'OVERWRITE_SETTING_';
|
|
101
|
+
/**
|
|
102
|
+
* The value when it is a mapping, else `{}`.
|
|
103
|
+
*
|
|
104
|
+
* The declared record type says mapping, and a hand-edited or half-written repro.json can
|
|
105
|
+
* still hold a list there. Routed through `unknown` so the check is against what is on
|
|
106
|
+
* disk rather than against what the annotation claims.
|
|
107
|
+
*/
|
|
108
|
+
function bagOf(value) {
|
|
109
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
110
|
+
return {};
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A mapping made of what a hand-edited `extra.env` can hold.
|
|
115
|
+
*
|
|
116
|
+
* A mapping is copied. Anything else is read as a sequence of key/value PAIRS:
|
|
117
|
+
* `[["A", "1"]]` is `{A: "1"}`, and so is `["AB"]`, since a string is the sequence of its
|
|
118
|
+
* characters. `"abc"` is entry #0 with one item and `5` is not a sequence at all, each
|
|
119
|
+
* refused with what it was. `bagOf` answered `{}` for every one of them, so a list
|
|
120
|
+
* of pairs was dropped from the document and the record, and a string reported success
|
|
121
|
+
* where the right answer is a refusal before anything is written.
|
|
122
|
+
*
|
|
123
|
+
* NOT REPRODUCED: a pair keyed by a number, a bool or null. It is kept here under its JSON
|
|
124
|
+
* spelling. The previous implementation keeps the key as it is -- where `true` and `1` are
|
|
125
|
+
* one key -- writes both files, and then fails sorting it against a string for the
|
|
126
|
+
* display, exit 1.
|
|
127
|
+
*/
|
|
128
|
+
function dictOf(value) {
|
|
129
|
+
// A mapping is `orderedDict`'s copy: in the record's key order, with its numbers' spelling,
|
|
130
|
+
// where a copy key by key was in JavaScript's order, integer-like keys first.
|
|
131
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value))
|
|
132
|
+
return (0, json_text_1.orderedDict)(value);
|
|
133
|
+
const out = {};
|
|
134
|
+
if (!Array.isArray(value) && typeof value !== 'string') {
|
|
135
|
+
throw new TypeError((0, format_1.expectedText)('an object or a list of KEY/VALUE pairs', value));
|
|
136
|
+
}
|
|
137
|
+
Array.from(value).forEach((element, index) => {
|
|
138
|
+
const at = `env entry #${String(index)}`;
|
|
139
|
+
let pair;
|
|
140
|
+
if (Array.isArray(element))
|
|
141
|
+
pair = element;
|
|
142
|
+
else if (typeof element === 'string')
|
|
143
|
+
pair = Array.from(element);
|
|
144
|
+
else if (element !== null && typeof element === 'object')
|
|
145
|
+
pair = Object.keys(element);
|
|
146
|
+
else
|
|
147
|
+
throw new TypeError(`${at} is ${(0, format_1.valueKind)(element)}, not a KEY/VALUE pair`);
|
|
148
|
+
if (pair.length !== 2) {
|
|
149
|
+
throw (0, format_1.namedError)('InvalidValue', `${at} has ${String(pair.length)} item${pair.length === 1 ? '' : 's'}; a KEY/VALUE pair has 2`);
|
|
150
|
+
}
|
|
151
|
+
const [key, item] = pair;
|
|
152
|
+
if (key !== null && typeof key === 'object') {
|
|
153
|
+
throw new TypeError((0, format_1.keyRefusal)(key));
|
|
154
|
+
}
|
|
155
|
+
const name = typeof key === 'string'
|
|
156
|
+
? key
|
|
157
|
+
: key === null
|
|
158
|
+
? 'null'
|
|
159
|
+
: typeof key === 'boolean'
|
|
160
|
+
? String(key)
|
|
161
|
+
: (0, format_1.storedText)(key);
|
|
162
|
+
(0, format_1.setItemChecked)(out, name, item);
|
|
163
|
+
});
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* `{"Some_Setting": v}` -> `{"OVERWRITE_SETTING_Some_Setting": v}`.
|
|
168
|
+
*
|
|
169
|
+
* A Rocket.Chat SETTING only takes effect from the environment with this prefix; a
|
|
170
|
+
* bare setting id changes nothing at all. Both front-ends hand their "this is a
|
|
171
|
+
* setting" input through here rather than each prepending the prefix itself, so
|
|
172
|
+
* the rule lives in one place.
|
|
173
|
+
*
|
|
174
|
+
* Already-prefixed keys pass through, so a caller that pastes the full name is not
|
|
175
|
+
* double-prefixed.
|
|
176
|
+
*/
|
|
177
|
+
function prefixSettings(settings) {
|
|
178
|
+
const out = {};
|
|
179
|
+
for (const [rawKey, value] of Object.entries(settings ?? {})) {
|
|
180
|
+
const key = (0, format_1.stripText)(String(rawKey));
|
|
181
|
+
const bare = key.startsWith(exports.SETTING_PREFIX) ? key.slice(exports.SETTING_PREFIX.length) : key;
|
|
182
|
+
checkNames([bare]);
|
|
183
|
+
out[exports.SETTING_PREFIX + bare] = value;
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
/** `--setting Id=value` -> `{"OVERWRITE_SETTING_Id": "value"}`. */
|
|
188
|
+
function asSetting(pairs) {
|
|
189
|
+
return prefixSettings(parseSet(pairs));
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Warn when a key is a Rocket.Chat setting id used WITHOUT the prefix.
|
|
193
|
+
*
|
|
194
|
+
* This is the one mistake here with no feedback of its own: docker accepts the
|
|
195
|
+
* variable, Rocket.Chat ignores it, and the setting silently keeps its old value.
|
|
196
|
+
* Verified against a live workspace — `Accounts_ShowFormLogin=false` left the setting
|
|
197
|
+
* `true`, while `OVERWRITE_SETTING_Accounts_ShowFormLogin=false` applied.
|
|
198
|
+
*
|
|
199
|
+
* Best-effort: the workspace is asked which names are settings, so this is right for
|
|
200
|
+
* whatever version is running. If it cannot be reached, say nothing.
|
|
201
|
+
*/
|
|
202
|
+
async function warnBareSettings(meta, keys, emit = events_1.nullEmit) {
|
|
203
|
+
const candidates = keys.filter((key) => !key.startsWith(exports.SETTING_PREFIX));
|
|
204
|
+
if (candidates.length === 0)
|
|
205
|
+
return;
|
|
206
|
+
let known;
|
|
207
|
+
try {
|
|
208
|
+
const auth = await (0, admin_1.login)(meta);
|
|
209
|
+
known = await (0, rcapi_1.settingIds)(meta.rootUrl, auth, (0, record_1.adminPass)(meta));
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
// not serving yet, or not logged in; skip quietly
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (known === null || known.size === 0)
|
|
216
|
+
return;
|
|
217
|
+
for (const key of candidates) {
|
|
218
|
+
if (known.has(key)) {
|
|
219
|
+
(0, events_1.warn)(emit, `${key} is a Rocket.Chat SETTING, not an environment variable. ` +
|
|
220
|
+
`On its own it has no effect - use ${exports.SETTING_PREFIX}${key} ` +
|
|
221
|
+
`(or \`--setting ${key}=...\`).`, { phase: 'config' });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** Turn `["K=V", ...]` into `{K: V}`. Raises on a malformed pair or bad name. */
|
|
226
|
+
function parseSet(pairs) {
|
|
227
|
+
const out = {};
|
|
228
|
+
for (const raw of pairs ?? []) {
|
|
229
|
+
if (!raw.includes('=')) {
|
|
230
|
+
throw new errors_1.ValidationError(`--set ${(0, format_1.quotedText)(raw)} is not KEY=VALUE (to remove a key, use --unset ${raw})`);
|
|
231
|
+
}
|
|
232
|
+
const at = raw.indexOf('=');
|
|
233
|
+
// `stripText(key)`, not `trim()`: `--set $'\x1fFOO=1'` has always been FOO and was an
|
|
234
|
+
// invalid name here, and a BOM-led key the reverse. The same split as `chown --to`'s,
|
|
235
|
+
// at all three strips -- this one, `prefixSettings` and `checkNames`.
|
|
236
|
+
const key = (0, format_1.stripText)(raw.slice(0, at));
|
|
237
|
+
const value = raw.slice(at + 1);
|
|
238
|
+
if (!NAME_RE.test(key)) {
|
|
239
|
+
throw new errors_1.ValidationError(`${(0, format_1.quotedText)(key)} is not a valid environment variable name (letters, digits ` +
|
|
240
|
+
'and underscore; not starting with a digit)');
|
|
241
|
+
}
|
|
242
|
+
// An item set on a mapping (`setItemChecked`), where every name the rule above accepts is a
|
|
243
|
+
// key -- `__proto__` too. Assigned here, it hit `Object.prototype`'s accessor and was
|
|
244
|
+
// dropped, so `env --set __proto__=x` parsed to nothing and ran as a read.
|
|
245
|
+
(0, format_1.setItemChecked)(out, key, value);
|
|
246
|
+
}
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
function checkNames(keys) {
|
|
250
|
+
for (const key of keys) {
|
|
251
|
+
if (!NAME_RE.test((0, format_1.stripText)(key))) {
|
|
252
|
+
throw new errors_1.ValidationError(`${(0, format_1.quotedText)(key)} is not a valid environment variable name`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* A compose `environment` value as a name -> value map.
|
|
258
|
+
*
|
|
259
|
+
* Compose accepts both the map form and the list form (`"K=V"`). The split is on the
|
|
260
|
+
* FIRST `=` only, so a value that contains one keeps it: `"A=x=y"` is `A -> "x=y"`.
|
|
261
|
+
*/
|
|
262
|
+
function asEnvironmentMap(env) {
|
|
263
|
+
const out = {};
|
|
264
|
+
for (const item of Array.isArray(env) ? env : []) {
|
|
265
|
+
const text = (0, format_1.storedText)(item);
|
|
266
|
+
const at = text.indexOf('=');
|
|
267
|
+
// A mapping's item assignment (`setItemChecked`), so a `__proto__=x` item is a variable
|
|
268
|
+
// here too.
|
|
269
|
+
if (at < 0)
|
|
270
|
+
(0, format_1.setItemChecked)(out, text, '');
|
|
271
|
+
else
|
|
272
|
+
(0, format_1.setItemChecked)(out, text.slice(0, at), text.slice(at + 1));
|
|
273
|
+
}
|
|
274
|
+
return out;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Each variable, masked where it is a credential, and whether it has drifted.
|
|
278
|
+
*
|
|
279
|
+
* WHAT IT IS RUNNING, not only what it was asked to run. The Kubernetes branch of
|
|
280
|
+
* `current` already reads the container, and says why — "strictly more accurate". Compose
|
|
281
|
+
* could answer from the document it generated, so it did, and that is
|
|
282
|
+
* the wrong answer whenever the two disagree.
|
|
283
|
+
*
|
|
284
|
+
* MEASURED: an `env` apply interrupted mid-recreate left the variable in the compose file
|
|
285
|
+
* and in `repro.json` and absent from the container. `houston env` then displayed it as
|
|
286
|
+
* `<- yours` while Rocket.Chat used the old value, and neither `start`, `restart` nor a
|
|
287
|
+
* re-run `up` reconverged it. That lands on the exact question this command exists to
|
|
288
|
+
* answer — "is this setting actually set?" — and answered it wrongly, with a confirming
|
|
289
|
+
* display.
|
|
290
|
+
*
|
|
291
|
+
* `live` is null when the container could not be read (not running, Docker down); then
|
|
292
|
+
* there is nothing to compare against and the document is all there is, reported as before
|
|
293
|
+
* rather than as universal drift.
|
|
294
|
+
*/
|
|
295
|
+
function envRows(env, overrides, live) {
|
|
296
|
+
const rows = [];
|
|
297
|
+
const drift = [];
|
|
298
|
+
for (const key of Object.keys(env).sort()) {
|
|
299
|
+
const value = env[key];
|
|
300
|
+
// `Object.hasOwn`, not `in`: `'constructor' in {}` is TRUE, so a variable named
|
|
301
|
+
// after an `Object.prototype` property was reported as an override the document
|
|
302
|
+
// never recorded. Only a mapping's own keys count, so `hasOwn` is the faithful test.
|
|
303
|
+
const row = {
|
|
304
|
+
key,
|
|
305
|
+
value: (0, redact_1.redactEnv)(key, (0, format_1.storedText)(value)),
|
|
306
|
+
override: Object.hasOwn(overrides, key),
|
|
307
|
+
};
|
|
308
|
+
// A key absent from the container is a drift, and so is one whose value differs as
|
|
309
|
+
// text. The absence is compared as its own case rather than through `storedText`, since a
|
|
310
|
+
// sentinel has no meaningful text.
|
|
311
|
+
const liveValue = live !== null && Object.hasOwn(live, key) ? live[key] : MISSING;
|
|
312
|
+
if (live !== null && (liveValue === MISSING || (0, format_1.storedText)(liveValue) !== (0, format_1.storedText)(value))) {
|
|
313
|
+
// RECORDED BUT NOT IN EFFECT. Reported as its own state rather than folded into
|
|
314
|
+
// the value, because a caller has to be able to say which of the two numbers it
|
|
315
|
+
// is showing.
|
|
316
|
+
row.drift = true;
|
|
317
|
+
row.live = Object.hasOwn(live, key) ? (0, redact_1.redactEnv)(key, (0, format_1.storedText)(live[key])) : '';
|
|
318
|
+
drift.push(key);
|
|
319
|
+
}
|
|
320
|
+
rows.push(row);
|
|
321
|
+
}
|
|
322
|
+
return { drift, live, rows };
|
|
323
|
+
}
|
|
324
|
+
/** What the compose document says this workspace was asked to run with. */
|
|
325
|
+
async function composeEnvironment(meta, target) {
|
|
326
|
+
const doc = await (0, record_1.readCompose)(target);
|
|
327
|
+
const services = bagOf(doc.services);
|
|
328
|
+
// `rocketchat` by a truth test, else `rocketchat-1`: an EMPTY map is falsy, so a
|
|
329
|
+
// document with `rocketchat: {}` and a populated `rocketchat-1` reads the multi-instance
|
|
330
|
+
// service. `??` only fell back for null/undefined and answered no variables at all for
|
|
331
|
+
// that document; measured against the previous implementation.
|
|
332
|
+
const primary = services.rocketchat;
|
|
333
|
+
const rc = bagOf((0, format_1.isTruthy)(primary) ? primary : services['rocketchat-1']);
|
|
334
|
+
// THE LIST FORM IS REAL: compose accepts `environment: ["K=V", ...]` and both
|
|
335
|
+
// `readCompose` consumers have to see the same map. `bagOf` alone would answer `{}`
|
|
336
|
+
// for it, so `houston env` would show no variables at all for a document docker runs
|
|
337
|
+
// perfectly well.
|
|
338
|
+
const raw = rc.environment;
|
|
339
|
+
const env = Array.isArray(raw) ? asEnvironmentMap(raw) : bagOf(raw);
|
|
340
|
+
const overrides = bagOf(bagOf(meta.extra).env);
|
|
341
|
+
return { env, overrides };
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* The overrides that are removals (`env --unset` records the key as null). `overrides` keeps
|
|
345
|
+
* listing them, as earlier releases did; a reader that says "your overrides" leaves these out,
|
|
346
|
+
* or an unset key was still named as one (live matrix 2026-10-30, F1).
|
|
347
|
+
*/
|
|
348
|
+
function removedKeys(overrides) {
|
|
349
|
+
return Object.keys(overrides)
|
|
350
|
+
.filter((key) => overrides[key] === null)
|
|
351
|
+
.sort();
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* The RC service's effective environment, credentials masked, plus which keys are user
|
|
355
|
+
* overrides — so a caller can show what was changed versus inherited.
|
|
356
|
+
*
|
|
357
|
+
* Answered per runtime. On Compose that is the generated compose document; on Kubernetes
|
|
358
|
+
* there is no such document, so the running container is asked — which is strictly more
|
|
359
|
+
* accurate, since the chart contributes variables houston never set and the helm values
|
|
360
|
+
* would not show them.
|
|
361
|
+
*
|
|
362
|
+
* This path first threw a bare ENOENT naming
|
|
363
|
+
* `repros/<n>/docker-compose.yml` — a path, with no statement of what was wrong — which
|
|
364
|
+
* escaped the ReproError contract so `serve` answered 500 to a request that was merely
|
|
365
|
+
* unsupported. It then refused cleanly, and now answers.
|
|
366
|
+
*/
|
|
367
|
+
async function current(name) {
|
|
368
|
+
const target = await (0, naming_1.resolveName)(name);
|
|
369
|
+
const meta = await (0, record_1.readMeta)(target);
|
|
370
|
+
if ((await topology.ofRepro(target)) === topology.KUBERNETES) {
|
|
371
|
+
// Read from the RUNNING CONTAINER, not from a document. Compose can answer this from
|
|
372
|
+
// the file it generated; there is no such file here, and the helm values are only
|
|
373
|
+
// what houston asked for — the chart adds its own on top, so they are not the answer
|
|
374
|
+
// to "what is Rocket.Chat running with".
|
|
375
|
+
const { containerEnv } = await Promise.resolve().then(() => __importStar(require('./kube/status')));
|
|
376
|
+
const ctxValue = bagOf(meta.extra)[config.EXTRA_CONTEXT];
|
|
377
|
+
const context = String((0, format_1.isTruthy)(ctxValue) ? ctxValue : (await Promise.resolve().then(() => __importStar(require('./kube/names')))).CONTEXT);
|
|
378
|
+
const env = await containerEnv(target, { context });
|
|
379
|
+
const overrides = bagOf(bagOf(meta.extra).env);
|
|
380
|
+
return {
|
|
381
|
+
name: target,
|
|
382
|
+
env: Object.keys(env)
|
|
383
|
+
.sort()
|
|
384
|
+
.map((key) => ({
|
|
385
|
+
key,
|
|
386
|
+
value: (0, redact_1.redactEnv)(key, (0, format_1.storedText)(env[key])),
|
|
387
|
+
override: Object.hasOwn(overrides, key),
|
|
388
|
+
})),
|
|
389
|
+
overrides: Object.keys(overrides).sort(),
|
|
390
|
+
removed: removedKeys(overrides),
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
const { env, overrides } = await composeEnvironment(meta, target);
|
|
394
|
+
const { drift, live, rows } = envRows(env, overrides, await (0, queries_1.rcContainerEnv)(target));
|
|
395
|
+
return {
|
|
396
|
+
name: target,
|
|
397
|
+
env: rows,
|
|
398
|
+
overrides: Object.keys(overrides).sort(),
|
|
399
|
+
removed: removedKeys(overrides),
|
|
400
|
+
// The keys the workspace records and is not running. Empty when there are none AND
|
|
401
|
+
// when the container could not be read — `live_read` says which.
|
|
402
|
+
drift,
|
|
403
|
+
live_read: live !== null,
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Apply env changes to a repro and recreate Rocket.Chat so they take effect.
|
|
408
|
+
*
|
|
409
|
+
* `sets` adds or replaces; `unset` removes a key entirely (including a base or preset
|
|
410
|
+
* default, which merely blanking it would not do).
|
|
411
|
+
*/
|
|
412
|
+
/**
|
|
413
|
+
* The workspace an env change acts on, refused where it has no Compose document to change.
|
|
414
|
+
*
|
|
415
|
+
* No Kubernetes path yet. Reaching for the compose project answers "no configuration file
|
|
416
|
+
* provided", which names nothing a user can act on — so this refuses and hands over the
|
|
417
|
+
* command that does the job. RESOLVED FIRST, because the refusal QUOTES the name.
|
|
418
|
+
* `requireCompose` ran on the raw argument, so `env --set X=1 --name TICKET-1234` handed
|
|
419
|
+
* over `helm -n houston-TICKET-1234 ...` — a namespace that does not exist, for a workspace
|
|
420
|
+
* really called `ticket-1234`. A refusal whose suggested command cannot work is worse than
|
|
421
|
+
* a bare refusal: it sends somebody to debug kubectl. Exported so the GUI refuses before it
|
|
422
|
+
* queues a job, not inside one.
|
|
423
|
+
*/
|
|
424
|
+
async function envTarget(name) {
|
|
425
|
+
const target = await (0, naming_1.resolveName)(name);
|
|
426
|
+
await topology.requireCompose(target, 'env', {
|
|
427
|
+
instead: `Use \`helm -n houston-${target} upgrade rocketchat --reuse-values ` +
|
|
428
|
+
'--set extraEnv[0].name=...`, or `houston api` for a runtime setting.',
|
|
429
|
+
});
|
|
430
|
+
return target;
|
|
431
|
+
}
|
|
432
|
+
async function setEnv(name, sets = null, unset = null, { restart = true, emit = events_1.nullEmit } = {}) {
|
|
433
|
+
const target = await envTarget(name);
|
|
434
|
+
await (0, preconditions_1.requireDocker)();
|
|
435
|
+
// Serialised against every other mutating operation on this repro: this does
|
|
436
|
+
// read-compose -> write-compose -> `docker compose up`, and interleaving that with a
|
|
437
|
+
// backup, an upgrade or another env change races compose against itself.
|
|
438
|
+
return await (0, locks_1.reproLock)(target, async () => await setEnvLocked(target, sets, unset, { restart, emit }));
|
|
439
|
+
}
|
|
440
|
+
/** Write the overrides onto every Rocket.Chat service in the document. */
|
|
441
|
+
async function applyToCompose(overrides, target) {
|
|
442
|
+
const doc = await (0, record_1.readCompose)(target);
|
|
443
|
+
// The services, deliberately NOT through `bagOf`, so a present-but-null `services:`
|
|
444
|
+
// throws here, as it always has. A MISSING key reads as `{}` and reaches the DockerError
|
|
445
|
+
// below; it used to be `Object.keys(undefined)`, a raw TypeError out of the error
|
|
446
|
+
// contract.
|
|
447
|
+
const services = doc.services === undefined ? {} : doc.services;
|
|
448
|
+
const rcServices = Object.keys(services).filter((service) => service === 'rocketchat' || service.startsWith('rocketchat-'));
|
|
449
|
+
if (rcServices.length === 0) {
|
|
450
|
+
throw new errors_1.DockerError(`${(0, format_1.quotedText)(target)} has no rocketchat service to change`);
|
|
451
|
+
}
|
|
452
|
+
for (const service of rcServices) {
|
|
453
|
+
const entry = services[service];
|
|
454
|
+
if (!('environment' in entry))
|
|
455
|
+
entry.environment = {};
|
|
456
|
+
const existing = entry.environment;
|
|
457
|
+
const env = Array.isArray(existing) ? asEnvironmentMap(existing) : existing;
|
|
458
|
+
entry.environment = env;
|
|
459
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
460
|
+
if (value === null)
|
|
461
|
+
delete env[key];
|
|
462
|
+
// Each value through `storedText`: a recorded override that is not a string (a
|
|
463
|
+
// hand-edited repro.json, or a manifest `env_overrides` carrying a JSON
|
|
464
|
+
// number/bool) is the STRING `'8080'` / `'True'` in the document, not a YAML
|
|
465
|
+
// number/bool. Defined rather than assigned, so an override named `__proto__` lands
|
|
466
|
+
// in the document like any other variable.
|
|
467
|
+
else
|
|
468
|
+
(0, format_1.setItemChecked)(env, key, (0, format_1.storedText)(value));
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return { doc, rcServices };
|
|
472
|
+
}
|
|
473
|
+
/** Fold this call's sets and unsets into the workspace's recorded overrides. */
|
|
474
|
+
async function mergedOverrides(emit, sets, target, unset) {
|
|
475
|
+
const meta = await (0, record_1.readMeta)(target);
|
|
476
|
+
// The recorded `env` when `extra` is a mapping and `env` is truthy, else nothing: a
|
|
477
|
+
// record whose `extra` is not a mapping starts from nothing, and its `env` goes through
|
|
478
|
+
// `dictOf`.
|
|
479
|
+
const recorded = bagOf(meta.extra).env;
|
|
480
|
+
const overrides = dictOf((0, format_1.isTruthy)(recorded) ? recorded : {});
|
|
481
|
+
for (const key of unset) {
|
|
482
|
+
// null (not "") records "remove this key", so a preset default really goes away
|
|
483
|
+
// instead of being set to an empty string.
|
|
484
|
+
(0, format_1.setItemChecked)(overrides, key, null);
|
|
485
|
+
}
|
|
486
|
+
// Each set merged in key by key (`setItemChecked`). `Object.assign` assigns through
|
|
487
|
+
// the prototype chain, and so did `overrides[key] = null`: `--set __proto__=x` was
|
|
488
|
+
// dropped from the record and the document, and `--unset __proto__` replaced the
|
|
489
|
+
// object's prototype instead of recording the removal.
|
|
490
|
+
for (const [key, value] of Object.entries(sets))
|
|
491
|
+
(0, format_1.setItemChecked)(overrides, key, value);
|
|
492
|
+
for (const key of Object.keys(sets)) {
|
|
493
|
+
// An OWN key of `LOAD_BEARING` only. A lookup by name reached `Object.prototype`
|
|
494
|
+
// instead, so `--set constructor=x` warned with the function's own source where the
|
|
495
|
+
// established answer is no warning at all.
|
|
496
|
+
if (Object.hasOwn(LOAD_BEARING, key)) {
|
|
497
|
+
(0, events_1.warn)(emit, `${key} is load-bearing: ${LOAD_BEARING[key]}. Setting it anyway.`, {
|
|
498
|
+
phase: 'config',
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
await warnBareSettings(meta, Object.keys(sets), emit);
|
|
503
|
+
return { meta, overrides };
|
|
504
|
+
}
|
|
505
|
+
async function setEnvLocked(target, setsValue, unsetValue, { restart = true, emit = events_1.nullEmit } = {}) {
|
|
506
|
+
const sets = { ...(setsValue ?? {}) };
|
|
507
|
+
const unset = [...(unsetValue ?? [])];
|
|
508
|
+
checkNames([...Object.keys(sets), ...unset]);
|
|
509
|
+
if (Object.keys(sets).length === 0 && unset.length === 0) {
|
|
510
|
+
throw new errors_1.ValidationError('nothing to change (use --set KEY=VALUE or --unset KEY)');
|
|
511
|
+
}
|
|
512
|
+
const { meta, overrides } = await mergedOverrides(emit, sets, target, unset);
|
|
513
|
+
const { doc, rcServices } = await applyToCompose(overrides, target);
|
|
514
|
+
// `meta.extra["env"] = overrides`, which is a TypeError when `extra` is not a mapping --
|
|
515
|
+
// raised before anything is written. Assigned into `bagOf`'s throwaway `{}`, the override
|
|
516
|
+
// reached docker-compose.yml and not repro.json, so the next `up --force` rebuilt it away.
|
|
517
|
+
(0, format_1.setItemChecked)(meta.extra, 'env', overrides);
|
|
518
|
+
await (0, record_1.write)(target, (0, compose_1.toYaml)(doc), meta);
|
|
519
|
+
const changed = [...Object.keys(sets), ...unset].sort().join(', ');
|
|
520
|
+
(0, events_1.info)(emit, `env updated on ${(0, format_1.quotedText)(target)}: ${changed}`, { phase: 'config' });
|
|
521
|
+
if (!restart) {
|
|
522
|
+
// Not `up`: on a running workspace it recreates nothing. Re-running `env` forces it.
|
|
523
|
+
(0, events_1.info)(emit, 'not restarting; the change is written but not applied. To apply it, re-run the ' +
|
|
524
|
+
'same `houston env` without --no-restart', { phase: 'done' });
|
|
525
|
+
return { name: target, restarted: false, overrides: shown(overrides) };
|
|
526
|
+
}
|
|
527
|
+
// An env change only reaches Rocket.Chat by recreating the container. compose recreates
|
|
528
|
+
// just the services whose config changed, so Mongo keeps running and its volume is
|
|
529
|
+
// untouched — no data loss, and no image pull.
|
|
530
|
+
(0, events_1.info)(emit, 'recreating the Rocket.Chat container (data is kept)...', { phase: 'boot' });
|
|
531
|
+
// FORCED, so an interrupted apply is healed by the next one. Compose decides what to
|
|
532
|
+
// recreate from a config hash on the container, and that was measured not to fire: an
|
|
533
|
+
// apply interrupted mid-recreate left the compose file carrying a variable the
|
|
534
|
+
// container did not have, and re-running `env`, `restart` and `up` all reported success
|
|
535
|
+
// without changing anything. Scoped to the one service, so Mongo and its volume are
|
|
536
|
+
// untouched — which is the reason recreating here is safe at all.
|
|
537
|
+
if ((await (0, engine_1.up)(target, { pull: false, forceRecreate: rcServices[0] })) !== 0) {
|
|
538
|
+
throw new errors_1.DockerError('`docker compose up` failed applying the env change');
|
|
539
|
+
}
|
|
540
|
+
// WAITED FOR, so the command returns when Rocket.Chat answers again. It returned as soon
|
|
541
|
+
// as compose had recreated the container, and a `seed` typed straight after refused
|
|
542
|
+
// "repro not ready" while the new container booted. No line of its own: the wait sits
|
|
543
|
+
// under the "recreating" line, and "restarted" is said once it is true. A container the
|
|
544
|
+
// new environment stops from serving is a NotReadyError (exit 5) naming why, not a
|
|
545
|
+
// success; the change is written either way, so `env --unset` is the way back.
|
|
546
|
+
await (0, ready_1.waitServing)(await (0, record_1.readMeta)(target), emit, 300.0);
|
|
547
|
+
(0, events_1.info)(emit, `${(0, format_1.quotedText)(target)} restarted with the new environment`, { phase: 'done' });
|
|
548
|
+
return { name: target, restarted: true, overrides: shown(overrides) };
|
|
549
|
+
}
|
|
550
|
+
/** Overrides for display: values masked by key, removals marked. */
|
|
551
|
+
function shown(overrides) {
|
|
552
|
+
const out = [];
|
|
553
|
+
for (const key of Object.keys(overrides).sort()) {
|
|
554
|
+
const value = overrides[key];
|
|
555
|
+
out.push({
|
|
556
|
+
key,
|
|
557
|
+
removed: value === null,
|
|
558
|
+
value: value === null ? '' : (0, redact_1.redactEnv)(key, (0, format_1.storedText)(value)),
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
return out;
|
|
562
|
+
}
|