@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,496 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PRESIGNED_OVER_HTTPS = exports.LDAPADMIN_PATH = exports.MINIO_PATH = exports.DEMO_PATH = exports.KEYCLOAK_PATH = exports.MAILPIT_PATH = void 0;
|
|
4
|
+
exports.withPublicUrl = withPublicUrl;
|
|
5
|
+
exports.presignedOverHttps = presignedOverHttps;
|
|
6
|
+
exports.publicPathsOf = publicPathsOf;
|
|
7
|
+
/**
|
|
8
|
+
* A preset's own web UIs at paths of the workspace's HTTPS name, as Grafana is at /grafana:
|
|
9
|
+
* Mailpit at /mailpit, Keycloak at /keycloak, the livechat demo page at /livechat-demo, the
|
|
10
|
+
* MinIO console at /minio and phpLDAPadmin at /phpldapadmin.
|
|
11
|
+
*
|
|
12
|
+
* Applied by the create once the public URL is known (it is not when presets are loaded),
|
|
13
|
+
* the way `withCertificate` is. Pure: it rewrites the preset for either runtime and records
|
|
14
|
+
* what to route in `extra.public_paths`; the edge (Compose) and an Ingress (Kubernetes) do
|
|
15
|
+
* the routing.
|
|
16
|
+
*
|
|
17
|
+
* Each UI serves from its path itself where it can -- Mailpit's web root, Keycloak's relative
|
|
18
|
+
* path, the demo page copied under its path -- so no edge or Ingress rewrites a prefix, which
|
|
19
|
+
* ingress controllers each do their own way. The MinIO console and phpLDAPadmin 2 have no
|
|
20
|
+
* such setting (they expect the prefix stripped), so a small nginx of each one's own,
|
|
21
|
+
* `minio-ui` and `ldap-ui`, strips it on both runtimes. `/livechat` is not
|
|
22
|
+
* available: Rocket.Chat serves its own widget there on the same host.
|
|
23
|
+
*/
|
|
24
|
+
const guides_1 = require("./guides");
|
|
25
|
+
const common_1 = require("./common");
|
|
26
|
+
exports.MAILPIT_PATH = '/mailpit';
|
|
27
|
+
exports.KEYCLOAK_PATH = '/keycloak';
|
|
28
|
+
exports.DEMO_PATH = '/livechat-demo';
|
|
29
|
+
exports.MINIO_PATH = '/minio';
|
|
30
|
+
exports.LDAPADMIN_PATH = '/phpldapadmin';
|
|
31
|
+
const NGINX_ROOT = '/usr/share/nginx/html';
|
|
32
|
+
const NGINX_IMAGE = 'docker.io/nginx:alpine';
|
|
33
|
+
const MINIO_UI = 'minio-ui';
|
|
34
|
+
const UI_PORT_LABEL = 'houston.io/ui-port';
|
|
35
|
+
/**
|
|
36
|
+
* Presigned downloads are links to MinIO's own http:// port, and an https page may not load
|
|
37
|
+
* them: measured on a live domain, Chrome requested `https://minio:9000/...` for the image
|
|
38
|
+
* and it failed. Said at create and in the notes.
|
|
39
|
+
*/
|
|
40
|
+
exports.PRESIGNED_OVER_HTTPS = 'presigned mode over HTTPS: the download links are http:// to MinIO on an https page, ' +
|
|
41
|
+
'which browsers treat as mixed content: Chrome rewrites them to https://, which MinIO ' +
|
|
42
|
+
'does not serve, so previews and downloads break, as on a customer site with an http S3 ' +
|
|
43
|
+
'endpoint. The default proxy mode works over HTTPS.';
|
|
44
|
+
/**
|
|
45
|
+
* The MinIO console under /minio/, its own root on the far side. Its page names /minio/ as
|
|
46
|
+
* its base (MINIO_BROWSER_REDIRECT_URL), so every request the browser makes comes back here.
|
|
47
|
+
* `minio` reaches the console on both runtimes: the Compose service, and on Kubernetes the
|
|
48
|
+
* primary Service, which carries every port the workload listens on.
|
|
49
|
+
*
|
|
50
|
+
* ponytail: nginx resolves `minio` once, at start. A Compose `minio` restarted alone with a
|
|
51
|
+
* new address answers 502 here until `minio-ui` restarts too; no houston command does that
|
|
52
|
+
* (re-`up` downs everything first, `start` starts minio first). A Kubernetes Service keeps
|
|
53
|
+
* its address while it exists, and `down` keeps the presets' Services for that reason.
|
|
54
|
+
*/
|
|
55
|
+
function minioUiConf(consolePort) {
|
|
56
|
+
return `server {
|
|
57
|
+
listen 80;
|
|
58
|
+
absolute_redirect off;
|
|
59
|
+
location = / { return 302 ${exports.MINIO_PATH}/; }
|
|
60
|
+
location = ${exports.MINIO_PATH} { return 301 ${exports.MINIO_PATH}/; }
|
|
61
|
+
location ${exports.MINIO_PATH}/ {
|
|
62
|
+
proxy_pass http://minio:${String(consolePort)}/;
|
|
63
|
+
proxy_http_version 1.1;
|
|
64
|
+
proxy_set_header Host $http_host;
|
|
65
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
66
|
+
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
67
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
68
|
+
proxy_set_header Connection "upgrade";
|
|
69
|
+
chunked_transfer_encoding off;
|
|
70
|
+
client_max_body_size 0;
|
|
71
|
+
proxy_buffering off;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Short on purpose: the edge reaches it as `houston-<name>-ldap-ui-1`, a DNS label, and
|
|
78
|
+
* `phpldapadmin-ui` would have been the longest container it routes to (`naming.DERIVED_MAX`).
|
|
79
|
+
*/
|
|
80
|
+
const LDAPADMIN_UI = 'ldap-ui';
|
|
81
|
+
/**
|
|
82
|
+
* phpLDAPadmin 2 has no server-path setting (1.x's PHPLDAPADMIN_SERVER_PATH is gone): it serves
|
|
83
|
+
* from / and builds every link from `X-Forwarded-Prefix`, which it believes from the private
|
|
84
|
+
* ranges its image trusts by default (APP_TRUST_PROXIES: 10/8, 127/8, 172.16/12, 192.168/16 --
|
|
85
|
+
* a Docker or Podman network, a k3s or EKS-default pod). So this strips the prefix and names
|
|
86
|
+
* it, as the maintainer's own configuration does (leenooks/phpLDAPadmin#435).
|
|
87
|
+
*
|
|
88
|
+
* ponytail: nginx resolves `phpldapadmin` once, at start, as `minio-ui` does `minio`; a pod
|
|
89
|
+
* network outside those ranges would need APP_TRUST_PROXIES set on phpLDAPadmin too.
|
|
90
|
+
*/
|
|
91
|
+
function ldapadminUiConf(upstreamPort) {
|
|
92
|
+
return `server {
|
|
93
|
+
listen 80;
|
|
94
|
+
absolute_redirect off;
|
|
95
|
+
location = / { return 302 ${exports.LDAPADMIN_PATH}/; }
|
|
96
|
+
location = ${exports.LDAPADMIN_PATH} { return 301 ${exports.LDAPADMIN_PATH}/; }
|
|
97
|
+
location ${exports.LDAPADMIN_PATH}/ {
|
|
98
|
+
proxy_pass http://phpldapadmin:${String(upstreamPort)}/;
|
|
99
|
+
proxy_http_version 1.1;
|
|
100
|
+
proxy_set_header Host $http_host;
|
|
101
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
102
|
+
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
103
|
+
proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
|
|
104
|
+
proxy_set_header X-Forwarded-Prefix ${exports.LDAPADMIN_PATH};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
const bag = (value) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
110
|
+
/** The Kubernetes manifests as documents, to edit and dump back. */
|
|
111
|
+
function docsOf(pre) {
|
|
112
|
+
return pre.kubernetesManifests.map((manifest) => (0, common_1.safeLoadAll)(manifest).map(bag));
|
|
113
|
+
}
|
|
114
|
+
const dumpAll = (docs) => docs.map((one) => one.map((doc) => (0, common_1.safeDump)(doc)).join('---\n'));
|
|
115
|
+
const find = (docs, kind, name) => docs.flat().find((doc) => doc.kind === kind && bag(doc.metadata).name === name);
|
|
116
|
+
function containerOf(deployment) {
|
|
117
|
+
const spec = bag(bag(bag(deployment.spec).template).spec);
|
|
118
|
+
return bag(spec.containers[0]);
|
|
119
|
+
}
|
|
120
|
+
function addEnv(container, env) {
|
|
121
|
+
const list = Array.isArray(container.env) ? container.env : [];
|
|
122
|
+
for (const [name, value] of Object.entries(env)) {
|
|
123
|
+
const at = list.findIndex((entry) => entry.name === name);
|
|
124
|
+
if (at >= 0)
|
|
125
|
+
list[at] = { name, value };
|
|
126
|
+
else
|
|
127
|
+
list.push({ name, value });
|
|
128
|
+
}
|
|
129
|
+
container.env = list;
|
|
130
|
+
}
|
|
131
|
+
function probePath(container, path) {
|
|
132
|
+
const get = bag(bag(container.readinessProbe).httpGet);
|
|
133
|
+
if (typeof get.path === 'string')
|
|
134
|
+
get.path = path;
|
|
135
|
+
}
|
|
136
|
+
/** What the workspace would reach `service` at: its container port and its Service port. */
|
|
137
|
+
function ports(pre, service, docs, fallback) {
|
|
138
|
+
const compose = bag(pre.services[service]);
|
|
139
|
+
const mapping = Array.isArray(compose.ports) ? String(compose.ports[0] ?? '') : '';
|
|
140
|
+
const [published = '', inside = ''] = mapping.split(':').slice(-2);
|
|
141
|
+
const svc = find(docs, 'Service', service);
|
|
142
|
+
const first = svc === undefined ? undefined : bag(bag(svc.spec).ports[0]);
|
|
143
|
+
const container = Number(inside) || Number(first?.targetPort) || fallback;
|
|
144
|
+
const exposed = Number(first?.port) || Number(published) || fallback;
|
|
145
|
+
return [container, exposed];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The HOST port a side UI is published on in this workspace: its `houston.io/ui-port` label on
|
|
149
|
+
* Kubernetes (read before this module moves the label), the host side of its mapping on
|
|
150
|
+
* Compose. Read off the preset, never the registry, so it is whatever port the builder was
|
|
151
|
+
* given. 0 when the preset publishes none there.
|
|
152
|
+
*/
|
|
153
|
+
function hostPortOf(pre, docs, kube, service, { k8sService = service, index = 0 } = {}) {
|
|
154
|
+
if (kube) {
|
|
155
|
+
const svc = find(docs, 'Service', k8sService);
|
|
156
|
+
return Number(bag(bag(svc?.metadata).labels)[UI_PORT_LABEL]) || 0;
|
|
157
|
+
}
|
|
158
|
+
const mappings = bag(pre.services[service]).ports;
|
|
159
|
+
const mapping = Array.isArray(mappings) ? String(mappings[index] ?? '') : '';
|
|
160
|
+
return Number(mapping.split(':').slice(-2)[0]) || 0;
|
|
161
|
+
}
|
|
162
|
+
function addRedirects(realm, publicUrl) {
|
|
163
|
+
const parsed = JSON.parse(realm);
|
|
164
|
+
for (const client of parsed.clients ?? []) {
|
|
165
|
+
const uris = Array.isArray(client.redirectUris) ? client.redirectUris : [];
|
|
166
|
+
if (!uris.includes(`${publicUrl}/*`))
|
|
167
|
+
client.redirectUris = [...uris, `${publicUrl}/*`];
|
|
168
|
+
}
|
|
169
|
+
return JSON.stringify(parsed, null, 2);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The notes that send a browser to Keycloak by its port or a hosts entry, as runs of lines:
|
|
173
|
+
* how each run starts, and its length. Runs, not patterns: a composed workspace's notes are
|
|
174
|
+
* merged, and s3_minio's presigned-mode hosts entry is worded line for line like oidc's.
|
|
175
|
+
*/
|
|
176
|
+
const KEYCLOAK_HOST_NOTES = [
|
|
177
|
+
['OIDC needs one host entry', 5],
|
|
178
|
+
[" It is 'localhost', so the browser must be on the machine running houston", 3],
|
|
179
|
+
// ldap's SSO notes: the sentence, then the entry to paste on its own line.
|
|
180
|
+
['A browser on the machine running houston needs a hosts entry for Keycloak', 2],
|
|
181
|
+
['From another computer, create the workspace with HTTPS on a domain', 1],
|
|
182
|
+
];
|
|
183
|
+
function dropRuns(notes, runs) {
|
|
184
|
+
const out = [...notes];
|
|
185
|
+
for (const [start, length] of runs) {
|
|
186
|
+
const at = out.findIndex((note) => note.startsWith(start));
|
|
187
|
+
if (at >= 0)
|
|
188
|
+
out.splice(at, length);
|
|
189
|
+
}
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
192
|
+
/** Notes with one address replaced by another, wherever it appears. */
|
|
193
|
+
function rewrite(notes, from, to) {
|
|
194
|
+
return notes.map((note) => note.split(from).join(to));
|
|
195
|
+
}
|
|
196
|
+
/** The preset, with its UIs served under `publicUrl` on `runtime`. */
|
|
197
|
+
function withPublicUrl(pre, publicUrl, runtime) {
|
|
198
|
+
const base = publicUrl.replace(/\/+$/u, '');
|
|
199
|
+
const kube = runtime === 'kubernetes';
|
|
200
|
+
const out = {
|
|
201
|
+
...pre,
|
|
202
|
+
env: { ...pre.env },
|
|
203
|
+
services: JSON.parse(JSON.stringify(pre.services)),
|
|
204
|
+
files: [...pre.files],
|
|
205
|
+
notes: [...pre.notes],
|
|
206
|
+
guides: (0, guides_1.withoutLocalSetup)(pre.guides),
|
|
207
|
+
postReady: pre.postReady.map((action) => JSON.parse(JSON.stringify(action))),
|
|
208
|
+
extra: { ...pre.extra },
|
|
209
|
+
};
|
|
210
|
+
const docs = docsOf(pre);
|
|
211
|
+
const has = (name) => kube ? find(docs, 'Deployment', name) !== undefined : name in out.services;
|
|
212
|
+
const paths = [];
|
|
213
|
+
if (has('mailpit')) {
|
|
214
|
+
const [container, exposed] = ports(pre, 'mailpit', docs, 8025);
|
|
215
|
+
paths.push({
|
|
216
|
+
preset: 'email',
|
|
217
|
+
path: exports.MAILPIT_PATH,
|
|
218
|
+
service: 'mailpit',
|
|
219
|
+
container_port: container,
|
|
220
|
+
service_port: exposed,
|
|
221
|
+
});
|
|
222
|
+
if (kube) {
|
|
223
|
+
const c = containerOf(find(docs, 'Deployment', 'mailpit'));
|
|
224
|
+
addEnv(c, { MP_WEBROOT: exports.MAILPIT_PATH });
|
|
225
|
+
probePath(c, `${exports.MAILPIT_PATH}/`);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
const svc = bag(out.services.mailpit);
|
|
229
|
+
svc.environment = { ...bag(svc.environment), MP_WEBROOT: exports.MAILPIT_PATH };
|
|
230
|
+
}
|
|
231
|
+
// houston reads 2FA codes from Mailpit's API, which now lives under the path too.
|
|
232
|
+
const local = typeof out.extra.mailpit_url === 'string' ? out.extra.mailpit_url : '';
|
|
233
|
+
if (local)
|
|
234
|
+
out.extra.mailpit_url = `${local.replace(/\/+$/u, '')}${exports.MAILPIT_PATH}`;
|
|
235
|
+
// Its own port answers only under the path now: say the address that works anywhere.
|
|
236
|
+
// The HOST port, which the notes name: on Kubernetes `exposed` is the Service's.
|
|
237
|
+
out.notes = rewrite(out.notes, `http://localhost:${String(hostPortOf(pre, docs, kube, 'mailpit'))}`, `${base}${exports.MAILPIT_PATH}/`);
|
|
238
|
+
}
|
|
239
|
+
if (has('widget-site')) {
|
|
240
|
+
const [container, exposed] = ports(pre, 'widget-site', docs, 80);
|
|
241
|
+
paths.push({
|
|
242
|
+
preset: 'livechat',
|
|
243
|
+
path: exports.DEMO_PATH,
|
|
244
|
+
service: 'widget-site',
|
|
245
|
+
container_port: container,
|
|
246
|
+
service_port: exposed,
|
|
247
|
+
});
|
|
248
|
+
const target = `${NGINX_ROOT}${exports.DEMO_PATH}/index.html`;
|
|
249
|
+
// Keep the separate-port fixture intact; its cross-origin guidance is still true.
|
|
250
|
+
const originalPage = out.files.find(([name]) => name === 'livechat/index.html')?.[1];
|
|
251
|
+
const publicPage = originalPage?.replace(/(<div class="demo">)[\s\S]*?(<\/div>)/u, "$1houston Livechat demo — this storefront shares Rocket.Chat's HTTPS origin. " +
|
|
252
|
+
"Start a chat here, answer it in Rocket.Chat's Omnichannel area. " +
|
|
253
|
+
'Use the separate demo port to test cross-origin CORS and framing.$2');
|
|
254
|
+
if (publicPage !== undefined)
|
|
255
|
+
out.files.push(['livechat/public.html', publicPage]);
|
|
256
|
+
if (kube) {
|
|
257
|
+
const c = containerOf(find(docs, 'Deployment', 'widget-site'));
|
|
258
|
+
const mounts = Array.isArray(c.volumeMounts) ? c.volumeMounts : [];
|
|
259
|
+
const page = mounts.find((m) => m.subPath === 'index.html');
|
|
260
|
+
const files = find(docs, 'ConfigMap', 'widget-site-files');
|
|
261
|
+
if (publicPage !== undefined && files !== undefined)
|
|
262
|
+
files.data = { ...bag(files.data), 'public.html': publicPage };
|
|
263
|
+
if (page !== undefined)
|
|
264
|
+
c.volumeMounts = [
|
|
265
|
+
...mounts,
|
|
266
|
+
{
|
|
267
|
+
...page,
|
|
268
|
+
mountPath: target,
|
|
269
|
+
subPath: publicPage === undefined ? 'index.html' : 'public.html',
|
|
270
|
+
},
|
|
271
|
+
];
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
const svc = bag(out.services['widget-site']);
|
|
275
|
+
const volumes = Array.isArray(svc.volumes) ? svc.volumes : [];
|
|
276
|
+
const page = volumes.find((v) => v.includes(`${NGINX_ROOT}/index.html`));
|
|
277
|
+
if (page !== undefined)
|
|
278
|
+
svc.volumes = [
|
|
279
|
+
...volumes,
|
|
280
|
+
publicPage === undefined
|
|
281
|
+
? page.replace(`${NGINX_ROOT}/index.html`, target)
|
|
282
|
+
: `./livechat/public.html:${target}:ro`,
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
out.notes.push(`Demo page over HTTPS: ${base}${exports.DEMO_PATH}/ (the same origin as Rocket.Chat, so CORS and framing problems will not show there; the port above does)`);
|
|
286
|
+
}
|
|
287
|
+
if (has('keycloak')) {
|
|
288
|
+
const [container, exposed] = ports(pre, 'keycloak', docs, 8080);
|
|
289
|
+
const published = hostPortOf(pre, docs, kube, 'keycloak');
|
|
290
|
+
paths.push({
|
|
291
|
+
preset: 'keycloak',
|
|
292
|
+
path: exports.KEYCLOAK_PATH,
|
|
293
|
+
service: 'keycloak',
|
|
294
|
+
container_port: container,
|
|
295
|
+
service_port: exposed,
|
|
296
|
+
});
|
|
297
|
+
// The browser gets the public URL; houston and Rocket.Chat's server keep reaching it
|
|
298
|
+
// directly, which the dynamic back channel lets Keycloak answer.
|
|
299
|
+
const kc = {
|
|
300
|
+
KC_HTTP_RELATIVE_PATH: exports.KEYCLOAK_PATH,
|
|
301
|
+
KC_HOSTNAME: `${base}${exports.KEYCLOAK_PATH}`,
|
|
302
|
+
KC_HOSTNAME_BACKCHANNEL_DYNAMIC: 'true',
|
|
303
|
+
};
|
|
304
|
+
const realmBase = `${base}${exports.KEYCLOAK_PATH}/realms`;
|
|
305
|
+
if (kube) {
|
|
306
|
+
const c = containerOf(find(docs, 'Deployment', 'keycloak'));
|
|
307
|
+
addEnv(c, kc);
|
|
308
|
+
probePath(c, `${exports.KEYCLOAK_PATH}/realms/master`);
|
|
309
|
+
const cm = find(docs, 'ConfigMap', 'keycloak-realm');
|
|
310
|
+
const data = bag(cm?.data);
|
|
311
|
+
if (typeof data['houston-realm.json'] === 'string') {
|
|
312
|
+
data['houston-realm.json'] = addRedirects(data['houston-realm.json'], base);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
const svc = bag(out.services.keycloak);
|
|
317
|
+
svc.environment = { ...bag(svc.environment), ...kc };
|
|
318
|
+
out.files = out.files.map(([file, text]) => file.endsWith('keycloak-realm.json') ? [file, addRedirects(text, base)] : [file, text]);
|
|
319
|
+
}
|
|
320
|
+
// SAML: the entry point is where the BROWSER is sent.
|
|
321
|
+
for (const key of [
|
|
322
|
+
'OVERWRITE_SETTING_SAML_Custom_Default_entry_point',
|
|
323
|
+
'OVERWRITE_SETTING_SAML_Custom_Default_idp_slo_redirect_url',
|
|
324
|
+
]) {
|
|
325
|
+
if (key in out.env)
|
|
326
|
+
out.env[key] = `${realmBase}/houston/protocol/saml`;
|
|
327
|
+
}
|
|
328
|
+
for (const action of out.postReady) {
|
|
329
|
+
if (action.action === 'saml_idp_cert' && typeof action.descriptor_url === 'string') {
|
|
330
|
+
action.descriptor_url = action.descriptor_url.replace('/realms/', `${exports.KEYCLOAK_PATH}/realms/`);
|
|
331
|
+
}
|
|
332
|
+
if (action.action === 'keycloak_master_ssl_off')
|
|
333
|
+
action.path = exports.KEYCLOAK_PATH;
|
|
334
|
+
// OIDC: the browser authorizes at the public URL; Rocket.Chat's server exchanges the
|
|
335
|
+
// code and reads the user from Keycloak directly (absolute token and identity paths).
|
|
336
|
+
if (action.action === 'create_oauth_provider') {
|
|
337
|
+
const settings = bag(action.settings);
|
|
338
|
+
const backchannel = `http://keycloak:${String(container)}${exports.KEYCLOAK_PATH}/realms/houston`;
|
|
339
|
+
for (const key of Object.keys(settings)) {
|
|
340
|
+
if (key.endsWith('-url'))
|
|
341
|
+
settings[key] = `${realmBase}/houston`;
|
|
342
|
+
if (key.endsWith('-token_path'))
|
|
343
|
+
settings[key] = `${backchannel}/protocol/openid-connect/token`;
|
|
344
|
+
if (key.endsWith('-identity_path'))
|
|
345
|
+
settings[key] = `${backchannel}/protocol/openid-connect/userinfo`;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// The hosts entry and `idp_host` were for a browser reaching Keycloak by port.
|
|
350
|
+
out.notes = dropRuns(out.notes, KEYCLOAK_HOST_NOTES);
|
|
351
|
+
// And the card's: a line sending the browser to Keycloak's port becomes the path.
|
|
352
|
+
const byPort = new RegExp(`http://[A-Za-z0-9.-]+:${String(published)}`, 'u');
|
|
353
|
+
out.guides = out.guides.map((one) => one.signIn.some(([, , where]) => where.startsWith('Keycloak'))
|
|
354
|
+
? {
|
|
355
|
+
...one,
|
|
356
|
+
know: [
|
|
357
|
+
`Keycloak is at ${base}${exports.KEYCLOAK_PATH}, on the workspace's own address: any browser that opens Rocket.Chat reaches it.`,
|
|
358
|
+
...one.know.filter((line) => !byPort.test(line)),
|
|
359
|
+
],
|
|
360
|
+
}
|
|
361
|
+
: one);
|
|
362
|
+
// Every address the notes give for Keycloak (its port, under any idp_host) is the path now.
|
|
363
|
+
out.notes = out.notes.map((note) => note.replace(new RegExp(`http://[A-Za-z0-9.-]+:${String(published)}`, 'gu'), `${base}${exports.KEYCLOAK_PATH}`));
|
|
364
|
+
}
|
|
365
|
+
if (has('minio')) {
|
|
366
|
+
// The console listens on its host port (`s3-minio.ts`: same inside and out), so the one
|
|
367
|
+
// number is both what the nginx proxies to and what it takes over on the host.
|
|
368
|
+
const consolePort = hostPortOf(pre, docs, kube, 'minio', {
|
|
369
|
+
k8sService: 'minio-console',
|
|
370
|
+
index: 1,
|
|
371
|
+
});
|
|
372
|
+
paths.push({
|
|
373
|
+
preset: 's3_minio',
|
|
374
|
+
path: exports.MINIO_PATH,
|
|
375
|
+
service: MINIO_UI,
|
|
376
|
+
container_port: 80,
|
|
377
|
+
service_port: 80,
|
|
378
|
+
});
|
|
379
|
+
const redirect = { MINIO_BROWSER_REDIRECT_URL: `${base}${exports.MINIO_PATH}/` };
|
|
380
|
+
if (kube) {
|
|
381
|
+
addEnv(containerOf(find(docs, 'Deployment', 'minio')), redirect);
|
|
382
|
+
// The console port forwards to the nginx now, which sends / to /minio/: the console's
|
|
383
|
+
// own Service would serve a page whose base it no longer answers.
|
|
384
|
+
const consoleService = find(docs, 'Service', 'minio-console');
|
|
385
|
+
if (consoleService !== undefined)
|
|
386
|
+
delete bag(bag(consoleService.metadata).labels)[UI_PORT_LABEL];
|
|
387
|
+
docs.push((0, common_1.safeLoadAll)((0, common_1.k8sManifests)({
|
|
388
|
+
name: MINIO_UI,
|
|
389
|
+
image: NGINX_IMAGE,
|
|
390
|
+
ports: [[consolePort, 80]],
|
|
391
|
+
ui: { [MINIO_UI]: [consolePort, 80] },
|
|
392
|
+
files: { 'default.conf': minioUiConf(consolePort) },
|
|
393
|
+
mounts: [
|
|
394
|
+
{
|
|
395
|
+
name: 'files',
|
|
396
|
+
mountPath: '/etc/nginx/conf.d/default.conf',
|
|
397
|
+
subPath: 'default.conf',
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
})).map(bag));
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
const svc = bag(out.services.minio);
|
|
404
|
+
svc.environment = { ...bag(svc.environment), ...redirect };
|
|
405
|
+
// The console's port is the nginx's now, which sends / to /minio/, so
|
|
406
|
+
// http://localhost:<console port> keeps opening the console.
|
|
407
|
+
const published = `${String(consolePort)}:${String(consolePort)}`;
|
|
408
|
+
if (Array.isArray(svc.ports))
|
|
409
|
+
svc.ports = svc.ports.filter((p) => p !== published);
|
|
410
|
+
out.services[MINIO_UI] = {
|
|
411
|
+
image: NGINX_IMAGE,
|
|
412
|
+
volumes: [`./s3_minio/${MINIO_UI}.conf:/etc/nginx/conf.d/default.conf:ro`],
|
|
413
|
+
ports: [`${String(consolePort)}:80`],
|
|
414
|
+
depends_on: ['minio'],
|
|
415
|
+
restart: 'unless-stopped',
|
|
416
|
+
};
|
|
417
|
+
out.files = [...out.files, [`s3_minio/${MINIO_UI}.conf`, minioUiConf(consolePort)]];
|
|
418
|
+
}
|
|
419
|
+
// The address that works from anywhere, not only on this machine.
|
|
420
|
+
out.notes = rewrite(out.notes, `http://localhost:${String(consolePort)}`, `${base}${exports.MINIO_PATH}/`);
|
|
421
|
+
if (presignedOf(out))
|
|
422
|
+
out.notes.push(`Note: ${exports.PRESIGNED_OVER_HTTPS}`);
|
|
423
|
+
}
|
|
424
|
+
if (has('phpldapadmin')) {
|
|
425
|
+
// Compose reaches the container's own port; Kubernetes reaches the Service's.
|
|
426
|
+
const [container, exposed] = ports(pre, 'phpldapadmin', docs, 8080);
|
|
427
|
+
const conf = ldapadminUiConf(kube ? exposed : container);
|
|
428
|
+
paths.push({
|
|
429
|
+
preset: 'ldap',
|
|
430
|
+
path: exports.LDAPADMIN_PATH,
|
|
431
|
+
service: LDAPADMIN_UI,
|
|
432
|
+
container_port: 80,
|
|
433
|
+
service_port: 80,
|
|
434
|
+
});
|
|
435
|
+
const port = hostPortOf(pre, docs, kube, 'phpldapadmin');
|
|
436
|
+
if (kube) {
|
|
437
|
+
// The host port forwards to the nginx now, which sends / to /phpldapadmin/.
|
|
438
|
+
const uiService = find(docs, 'Service', 'phpldapadmin');
|
|
439
|
+
if (uiService !== undefined)
|
|
440
|
+
delete bag(bag(uiService.metadata).labels)[UI_PORT_LABEL];
|
|
441
|
+
docs.push((0, common_1.safeLoadAll)((0, common_1.k8sManifests)({
|
|
442
|
+
name: LDAPADMIN_UI,
|
|
443
|
+
image: NGINX_IMAGE,
|
|
444
|
+
ports: [[port, 80]],
|
|
445
|
+
ui: { [LDAPADMIN_UI]: [port, 80] },
|
|
446
|
+
files: { 'default.conf': conf },
|
|
447
|
+
mounts: [
|
|
448
|
+
{
|
|
449
|
+
name: 'files',
|
|
450
|
+
mountPath: '/etc/nginx/conf.d/default.conf',
|
|
451
|
+
subPath: 'default.conf',
|
|
452
|
+
},
|
|
453
|
+
],
|
|
454
|
+
})).map(bag));
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
// Its port is the nginx's now, so http://localhost:<port> keeps opening it.
|
|
458
|
+
const svc = bag(out.services.phpldapadmin);
|
|
459
|
+
delete svc.ports;
|
|
460
|
+
out.services[LDAPADMIN_UI] = {
|
|
461
|
+
image: NGINX_IMAGE,
|
|
462
|
+
volumes: [`./ldap/${LDAPADMIN_UI}.conf:/etc/nginx/conf.d/default.conf:ro`],
|
|
463
|
+
ports: [`${String(port)}:80`],
|
|
464
|
+
depends_on: ['phpldapadmin'],
|
|
465
|
+
restart: 'unless-stopped',
|
|
466
|
+
};
|
|
467
|
+
out.files = [...out.files, [`ldap/${LDAPADMIN_UI}.conf`, conf]];
|
|
468
|
+
}
|
|
469
|
+
out.notes = rewrite(out.notes, `http://localhost:${String(port)}`, `${base}${exports.LDAPADMIN_PATH}/`);
|
|
470
|
+
}
|
|
471
|
+
if (paths.length === 0)
|
|
472
|
+
return pre;
|
|
473
|
+
if (kube)
|
|
474
|
+
out.kubernetesManifests = dumpAll(docs);
|
|
475
|
+
out.extra.public_paths = paths;
|
|
476
|
+
return out;
|
|
477
|
+
}
|
|
478
|
+
/** Whether `pre` serves downloads as presigned MinIO links (s3_minio `presigned=true`). */
|
|
479
|
+
function presignedOf(pre) {
|
|
480
|
+
return pre.env.OVERWRITE_SETTING_FileUpload_S3_Proxy_Uploads === 'false';
|
|
481
|
+
}
|
|
482
|
+
/** The create's warning for presigned links on an https workspace, or ''. */
|
|
483
|
+
function presignedOverHttps(pre) {
|
|
484
|
+
return publicPathsOf(pre.extra).some((p) => p.service === MINIO_UI) && presignedOf(pre)
|
|
485
|
+
? exports.PRESIGNED_OVER_HTTPS
|
|
486
|
+
: '';
|
|
487
|
+
}
|
|
488
|
+
/** The paths a workspace recorded, for the edge or an Ingress; [] for anything else. */
|
|
489
|
+
function publicPathsOf(extra) {
|
|
490
|
+
const raw = extra.public_paths;
|
|
491
|
+
if (!Array.isArray(raw))
|
|
492
|
+
return [];
|
|
493
|
+
return raw.filter((p) => typeof bag(p).path === 'string' &&
|
|
494
|
+
typeof bag(p).service === 'string' &&
|
|
495
|
+
Number.isInteger(bag(p).container_port));
|
|
496
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DYNAMIC_PRESETS = exports.SCENARIOS = exports.REGISTRY = void 0;
|
|
4
|
+
exports.register = register;
|
|
5
|
+
exports.registerScenario = registerScenario;
|
|
6
|
+
exports.builders = builders;
|
|
7
|
+
exports.scenarios = scenarios;
|
|
8
|
+
exports.resetRegistry = resetRegistry;
|
|
9
|
+
exports.REGISTRY = {};
|
|
10
|
+
/**
|
|
11
|
+
* Registered scenario adapters, typed as `unknown`: naming the `Scenario` type here would
|
|
12
|
+
* be a sideways edge between two rank-2 modules.
|
|
13
|
+
*/
|
|
14
|
+
exports.SCENARIOS = {};
|
|
15
|
+
/**
|
|
16
|
+
* The preset names the dynamic modules own.
|
|
17
|
+
*
|
|
18
|
+
* A registry that did the importing would keep module name -> preset name. The names are
|
|
19
|
+
* what the check needs, so the names are what is kept.
|
|
20
|
+
*/
|
|
21
|
+
exports.DYNAMIC_PRESETS = Object.freeze([
|
|
22
|
+
'e2ee',
|
|
23
|
+
'email',
|
|
24
|
+
'ldap',
|
|
25
|
+
'livechat',
|
|
26
|
+
'multi-instance',
|
|
27
|
+
'oidc',
|
|
28
|
+
's3_minio',
|
|
29
|
+
'saml',
|
|
30
|
+
'voice',
|
|
31
|
+
'webhooks',
|
|
32
|
+
]);
|
|
33
|
+
/** Register the builder owned by a dynamic preset module. */
|
|
34
|
+
function register(name, builder) {
|
|
35
|
+
if (name in exports.REGISTRY)
|
|
36
|
+
throw new Error(`preset builder '${name}' is already registered`);
|
|
37
|
+
exports.REGISTRY[name] = builder;
|
|
38
|
+
}
|
|
39
|
+
/** Register the scenario adapter owned by a dynamic preset module. */
|
|
40
|
+
function registerScenario(name, scenario) {
|
|
41
|
+
if (name in exports.SCENARIOS)
|
|
42
|
+
throw new Error(`preset scenario '${name}' is already registered`);
|
|
43
|
+
exports.SCENARIOS[name] = scenario;
|
|
44
|
+
}
|
|
45
|
+
/** Every registered builder, once every owner has registered. */
|
|
46
|
+
function builders() {
|
|
47
|
+
const missing = exports.DYNAMIC_PRESETS.filter((name) => !(name in exports.REGISTRY));
|
|
48
|
+
if (missing.length > 0) {
|
|
49
|
+
throw new Error(`preset modules did not register builders: ${JSON.stringify(missing)}`);
|
|
50
|
+
}
|
|
51
|
+
return { ...exports.REGISTRY };
|
|
52
|
+
}
|
|
53
|
+
/** Scenario adapters, after their owner modules have registered. */
|
|
54
|
+
function scenarios() {
|
|
55
|
+
builders();
|
|
56
|
+
return { ...exports.SCENARIOS };
|
|
57
|
+
}
|
|
58
|
+
/** Undo every registration -- the test seam that stands in for reloading this module. */
|
|
59
|
+
function resetRegistry() {
|
|
60
|
+
for (const key of Object.keys(exports.REGISTRY))
|
|
61
|
+
delete exports.REGISTRY[key];
|
|
62
|
+
for (const key of Object.keys(exports.SCENARIOS))
|
|
63
|
+
delete exports.SCENARIOS[key];
|
|
64
|
+
}
|