@rocket.chat/houston 0.27.0-next.3 → 2.1.9
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 +109 -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 +642 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/loadtest.md +264 -0
- package/data/docs/troubleshooting.md +203 -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 +170 -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 +57 -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 +3694 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +814 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2599 -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 +345 -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 +694 -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 +1549 -0
- package/dist/core/lifecycle/create-k8s.js +960 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +636 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +862 -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 +818 -0
- package/dist/core/lifecycle/request.js +510 -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 +1051 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +976 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1336 -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 +877 -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 +371 -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 +299 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +191 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +236 -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 +70 -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,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = build;
|
|
4
|
+
const format_1 = require("../format");
|
|
5
|
+
const guides_1 = require("./guides");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
const registry_1 = require("./registry");
|
|
8
|
+
const types_1 = require("./types");
|
|
9
|
+
/**
|
|
10
|
+
* S3 bucket naming rules (also keeps the name shell-safe in minio-init).
|
|
11
|
+
*
|
|
12
|
+
* `\n?$` is not decoration: the established rule's `$` matches at the end of the string OR
|
|
13
|
+
* before a single trailing newline, and JavaScript's does not. Reproduced rather than
|
|
14
|
+
* tightened, because this must accept exactly the names that have always been accepted --
|
|
15
|
+
* and the extra character that `$` admits can only be the last one, so it ends the `sh -c`
|
|
16
|
+
* line rather than extending it.
|
|
17
|
+
*/
|
|
18
|
+
const BUCKET_RE = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]\n?$/u;
|
|
19
|
+
/**
|
|
20
|
+
* What MinIO's S3 API listens on when told nothing. Both of its ports are the SAME inside the
|
|
21
|
+
* container and on the host: Rocket.Chat and (presigned) the browser follow one BucketURL, so
|
|
22
|
+
* a workspace given another API port must make MinIO listen there (`serverArgs`).
|
|
23
|
+
*/
|
|
24
|
+
const MINIO_DEFAULT_API_PORT = 9000;
|
|
25
|
+
const USER = 'houston';
|
|
26
|
+
/** MinIO requires >= 8 chars; throwaway repro creds. */
|
|
27
|
+
const PASSWORD = 'houston-secret';
|
|
28
|
+
// MinIO's own images are gone from Docker Hub (docker.io/minio/minio and minio/mc answer
|
|
29
|
+
// 404), so this runs PGSTY's community build of the same MinIO server and mc client: the
|
|
30
|
+
// upstream entrypoint, `/data` volume and arguments, from github.com/pgsty. Pinned
|
|
31
|
+
// multi-arch (amd64/arm64) tags -- verified via docker manifest inspect.
|
|
32
|
+
const MINIO_TAG = 'RELEASE.2026-08-04T00-00-00Z';
|
|
33
|
+
const MC_TAG = 'RELEASE.2026-08-04T00-00-00Z';
|
|
34
|
+
/**
|
|
35
|
+
* The Kubernetes twin of the compose `minio-init` service.
|
|
36
|
+
*
|
|
37
|
+
* It had no twin, and nothing said so. On Compose a one-shot container waits for MinIO
|
|
38
|
+
* and runs `mc mb -p`; the Kubernetes adapter rendered only the MinIO Deployment, so the
|
|
39
|
+
* bucket was NEVER created -- while the workspace's own notes said "bucket '<name>' is
|
|
40
|
+
* created automatically; watch uploads land in it". MinIO does not create buckets on
|
|
41
|
+
* demand and neither does Rocket.Chat, so every upload on that runtime had nowhere to go.
|
|
42
|
+
*
|
|
43
|
+
* A Job rather than an init container: an init container runs BEFORE its pod's main
|
|
44
|
+
* container, so it would wait for a MinIO that cannot start until it finishes. Same
|
|
45
|
+
* image, same idempotent `mc mb -p`, same wait loop as Compose.
|
|
46
|
+
*/
|
|
47
|
+
function bucketJob(bucket, s3Port, workspace = '__HOUSTON_NAME__') {
|
|
48
|
+
const app = 'houston-minio-init';
|
|
49
|
+
const labels = {
|
|
50
|
+
app,
|
|
51
|
+
'app.kubernetes.io/managed-by': 'houston',
|
|
52
|
+
'houston.io/component': 'minio-init',
|
|
53
|
+
'houston.io/repro': workspace,
|
|
54
|
+
};
|
|
55
|
+
return (0, common_1.safeDump)({
|
|
56
|
+
apiVersion: 'batch/v1',
|
|
57
|
+
kind: 'Job',
|
|
58
|
+
metadata: { name: 'minio-init', labels },
|
|
59
|
+
spec: {
|
|
60
|
+
// Retries rather than one attempt: the Job is applied at the same time as the
|
|
61
|
+
// Deployment, so its first run legitimately races MinIO starting.
|
|
62
|
+
backoffLimit: 10,
|
|
63
|
+
template: {
|
|
64
|
+
metadata: { labels },
|
|
65
|
+
spec: {
|
|
66
|
+
restartPolicy: 'OnFailure',
|
|
67
|
+
containers: [
|
|
68
|
+
{
|
|
69
|
+
name: 'minio-init',
|
|
70
|
+
image: `docker.io/pgsty/mc:${MC_TAG}`,
|
|
71
|
+
command: [
|
|
72
|
+
'sh',
|
|
73
|
+
'-c',
|
|
74
|
+
`until mc alias set local http://minio:${String(s3Port)} ` +
|
|
75
|
+
`${USER} ${PASSWORD}; do sleep 2; done; ` +
|
|
76
|
+
`mc mb -p local/${bucket}`,
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** What a presigned-URL setup needs the reader to know, and the proxy it wants. */
|
|
86
|
+
function presignedNotes(bucket, presigned, s3Host, [s3Port, consolePort]) {
|
|
87
|
+
const notes = [
|
|
88
|
+
`MinIO console: http://localhost:${String(consolePort)} (${USER} / ${PASSWORD})`,
|
|
89
|
+
` — bucket '${bucket}' is created automatically; watch uploads land in it.`,
|
|
90
|
+
'Upload any file/image in RC; it goes to MinIO instead of GridFS.',
|
|
91
|
+
];
|
|
92
|
+
if (presigned && s3Host === 'minio') {
|
|
93
|
+
notes.push('PRESIGNED MODE: the browser fetches files straight from MinIO, so add', 'this line to /etc/hosts (needs sudo):', ' 127.0.0.1 minio', ' That entry works only for a browser on the machine running houston. From', ' another computer, re-create with: --bind 0.0.0.0 --set s3_host=<this host>', "Remove the line to reproduce the classic 'presigned URL unreachable'", 'ticket symptom (uploads work, previews/downloads break).');
|
|
94
|
+
}
|
|
95
|
+
else if (presigned) {
|
|
96
|
+
notes.push('PRESIGNED MODE: the browser fetches files straight from ' +
|
|
97
|
+
`http://${s3Host}:${String(s3Port)}, so no hosts entry is needed — but that`, ' address must be reachable from the browser (`--bind 0.0.0.0`).', "Point s3_host somewhere unreachable to reproduce the classic 'presigned", " URL unreachable' ticket symptom (uploads work, previews break).");
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
notes.push('Downloads are proxied through RC (no hosts entry needed). For real', 'presigned-URL behaviour: --set presigned=true (reproduces that ticket class).');
|
|
101
|
+
}
|
|
102
|
+
return notes;
|
|
103
|
+
}
|
|
104
|
+
/** Every Rocket.Chat setting that points file uploads at this bucket. */
|
|
105
|
+
function s3Settings(bucket, presigned, s3Host, s3Port) {
|
|
106
|
+
return {
|
|
107
|
+
OVERWRITE_SETTING_FileUpload_Storage_Type: 'AmazonS3',
|
|
108
|
+
OVERWRITE_SETTING_FileUpload_S3_Bucket: bucket,
|
|
109
|
+
// The ENDPOINT, with no bucket on it, even though docs.rocket.chat/docs/minio spells
|
|
110
|
+
// the format as `http://[your.minio.domain/bucketname]`. Bucket is already passed
|
|
111
|
+
// separately, and with ForcePathStyle the client builds {endpoint}/{bucket}/{key} --
|
|
112
|
+
// so a bucket in the endpoint is repeated as a key prefix. Measured on 7.13.6 by
|
|
113
|
+
// uploading a file and reading MinIO's own layout:
|
|
114
|
+
//
|
|
115
|
+
// with the bucket -> houston-uploads/houston-uploads/<instance>/uploads/...
|
|
116
|
+
// without it -> houston-uploads/<instance>/uploads/...
|
|
117
|
+
//
|
|
118
|
+
// Both upload successfully -- MinIO is happy to treat it as a prefix -- which is why
|
|
119
|
+
// this went unnoticed. It is still every object nested one level deeper than it
|
|
120
|
+
// should be, under a directory named after its own bucket.
|
|
121
|
+
OVERWRITE_SETTING_FileUpload_S3_BucketURL: `http://${s3Host}:${String(s3Port)}`,
|
|
122
|
+
OVERWRITE_SETTING_FileUpload_S3_AWSAccessKeyId: USER,
|
|
123
|
+
OVERWRITE_SETTING_FileUpload_S3_AWSSecretAccessKey: PASSWORD,
|
|
124
|
+
OVERWRITE_SETTING_FileUpload_S3_Region: 'us-east-1', // MinIO default
|
|
125
|
+
OVERWRITE_SETTING_FileUpload_S3_ForcePathStyle: 'true', // mandatory for MinIO
|
|
126
|
+
// v2, which is what docs.rocket.chat/docs/minio prescribes -- and NOT a cosmetic
|
|
127
|
+
// choice. RC 7.13.x bundles aws-sdk v2 (there is no @aws-sdk directory in the image
|
|
128
|
+
// at all), which honours this setting; asking it for v4 makes the very first
|
|
129
|
+
// upload-store call raise
|
|
130
|
+
//
|
|
131
|
+
// Non-file stream objects are not supported with SigV4
|
|
132
|
+
//
|
|
133
|
+
// during startup, and Rocket.Chat then never finishes booting. Measured on 7.13.6 +
|
|
134
|
+
// s3_minio: with v4 it never served in 300s and /api/info refused the connection;
|
|
135
|
+
// with v2 it answered 200 in ~35s and the error was gone.
|
|
136
|
+
//
|
|
137
|
+
// Newer releases moved to @aws-sdk/client-s3, which always signs SigV4 and ignores
|
|
138
|
+
// this setting -- so v2 is correct on old images and inert on new ones, which is why
|
|
139
|
+
// 8.5.1 never showed the fault.
|
|
140
|
+
OVERWRITE_SETTING_FileUpload_S3_SignatureVersion: 'v2',
|
|
141
|
+
// Default: stream files through RC so the browser never needs to reach MinIO.
|
|
142
|
+
// Presigned mode: real presigned URLs (the faithful flow).
|
|
143
|
+
OVERWRITE_SETTING_FileUpload_S3_Proxy_Uploads: presigned ? 'false' : 'true',
|
|
144
|
+
OVERWRITE_SETTING_FileUpload_S3_Proxy_Avatars: presigned ? 'false' : 'true',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* `minio server`'s arguments: the console on its port, and the S3 API on its own only when that
|
|
149
|
+
* is not MinIO's default, so a workspace on the preferred ports runs the command it always did.
|
|
150
|
+
*/
|
|
151
|
+
function serverArgs(s3Port, consolePort) {
|
|
152
|
+
return [
|
|
153
|
+
'server',
|
|
154
|
+
'/data',
|
|
155
|
+
'--console-address',
|
|
156
|
+
`:${String(consolePort)}`,
|
|
157
|
+
...(s3Port === MINIO_DEFAULT_API_PORT ? [] : ['--address', `:${String(s3Port)}`]),
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
/** The same MinIO as native Kubernetes resources. */
|
|
161
|
+
function minioManifests(s3Port, consolePort) {
|
|
162
|
+
return (0, common_1.k8sManifests)({
|
|
163
|
+
name: 'minio',
|
|
164
|
+
image: `docker.io/pgsty/minio:${MINIO_TAG}`,
|
|
165
|
+
ports: [
|
|
166
|
+
[s3Port, s3Port],
|
|
167
|
+
[consolePort, consolePort],
|
|
168
|
+
],
|
|
169
|
+
env: { MINIO_ROOT_USER: USER, MINIO_ROOT_PASSWORD: PASSWORD },
|
|
170
|
+
args: serverArgs(s3Port, consolePort),
|
|
171
|
+
// The bucket is a directory in here, so keeping /data keeps it too: the one-shot
|
|
172
|
+
// `minio-init` Job never runs again, and nothing else would recreate it.
|
|
173
|
+
data: { path: '/data', size: '2Gi' },
|
|
174
|
+
// TWO Services, one Deployment: MinIO serves the S3 API and the console from the same
|
|
175
|
+
// process, and a Kubernetes label value cannot contain a comma -- so each Service
|
|
176
|
+
// names the workload through `houston.io/ui-deployment` instead of carrying a list of
|
|
177
|
+
// ports it is not allowed to spell.
|
|
178
|
+
readiness: {
|
|
179
|
+
httpGet: { path: '/minio/health/ready', port: s3Port },
|
|
180
|
+
initialDelaySeconds: 3,
|
|
181
|
+
periodSeconds: 3,
|
|
182
|
+
failureThreshold: 40,
|
|
183
|
+
},
|
|
184
|
+
ui: {
|
|
185
|
+
minio: [s3Port, s3Port],
|
|
186
|
+
'minio-console': [consolePort, consolePort],
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/** MinIO and its console, as compose services. */
|
|
191
|
+
function minioServices(bucket, s3Port, consolePort) {
|
|
192
|
+
return {
|
|
193
|
+
minio: {
|
|
194
|
+
image: `docker.io/pgsty/minio:${MINIO_TAG}`,
|
|
195
|
+
restart: 'unless-stopped',
|
|
196
|
+
command: serverArgs(s3Port, consolePort),
|
|
197
|
+
environment: {
|
|
198
|
+
MINIO_ROOT_USER: USER,
|
|
199
|
+
MINIO_ROOT_PASSWORD: PASSWORD,
|
|
200
|
+
},
|
|
201
|
+
volumes: ['minio_data:/data'],
|
|
202
|
+
ports: [
|
|
203
|
+
`${String(s3Port)}:${String(s3Port)}`,
|
|
204
|
+
`${String(consolePort)}:${String(consolePort)}`,
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
// One-shot: wait for MinIO to accept connections, then create the bucket. `mc mb -p`
|
|
208
|
+
// is idempotent (no error if it already exists), so BOTH steps retry: on rootless
|
|
209
|
+
// Podman the bucket step itself met a DNS flap ("lookup minio: i/o timeout") and the
|
|
210
|
+
// container exited for good with no bucket.
|
|
211
|
+
'minio-init': {
|
|
212
|
+
image: `docker.io/pgsty/mc:${MC_TAG}`,
|
|
213
|
+
restart: 'no',
|
|
214
|
+
depends_on: ['minio'],
|
|
215
|
+
entrypoint: [
|
|
216
|
+
'sh',
|
|
217
|
+
'-c',
|
|
218
|
+
`until mc alias set local http://minio:${String(s3Port)} ${USER} ${PASSWORD} && ` +
|
|
219
|
+
`mc mb -p local/${bucket}; do sleep 1; done`,
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function build(params, ports) {
|
|
225
|
+
const presigned = (0, common_1.truthyParam)(params, 'presigned');
|
|
226
|
+
const s3Port = (0, common_1.presetPort)('s3_minio', 0, ports);
|
|
227
|
+
const consolePort = (0, common_1.presetPort)('s3_minio', 1, ports);
|
|
228
|
+
// THE BROWSER'S ADDRESS FOR MINIO, in presigned mode only. A presigned URL is followed
|
|
229
|
+
// by the browser, and `minio` resolves for it solely through the `127.0.0.1 minio` hosts
|
|
230
|
+
// line below -- which names whichever machine the browser is on. Right on a laptop;
|
|
231
|
+
// wrong on the shared install this tool now runs on, where the same silent shape broke
|
|
232
|
+
// the saml and oidc buttons. Setting this to the host's own address satisfies the
|
|
233
|
+
// browser AND RC (which reaches it over the bridge) and needs no hosts entry, exactly as
|
|
234
|
+
// `idp_host` does for the IdP presets.
|
|
235
|
+
//
|
|
236
|
+
// Proxy mode is unaffected: there the browser never touches MinIO at all, which is why
|
|
237
|
+
// this default stays `minio` and nothing about the ordinary case changes.
|
|
238
|
+
const s3Host = (0, common_1.strParam)(params, 's3_host', 'minio');
|
|
239
|
+
const bucket = (0, common_1.strParam)(params, 'bucket', 'houston-uploads');
|
|
240
|
+
if (!BUCKET_RE.test(bucket)) {
|
|
241
|
+
throw new Error(`--set bucket=${(0, format_1.shownValue)(bucket)} is not a valid S3 bucket name ` +
|
|
242
|
+
'(3-63 chars: lowercase letters, digits, dots, hyphens)');
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
...(0, types_1.emptyPreset)('s3_minio'),
|
|
246
|
+
description: "MinIO S3-compatible storage wired as RC's file upload backend " +
|
|
247
|
+
`(bucket '${bucket}', console :${String(consolePort)}). Default proxies ` +
|
|
248
|
+
'downloads through RC; turn on Presigned URLs (--set presigned=true) for real ones.',
|
|
249
|
+
env: s3Settings(bucket, presigned, s3Host, s3Port),
|
|
250
|
+
services: minioServices(bucket, s3Port, consolePort),
|
|
251
|
+
dependsOn: ['minio'],
|
|
252
|
+
requiresLicense: false,
|
|
253
|
+
source: 'built-in (dynamic)',
|
|
254
|
+
paramsHelp: {
|
|
255
|
+
presigned: 'browser fetches presigned MinIO URLs (default false; needs /etc/hosts line)',
|
|
256
|
+
bucket: 'bucket name (default houston-uploads)',
|
|
257
|
+
s3_host: 'hostname the BROWSER reaches MinIO on in presigned mode ' +
|
|
258
|
+
"(default 'minio', which needs a hosts entry and only works " +
|
|
259
|
+
'for a browser on the machine running houston)',
|
|
260
|
+
},
|
|
261
|
+
volumes: { minio_data: { driver: 'local' } },
|
|
262
|
+
ports: [s3Port, consolePort],
|
|
263
|
+
// Both: the Deployment/Services for MinIO, and the Job that creates the bucket.
|
|
264
|
+
// Without the second, `up` succeeded, MinIO ran, and every upload had nowhere to land
|
|
265
|
+
// -- see `bucketJob`.
|
|
266
|
+
kubernetesManifests: [minioManifests(s3Port, consolePort), bucketJob(bucket, s3Port)],
|
|
267
|
+
notes: presignedNotes(bucket, presigned, s3Host, [s3Port, consolePort]),
|
|
268
|
+
guides: [
|
|
269
|
+
(0, guides_1.guide)('s3_minio', {
|
|
270
|
+
summary: `MinIO as the file upload store, bucket '${bucket}'${presigned ? ', presigned URLs' : ''}.`,
|
|
271
|
+
setup: presigned && s3Host === 'minio'
|
|
272
|
+
? {
|
|
273
|
+
why: 'In presigned mode the browser fetches files straight from MinIO, so it needs this line in /etc/hosts (needs sudo).',
|
|
274
|
+
line: '127.0.0.1 minio',
|
|
275
|
+
}
|
|
276
|
+
: null,
|
|
277
|
+
signIn: [[USER, PASSWORD, 'MinIO console']],
|
|
278
|
+
steps: [
|
|
279
|
+
'Upload any file or image in Rocket.Chat; it lands in MinIO, not GridFS.',
|
|
280
|
+
`Watch it arrive in the bucket '${bucket}' in the MinIO console.`,
|
|
281
|
+
],
|
|
282
|
+
know: presigned && s3Host === 'minio'
|
|
283
|
+
? [
|
|
284
|
+
'The hosts entry works only for a browser on the machine running houston; from another computer re-create with --bind 0.0.0.0 --set s3_host=<this host>.',
|
|
285
|
+
"Remove the hosts line to reproduce the classic 'presigned URL unreachable' symptom: uploads work, previews and downloads break.",
|
|
286
|
+
]
|
|
287
|
+
: presigned
|
|
288
|
+
? [
|
|
289
|
+
`The browser fetches files straight from http://${s3Host}:${String(s3Port)}, which must be reachable from it (--bind 0.0.0.0).`,
|
|
290
|
+
"Point s3_host somewhere unreachable to reproduce the classic 'presigned URL unreachable' symptom: uploads work, previews break.",
|
|
291
|
+
]
|
|
292
|
+
: [
|
|
293
|
+
'Downloads are proxied through Rocket.Chat; no hosts entry needed.',
|
|
294
|
+
'For real presigned-URL behaviour, re-create it with Presigned URLs on (--set presigned=true).',
|
|
295
|
+
],
|
|
296
|
+
}),
|
|
297
|
+
],
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
(0, registry_1.register)('s3_minio', build);
|
|
@@ -0,0 +1,149 @@
|
|
|
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.build = build;
|
|
37
|
+
const guides_1 = require("./guides");
|
|
38
|
+
const common_1 = require("./common");
|
|
39
|
+
const keycloak = __importStar(require("./keycloak"));
|
|
40
|
+
const registry_1 = require("./registry");
|
|
41
|
+
const types_1 = require("./types");
|
|
42
|
+
const KC_REALM = keycloak.REALM;
|
|
43
|
+
/** Package the shared IdP rendering with SAML-specific setup and guidance. */
|
|
44
|
+
function samlPreset(users, idpHost, descriptor, services, env, prefix, kcPort) {
|
|
45
|
+
const realm = keycloak.realmJson([keycloak.samlClient()], users, prefix);
|
|
46
|
+
return {
|
|
47
|
+
...(0, types_1.emptyPreset)('saml'),
|
|
48
|
+
description: `Keycloak IdP with a generated SAML realm (${String(users)} users ${prefix}user1..${prefix}user` +
|
|
49
|
+
`${String(users)}, password=username). Click 'Keycloak SSO', log in as ` +
|
|
50
|
+
`${prefix}user1/${prefix}user1. Keycloak admin at http://${idpHost}:${String(kcPort)} ` +
|
|
51
|
+
"(admin/admin, realm 'houston').",
|
|
52
|
+
env,
|
|
53
|
+
softEnv: [common_1.EMAIL_2FA],
|
|
54
|
+
services,
|
|
55
|
+
dependsOn: ['keycloak'],
|
|
56
|
+
requiresLicense: false,
|
|
57
|
+
source: 'built-in (dynamic)',
|
|
58
|
+
files: [['saml/keycloak-realm.json', realm]],
|
|
59
|
+
kubernetesManifests: [keycloak.manifests(realm, kcPort)],
|
|
60
|
+
paramsHelp: {
|
|
61
|
+
users: 'number of Keycloak test users (default 5)',
|
|
62
|
+
idp_host: 'hostname YOUR BROWSER reaches Keycloak on (default localhost: a browser on the ' +
|
|
63
|
+
'machine running houston only; from another computer create the workspace with ' +
|
|
64
|
+
'HTTPS on a domain instead, and Keycloak is at <workspace URL>/keycloak)',
|
|
65
|
+
},
|
|
66
|
+
ports: [kcPort],
|
|
67
|
+
guides: [
|
|
68
|
+
(0, guides_1.guide)('saml', {
|
|
69
|
+
summary: `Keycloak as a SAML identity provider with ${String(users)} users.`,
|
|
70
|
+
signIn: [
|
|
71
|
+
[
|
|
72
|
+
`${prefix}user1 … ${prefix}user${String(users)}`,
|
|
73
|
+
'same as the name',
|
|
74
|
+
"press 'Keycloak SSO' on the login page",
|
|
75
|
+
],
|
|
76
|
+
['admin', 'admin', `Keycloak admin console, realm '${KC_REALM}' (not master)`],
|
|
77
|
+
],
|
|
78
|
+
steps: [
|
|
79
|
+
"On the login page press 'Keycloak SSO': your browser is sent to Keycloak.",
|
|
80
|
+
`Sign in as ${prefix}user1 / ${prefix}user1.`,
|
|
81
|
+
],
|
|
82
|
+
know: [
|
|
83
|
+
`SAML sends your browser to http://${idpHost}:${String(kcPort)}: that address must resolve and be reachable from wherever the browser runs.`,
|
|
84
|
+
idpHost === 'localhost'
|
|
85
|
+
? `It is localhost, so the browser must be on the machine running houston. ${keycloak.FROM_ANOTHER_COMPUTER}`
|
|
86
|
+
: '',
|
|
87
|
+
`In the Keycloak console switch the realm (top left) to '${KC_REALM}': the users are not in master. The 'temporary admin' banner there is normal in dev mode.`,
|
|
88
|
+
],
|
|
89
|
+
}),
|
|
90
|
+
],
|
|
91
|
+
notes: [
|
|
92
|
+
`SAML sends your BROWSER to http://${idpHost}:${String(kcPort)} — that address has`,
|
|
93
|
+
' to resolve and be reachable from wherever the browser is running.',
|
|
94
|
+
...(idpHost !== 'localhost'
|
|
95
|
+
? []
|
|
96
|
+
: [
|
|
97
|
+
" It is 'localhost', so the browser must be on the machine running houston.",
|
|
98
|
+
keycloak.FROM_ANOTHER_COMPUTER,
|
|
99
|
+
' (Keycloak refuses a request that arrives on any other name.)',
|
|
100
|
+
]),
|
|
101
|
+
`Keycloak admin console: http://${idpHost}:${String(kcPort)} (admin / admin)`,
|
|
102
|
+
` Your SAML users live in the '${KC_REALM}' realm, NOT 'master' (the`,
|
|
103
|
+
' default view). Switch the realm dropdown (top-left) to ' +
|
|
104
|
+
`'${KC_REALM}', or open Users directly:`,
|
|
105
|
+
` http://${idpHost}:${String(kcPort)}/admin/master/console/#/${KC_REALM}/users`,
|
|
106
|
+
" ('temporary admin' banner on master is normal Keycloak dev mode — ignore it)",
|
|
107
|
+
],
|
|
108
|
+
postReady: [
|
|
109
|
+
{
|
|
110
|
+
action: 'saml_idp_cert',
|
|
111
|
+
descriptor_url: descriptor,
|
|
112
|
+
setting: 'SAML_Custom_Default_cert',
|
|
113
|
+
enable_setting: 'SAML_Custom_Default',
|
|
114
|
+
},
|
|
115
|
+
{ action: 'keycloak_master_ssl_off', service: 'keycloak' },
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function build(params, ports) {
|
|
120
|
+
const users = (0, common_1.intParam)(params, 'users', 5);
|
|
121
|
+
const kcPort = (0, common_1.presetPort)('saml', 0, ports);
|
|
122
|
+
// THE BROWSER'S ADDRESS FOR THE IdP, not houston's. `entry_point` is the URL the user's
|
|
123
|
+
// browser is redirected to, and it was hardcoded to `localhost` -- which names the
|
|
124
|
+
// browser's OWN machine. On a shared box (the deployment this tool now supports: one
|
|
125
|
+
// `serve` on an EC2 instance, several engineers using the GUI) the SAML button
|
|
126
|
+
// therefore sent every one of them to port 8081 on their own laptop, and the browser
|
|
127
|
+
// bounced straight back to the login page having reached nothing.
|
|
128
|
+
//
|
|
129
|
+
// Keycloak makes the mismatch unforgiving in the other direction too: it checks the
|
|
130
|
+
// AuthnRequest's `Destination` against the URL the request actually arrived on, so
|
|
131
|
+
// reaching the IdP as anything other than what `entry_point` says is refused with
|
|
132
|
+
// `error="invalid_authn_request" reason="invalid_destination"` -- measured on this box
|
|
133
|
+
// by changing nothing but the hostname. The two must agree, which is why this is one
|
|
134
|
+
// knob and not a guess.
|
|
135
|
+
const idpHost = (0, common_1.strParam)(params, 'idp_host', 'localhost');
|
|
136
|
+
const samlEp = `http://${idpHost}:${String(kcPort)}/realms/${KC_REALM}/protocol/saml`;
|
|
137
|
+
// FETCHED BY houston, so it stays on loopback whatever the browser uses. Same split as
|
|
138
|
+
// root_url/public_url elsewhere in this codebase: an internal caller and a browser do
|
|
139
|
+
// not need the same address, and giving the internal one the public address is how
|
|
140
|
+
// `--set idp_host=<public name>` would break its own cert fetch on a workspace bound to
|
|
141
|
+
// 127.0.0.1.
|
|
142
|
+
const descriptor = `http://localhost:${String(kcPort)}/realms/${KC_REALM}/protocol/saml/descriptor`;
|
|
143
|
+
const services = {
|
|
144
|
+
keycloak: keycloak.service('./saml/keycloak-realm.json', kcPort),
|
|
145
|
+
};
|
|
146
|
+
const prefix = (0, common_1.strParam)(params, keycloak.USER_PREFIX_PARAM, '');
|
|
147
|
+
return samlPreset(users, idpHost, descriptor, services, keycloak.samlSettings(samlEp), prefix, kcPort);
|
|
148
|
+
}
|
|
149
|
+
(0, registry_1.register)('saml', build);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scenario = void 0;
|
|
4
|
+
exports.canonicalParams = canonicalParams;
|
|
5
|
+
/**
|
|
6
|
+
* `params` with each alias key moved to the key it stands for. Both spellings of one option in
|
|
7
|
+
* one request is a refusal, never a silent winner.
|
|
8
|
+
*/
|
|
9
|
+
function canonicalParams(params, aliases) {
|
|
10
|
+
const out = { ...params };
|
|
11
|
+
for (const [old, now] of Object.entries(aliases)) {
|
|
12
|
+
if (!Object.hasOwn(out, old))
|
|
13
|
+
continue;
|
|
14
|
+
if (Object.hasOwn(out, now)) {
|
|
15
|
+
throw new Error(`--set ${old} is the earlier spelling of ${now}; give one of them`);
|
|
16
|
+
}
|
|
17
|
+
out[now] = out[old];
|
|
18
|
+
delete out[old];
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
/** One built-in scenario and its small deployment-specific adapters. */
|
|
23
|
+
class Scenario {
|
|
24
|
+
constructor(spec) {
|
|
25
|
+
this.name = spec.name;
|
|
26
|
+
this.paramsHelp = spec.paramsHelp;
|
|
27
|
+
this.paramAliases = spec.paramAliases ?? {};
|
|
28
|
+
this.resolveIntent = spec.resolveIntent;
|
|
29
|
+
this.adapters = spec.adapters;
|
|
30
|
+
}
|
|
31
|
+
/** `ports`: the workspace's side ports, sparse; `{}` is every preferred one. */
|
|
32
|
+
resolve(params, deploymentType, ports = {}) {
|
|
33
|
+
const given = canonicalParams(params ?? {}, this.paramAliases);
|
|
34
|
+
const known = new Set(Object.keys(this.paramsHelp));
|
|
35
|
+
const unknown = Object.keys(given)
|
|
36
|
+
.filter((key) => !known.has(key))
|
|
37
|
+
.sort();
|
|
38
|
+
if (unknown.length > 0) {
|
|
39
|
+
const valid = Object.keys(this.paramsHelp).sort().join(', ') || '(this preset takes no --set params)';
|
|
40
|
+
throw new Error(`unknown --set param(s) for preset '${this.name}': ${unknown.join(', ')} - valid: ${valid}`);
|
|
41
|
+
}
|
|
42
|
+
const adapter = this.adapters[deploymentType];
|
|
43
|
+
if (adapter === undefined) {
|
|
44
|
+
const supported = Object.keys(this.adapters).sort().join(', ') || 'none';
|
|
45
|
+
throw new Error(`preset '${this.name}' does not support deployment type ` +
|
|
46
|
+
`'${deploymentType}'; supported: ${supported}`);
|
|
47
|
+
}
|
|
48
|
+
return { ...adapter(this.resolveIntent(given), ports), paramAliases: { ...this.paramAliases } };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Scenario = Scenario;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emptyPreset = emptyPreset;
|
|
4
|
+
exports.presetFromJSON = presetFromJSON;
|
|
5
|
+
/** The established defaults, in the established order. */
|
|
6
|
+
function emptyPreset(name) {
|
|
7
|
+
return {
|
|
8
|
+
name,
|
|
9
|
+
description: '',
|
|
10
|
+
env: {},
|
|
11
|
+
services: {},
|
|
12
|
+
rocketchat: {},
|
|
13
|
+
dependsOn: [],
|
|
14
|
+
requiresLicense: false,
|
|
15
|
+
source: 'built-in',
|
|
16
|
+
files: [],
|
|
17
|
+
paramsHelp: {},
|
|
18
|
+
paramAliases: {},
|
|
19
|
+
guides: [],
|
|
20
|
+
postReady: [],
|
|
21
|
+
notes: [],
|
|
22
|
+
instances: 1,
|
|
23
|
+
entryService: '',
|
|
24
|
+
extra: {},
|
|
25
|
+
volumes: {},
|
|
26
|
+
ports: [],
|
|
27
|
+
topology: '',
|
|
28
|
+
scenario: '',
|
|
29
|
+
scenarioParams: {},
|
|
30
|
+
kubernetesManifests: [],
|
|
31
|
+
error: '',
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function obj(value) {
|
|
35
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
36
|
+
? value
|
|
37
|
+
: {};
|
|
38
|
+
}
|
|
39
|
+
function strMap(value) {
|
|
40
|
+
const out = {};
|
|
41
|
+
for (const [key, item] of Object.entries(obj(value)))
|
|
42
|
+
out[key] = String(item);
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
function list(value) {
|
|
46
|
+
return Array.isArray(value) ? value : [];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A `Preset` from the snake_case document of the established serialisation.
|
|
50
|
+
*
|
|
51
|
+
* Every field is defaulted rather than trusted, exactly as the preset parser does, so a
|
|
52
|
+
* catalogue row missing a key produces the documented default instead of `undefined`
|
|
53
|
+
* reaching the compose document.
|
|
54
|
+
*/
|
|
55
|
+
function presetFromJSON(raw) {
|
|
56
|
+
const base = emptyPreset(String(raw.name ?? ''));
|
|
57
|
+
return {
|
|
58
|
+
...base,
|
|
59
|
+
description: String(raw.description ?? ''),
|
|
60
|
+
env: strMap(raw.env),
|
|
61
|
+
services: obj(raw.services),
|
|
62
|
+
rocketchat: obj(raw.rocketchat),
|
|
63
|
+
dependsOn: list(raw.depends_on).map(String),
|
|
64
|
+
requiresLicense: Boolean(raw.requires_license),
|
|
65
|
+
source: String(raw.source ?? 'built-in'),
|
|
66
|
+
files: list(raw.files).map((row) => {
|
|
67
|
+
const pair = list(row);
|
|
68
|
+
return [String(pair[0] ?? ''), String(pair[1] ?? '')];
|
|
69
|
+
}),
|
|
70
|
+
paramsHelp: strMap(raw.params_help),
|
|
71
|
+
paramAliases: {},
|
|
72
|
+
guides: [],
|
|
73
|
+
postReady: list(raw.post_ready).map(obj),
|
|
74
|
+
notes: list(raw.notes).map(String),
|
|
75
|
+
instances: Number(raw.instances ?? 1) || 1,
|
|
76
|
+
entryService: String(raw.entry_service ?? ''),
|
|
77
|
+
extra: obj(raw.extra),
|
|
78
|
+
volumes: obj(raw.volumes),
|
|
79
|
+
ports: list(raw.ports).map(Number),
|
|
80
|
+
topology: String(raw.topology ?? ''),
|
|
81
|
+
scenario: String(raw.scenario ?? ''),
|
|
82
|
+
scenarioParams: obj(raw.scenario_params),
|
|
83
|
+
kubernetesManifests: list(raw.kubernetes_manifests).map(String),
|
|
84
|
+
error: String(raw.error ?? ''),
|
|
85
|
+
};
|
|
86
|
+
}
|