@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,550 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Workspace inspection and lifecycle operations. */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.register = register;
|
|
38
|
+
const node_perf_hooks_1 = require("node:perf_hooks");
|
|
39
|
+
const audit = __importStar(require("../../core/audit"));
|
|
40
|
+
const admin_1 = require("../../core/lifecycle/admin");
|
|
41
|
+
const create_docker_1 = require("../../core/lifecycle/create-docker");
|
|
42
|
+
const destroy_1 = require("../../core/lifecycle/destroy");
|
|
43
|
+
const inspect_1 = require("../../core/lifecycle/inspect");
|
|
44
|
+
const naming_1 = require("../../core/lifecycle/naming");
|
|
45
|
+
const ownership_1 = require("../../core/lifecycle/ownership");
|
|
46
|
+
const payload_1 = require("../../core/lifecycle/payload");
|
|
47
|
+
const preconditions_1 = require("../../core/lifecycle/preconditions");
|
|
48
|
+
const pruning_1 = require("../../core/lifecycle/pruning");
|
|
49
|
+
const ready_1 = require("../../core/lifecycle/ready");
|
|
50
|
+
const state_1 = require("../../core/lifecycle/state");
|
|
51
|
+
const types_1 = require("../../core/lifecycle/types");
|
|
52
|
+
const monitor = __importStar(require("../../core/monitor"));
|
|
53
|
+
const engine_1 = require("../../core/runner/engine");
|
|
54
|
+
const locks_1 = require("../../core/runner/locks");
|
|
55
|
+
const queries_1 = require("../../core/runner/queries");
|
|
56
|
+
const record_1 = require("../../core/runner/record");
|
|
57
|
+
const topology = __importStar(require("../../core/topology"));
|
|
58
|
+
const users_1 = require("../../core/users");
|
|
59
|
+
const config = __importStar(require("../../lib/config"));
|
|
60
|
+
const errors_1 = require("../../lib/errors");
|
|
61
|
+
const home_1 = require("../../lib/home");
|
|
62
|
+
const format_1 = require("../../lib/format");
|
|
63
|
+
const presets_1 = require("../../lib/presets");
|
|
64
|
+
const redact_1 = require("../../lib/redact");
|
|
65
|
+
const versions_1 = require("../../lib/versions");
|
|
66
|
+
const composite_1 = require("../../lib/presets/composite");
|
|
67
|
+
const voice_pbx_1 = require("../../lib/presets/voice-pbx");
|
|
68
|
+
const route_deps_1 = require("../route-deps");
|
|
69
|
+
const jobs_1 = require("../jobs");
|
|
70
|
+
function envvarsModule() {
|
|
71
|
+
return require('../../core/envvars');
|
|
72
|
+
}
|
|
73
|
+
function kubeModules() {
|
|
74
|
+
return {
|
|
75
|
+
context: require('../../core/kube/context'),
|
|
76
|
+
status: require('../../core/kube/status'),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function rcapiModule() {
|
|
80
|
+
return require('../../core/rcapi');
|
|
81
|
+
}
|
|
82
|
+
function resourcesModule() {
|
|
83
|
+
return require('../../perf/resources');
|
|
84
|
+
}
|
|
85
|
+
function tlsModule() {
|
|
86
|
+
return require('../../core/tls');
|
|
87
|
+
}
|
|
88
|
+
const API_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
|
|
89
|
+
function createRequest(request) {
|
|
90
|
+
const body = (0, route_deps_1.requestBody)(request.body, true);
|
|
91
|
+
const version = (0, format_1.stripText)((0, format_1.isTruthy)(body.version) ? (0, format_1.toTextAny)(body.version) : '');
|
|
92
|
+
if (version === '')
|
|
93
|
+
throw new errors_1.ValidationError('`version` is required, e.g. {"version": "8.5.1"}');
|
|
94
|
+
const fields = { actor: (0, route_deps_1.actor)(request) };
|
|
95
|
+
const names = {
|
|
96
|
+
version: 'version',
|
|
97
|
+
preset: 'preset',
|
|
98
|
+
name: 'name',
|
|
99
|
+
port: 'port',
|
|
100
|
+
root_url: 'rootUrl',
|
|
101
|
+
bind: 'bind',
|
|
102
|
+
rc_image: 'rcImage',
|
|
103
|
+
mongo: 'mongo',
|
|
104
|
+
reg_token: 'regToken',
|
|
105
|
+
params: 'params',
|
|
106
|
+
seed: 'seed',
|
|
107
|
+
seed_here: 'seedHere',
|
|
108
|
+
seed_profile: 'seedProfile',
|
|
109
|
+
seed_scenarios: 'seedScenarios',
|
|
110
|
+
seed_history_days: 'seedHistoryDays',
|
|
111
|
+
pin: 'pin',
|
|
112
|
+
wait: 'wait',
|
|
113
|
+
offline: 'offline',
|
|
114
|
+
no_pull: 'noPull',
|
|
115
|
+
fresh: 'fresh',
|
|
116
|
+
force: 'force',
|
|
117
|
+
monitor: 'monitor',
|
|
118
|
+
stats: 'stats',
|
|
119
|
+
runtime: 'runtime',
|
|
120
|
+
deployment: 'deployment',
|
|
121
|
+
replicas: 'replicas',
|
|
122
|
+
context: 'context',
|
|
123
|
+
mongo_operator: 'mongoOperator',
|
|
124
|
+
https: 'https',
|
|
125
|
+
domain: 'domain',
|
|
126
|
+
acme_email: 'acmeEmail',
|
|
127
|
+
acme_staging: 'acmeStaging',
|
|
128
|
+
acme_challenge: 'acmeChallenge',
|
|
129
|
+
acme_dns_provider: 'acmeDnsProvider',
|
|
130
|
+
ingress_class: 'ingressClass',
|
|
131
|
+
env: 'env',
|
|
132
|
+
bind_public: 'bindPublic',
|
|
133
|
+
// The license TEXT (the CLI's --license reads a file into the same field).
|
|
134
|
+
license: 'license',
|
|
135
|
+
};
|
|
136
|
+
for (const [wire, internal] of Object.entries(names)) {
|
|
137
|
+
if (Object.hasOwn(body, wire))
|
|
138
|
+
fields[internal] = body[wire];
|
|
139
|
+
}
|
|
140
|
+
// Several presets, as `presets: ["ldap", "email"]`, spelled into the one canonical
|
|
141
|
+
// `preset` the create reads. Params may come per preset ({"ldap": {"users": 5}}) or as the
|
|
142
|
+
// `--set` keys that say them ({"ldap.users": 5}). An older server ignores `presets`.
|
|
143
|
+
if (Object.hasOwn(body, 'presets')) {
|
|
144
|
+
if (Object.hasOwn(body, 'preset')) {
|
|
145
|
+
throw new errors_1.ValidationError('give `preset` or `presets`, not both');
|
|
146
|
+
}
|
|
147
|
+
const list = body.presets;
|
|
148
|
+
if (!Array.isArray(list) || !list.every((name) => typeof name === 'string')) {
|
|
149
|
+
throw new errors_1.ValidationError('`presets` must be a list of preset names, e.g. ["ldap", "email"]');
|
|
150
|
+
}
|
|
151
|
+
fields.preset = (0, composite_1.compositeName)(list);
|
|
152
|
+
const params = (0, route_deps_1.bag)(body.params);
|
|
153
|
+
const perPreset = Object.entries(params).every(([key, value]) => list.includes(key) && typeof value === 'object' && value !== null);
|
|
154
|
+
if (perPreset && Object.keys(params).length > 0)
|
|
155
|
+
fields.params = (0, composite_1.qualifiedParams)(params);
|
|
156
|
+
}
|
|
157
|
+
return (0, types_1.createReq)(fields);
|
|
158
|
+
}
|
|
159
|
+
async function statsOf(name) {
|
|
160
|
+
const target = await (0, naming_1.resolveName)(name);
|
|
161
|
+
if ((await topology.ofRepro(target)) === topology.KUBERNETES) {
|
|
162
|
+
const kube = kubeModules();
|
|
163
|
+
const meta = await (0, record_1.readMeta)(target);
|
|
164
|
+
const rows = await kube.status.podMetrics(target, {
|
|
165
|
+
context: (0, route_deps_1.kubeContext)(meta.extra),
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
cpu: (0, route_deps_1.oneDecimal)(rows.reduce((sum, row) => sum + row.cpu_millicores, 0) / 10),
|
|
169
|
+
mem_mb: (0, route_deps_1.oneDecimal)(rows.reduce((sum, row) => sum + row.mem_bytes, 0) / 1e6),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const ids = await (0, engine_1.containerIds)(target);
|
|
173
|
+
const resources = resourcesModule();
|
|
174
|
+
const prefix = `${config.PROJECT_PREFIX}${target}-`;
|
|
175
|
+
let cpu = 0;
|
|
176
|
+
let memory = 0;
|
|
177
|
+
for (const line of (await (0, queries_1.dockerStats)(ids)).split('\n')) {
|
|
178
|
+
const parts = line.split('\t');
|
|
179
|
+
if (parts.length < 3)
|
|
180
|
+
continue;
|
|
181
|
+
const full = parts[0] ?? '';
|
|
182
|
+
const service = full.startsWith(prefix) ? full.slice(prefix.length) : full;
|
|
183
|
+
if (service === 'rocketchat' || service.startsWith('rocketchat-')) {
|
|
184
|
+
cpu += resources.parseCpu(parts[1] ?? '');
|
|
185
|
+
memory += resources.parseMem(parts[2] ?? '')[0];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return { cpu: (0, route_deps_1.oneDecimal)(cpu), mem_mb: (0, route_deps_1.oneDecimal)(memory / 1e6) };
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A delete asked for while another job is working on the same workspace waited a silent
|
|
192
|
+
* minute for that job's lock and then failed with "another houston operation is still
|
|
193
|
+
* working on it". It is refused at once instead, naming the job and how to end it.
|
|
194
|
+
*/
|
|
195
|
+
function refuseWhileBusy(app, name) {
|
|
196
|
+
const busy = app.jobs
|
|
197
|
+
.listJobs()
|
|
198
|
+
// A cluster job's label is a cluster, region or context, not a workspace.
|
|
199
|
+
.find((job) => job.label === name && jobs_1.ACTIVE_STATUSES.has(job.status) && !job.kind.startsWith('cluster-'));
|
|
200
|
+
if (busy === undefined)
|
|
201
|
+
return;
|
|
202
|
+
// UTC, as every other time houston prints.
|
|
203
|
+
const since = new Date(busy.started_at * 1000).toISOString().slice(11, 16);
|
|
204
|
+
throw new errors_1.ConflictError(`'${name}' is busy: its ${busy.kind} job, started at ${since} UTC` +
|
|
205
|
+
`${busy.actor !== '' ? ` by ${busy.actor}` : ''}, is still running. ` +
|
|
206
|
+
(busy.stoppable
|
|
207
|
+
? 'Open it in Activity and press Stop job, or wait for it to finish, then delete again.'
|
|
208
|
+
: 'Wait for it to finish, then delete again.'));
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* A workspace's payload for somebody who may look at it but not change it: no admin login,
|
|
212
|
+
* no env vars, and the admin password nowhere else either -- a workspace published beyond
|
|
213
|
+
* loopback says it in a note. The keys stay, so the panel's payload keeps its shape.
|
|
214
|
+
*/
|
|
215
|
+
function lookOnly(d) {
|
|
216
|
+
const login = d.login;
|
|
217
|
+
const secret = typeof login?.password === 'string' ? login.password : '';
|
|
218
|
+
const out = { ...d, login: null, ...('env' in d ? { env: [] } : {}) };
|
|
219
|
+
// In the notes' text only, where it is spelled out: a password restored from a bundle can
|
|
220
|
+
// be any string, and replaced across the document a one-letter one rewrote keys and names.
|
|
221
|
+
// An incoming webhook's token (`/hooks/<id>/<token>`) is masked the same way: it posts as
|
|
222
|
+
// rocket.cat on a workspace that may be bound beyond loopback, and it is in the owner's
|
|
223
|
+
// `info` for whoever may change the workspace.
|
|
224
|
+
// And a customer's own endpoints, which the webhooks preset lists as where a captured
|
|
225
|
+
// integration or the Omnichannel webhook WAS bound: their path and query carry their
|
|
226
|
+
// secrets (a Slack hook's, a CRM's token), so a viewer sees the host and no more.
|
|
227
|
+
const mask = (text) => (secret === '' ? text : text.replaceAll(secret, redact_1.REDACTED))
|
|
228
|
+
.replace(/\/hooks\/([^\s/'"]+)\/[^\s'"]+/gu, `/hooks/$1/${redact_1.REDACTED}`)
|
|
229
|
+
.replace(/(\bwas |\bleft at )(https?:\/\/[^\s/]+)\/[^\s)]*/gu, `$1$2/${redact_1.REDACTED}`);
|
|
230
|
+
const hidden = (value) => JSON.parse(JSON.stringify(value), (_key, text) => typeof text === 'string' ? mask(text) : text);
|
|
231
|
+
for (const key of ['notes', 'note_groups']) {
|
|
232
|
+
if (key in out)
|
|
233
|
+
out[key] = hidden(out[key]);
|
|
234
|
+
}
|
|
235
|
+
return out;
|
|
236
|
+
}
|
|
237
|
+
function register(app) {
|
|
238
|
+
app.get('/api/repros', async () => ({ repros: await (0, inspect_1.listRepros)() }));
|
|
239
|
+
app.get('/api/repros/:name', async (request) => {
|
|
240
|
+
const d = await (0, inspect_1.describe)(request.params.name);
|
|
241
|
+
const [mayChange] = await (0, ownership_1.ownerGate)(String(d.name), (0, route_deps_1.actor)(request));
|
|
242
|
+
return mayChange ? d : lookOnly(d);
|
|
243
|
+
});
|
|
244
|
+
app.get('/api/repros/:name/detail', async (request) => {
|
|
245
|
+
const d = await (0, payload_1.detail)(request.params.name);
|
|
246
|
+
// THIS VIEWER's answer to the ownership gate, which every change to a workspace passes
|
|
247
|
+
// (`ownerScoped` routes), so the pane offers changes only to someone the server will let.
|
|
248
|
+
// Added here, not in `detail()`: a web actor is an identity the server authenticated, and
|
|
249
|
+
// the CLI's is the caller's own assertion. Named for the first thing it gated.
|
|
250
|
+
const [mayChange] = await (0, ownership_1.ownerGate)(String(d.name), (0, route_deps_1.actor)(request));
|
|
251
|
+
return { ...(mayChange ? d : lookOnly(d)), may_destroy: mayChange };
|
|
252
|
+
});
|
|
253
|
+
app.get('/api/repros/:name/stats', async (request) => await statsOf(request.params.name));
|
|
254
|
+
app.post('/api/repros', async (request) => {
|
|
255
|
+
const req = createRequest(request);
|
|
256
|
+
const privileged = types_1.PRIVILEGED_CREATE_FIELDS.filter((field) => {
|
|
257
|
+
const keys = {
|
|
258
|
+
rc_image: 'rcImage',
|
|
259
|
+
reg_token: 'regToken',
|
|
260
|
+
bind: 'bind',
|
|
261
|
+
context: 'context',
|
|
262
|
+
license: 'license',
|
|
263
|
+
};
|
|
264
|
+
return (0, format_1.isTruthy)(req[keys[field]]);
|
|
265
|
+
});
|
|
266
|
+
// A CI build is unreleased code chosen by name: the decision `rc_image` is gated for.
|
|
267
|
+
if ((0, versions_1.isBuildTag)(req.version))
|
|
268
|
+
privileged.push('a CI build version');
|
|
269
|
+
// Where it listens, as `bind` is: a VoIP domain opens voice's call ports on every address.
|
|
270
|
+
const voipDomain = Object.entries(req.params).find(([key]) => key === 'voip_domain' || key.endsWith('.voip_domain'))?.[1];
|
|
271
|
+
if (typeof voipDomain === 'string' && (0, voice_pbx_1.opensCallPorts)(voipDomain)) {
|
|
272
|
+
privileged.push('voip_domain (it opens the call ports to the network)');
|
|
273
|
+
}
|
|
274
|
+
if (privileged.length > 0 && !(0, ownership_1.maySetPrivilegedFields)((0, route_deps_1.actor)(request))) {
|
|
275
|
+
const extra = privileged.includes('bind')
|
|
276
|
+
? ' For a workspace everyone on this box should reach, `houston config set bind_host 0.0.0.0` sets it once for the box.'
|
|
277
|
+
: '';
|
|
278
|
+
throw new errors_1.ValidationError(`${privileged.join(', ')} is limited to admins on this box (\`gui.create_policy admin\`) — ` +
|
|
279
|
+
'they decide what code runs and where it listens. An admin can widen it again with ' +
|
|
280
|
+
'`houston config set gui.create_policy anyone`.' +
|
|
281
|
+
extra);
|
|
282
|
+
}
|
|
283
|
+
// A pin also makes it the CLI's default for everybody on the box, which is an admin's.
|
|
284
|
+
const who = (0, route_deps_1.actor)(request);
|
|
285
|
+
if (req.pin && who !== '' && (0, users_1.roleOf)(who) !== 'admin') {
|
|
286
|
+
throw new errors_1.ValidationError('pin also makes it the default workspace for CLI commands on this box, which is ' +
|
|
287
|
+
"an admin's to set");
|
|
288
|
+
}
|
|
289
|
+
if ((0, format_1.isTruthy)(req.context)) {
|
|
290
|
+
const [known] = await kubeModules().context.contexts();
|
|
291
|
+
if (known.length > 0 && !known.includes(req.context)) {
|
|
292
|
+
throw new errors_1.ValidationError(`no kubeconfig context named ${(0, format_1.quotedText)(req.context)} on this server. It can see: ` +
|
|
293
|
+
known.map(format_1.quotedText).join(', '));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if ((0, format_1.isTruthy)(req.preset)) {
|
|
297
|
+
try {
|
|
298
|
+
// Each name of a set: the set's own spelling (`email+ldap`) is not a name.
|
|
299
|
+
for (const name of (0, composite_1.namesOf)(req.preset))
|
|
300
|
+
(0, presets_1.userPath)(name);
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
throw new errors_1.ValidationError((0, errors_1.errorText)(error));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// So the label below names the workspace the create acts on. A name that is not a
|
|
307
|
+
// string is the job's to refuse.
|
|
308
|
+
if (typeof req.name === 'string')
|
|
309
|
+
await (0, ownership_1.claimTypedName)(req);
|
|
310
|
+
// The release lookup is the JOB's, inside `createRepro` where the pairing is resolved:
|
|
311
|
+
// the request holding a response open for it answered nothing the job does not answer
|
|
312
|
+
// again.
|
|
313
|
+
return (0, route_deps_1.submit)(app, 'create', (emit) => (0, create_docker_1.createRepro)(req, emit, {
|
|
314
|
+
streamOutput: true,
|
|
315
|
+
monitorAttach: monitor.attach,
|
|
316
|
+
}),
|
|
317
|
+
// A typed name is labelled -- and so audited -- as the workspace it makes: with
|
|
318
|
+
// accounts `gui-1` becomes `alice-gui-1`, and the audit said `create gui-1`, a name
|
|
319
|
+
// nothing on the box answers to. The same function the create uses. A derived name
|
|
320
|
+
// waits on the version lookup, so the job starts labelled with the version asked for,
|
|
321
|
+
// and its audit line waits for the name the create settles on: History listed every
|
|
322
|
+
// such create as "8.5.1". A name that is not a string keeps the label earlier releases
|
|
323
|
+
// gave it.
|
|
324
|
+
{
|
|
325
|
+
label: typeof req.name === 'string' && (0, format_1.isTruthy)(req.name)
|
|
326
|
+
? (0, naming_1.deriveFor)(req)
|
|
327
|
+
: ((0, format_1.isTruthy)(req.name) ? req.name : req.version),
|
|
328
|
+
auditWhenNamed: !(0, format_1.isTruthy)(req.name),
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
app.post('/api/repros/:name/state', async (request) => {
|
|
332
|
+
const action = (0, route_deps_1.requestBody)(request.body, true).action;
|
|
333
|
+
const target = await (0, preconditions_1.checkStateRequest)(request.params.name, action);
|
|
334
|
+
return (0, route_deps_1.submit)(app, 'state', (emit) => (0, state_1.setState)(target, action, emit, { streamOutput: true }), {
|
|
335
|
+
label: target,
|
|
336
|
+
verb: String(action), // start, stop or restart: `checkStateRequest` refused anything else
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
app.post('/api/repros/:name/up', async (request) => {
|
|
340
|
+
const target = await (0, naming_1.resolveName)(request.params.name);
|
|
341
|
+
const meta = await (0, record_1.readMeta)(target);
|
|
342
|
+
const extra = (0, route_deps_1.bag)(meta.extra);
|
|
343
|
+
// BROUGHT BACK AS ITS CREATOR, by anyone who may act for it. This sent no actor at all,
|
|
344
|
+
// and a Kubernetes namespace carries its creator as its owner label: the create refused
|
|
345
|
+
// the owner themselves ("HOUSTON_USER is not set"), so a GUI user could take a
|
|
346
|
+
// workspace down and never bring it back. `created_by` is that label, and the rewritten
|
|
347
|
+
// record keeps it.
|
|
348
|
+
//
|
|
349
|
+
// THIS workspace, never `<actor>-<name>`: a workspace made from the CLI has no
|
|
350
|
+
// `created_by`, so the clicker's prefix went on its name and the create failed on the
|
|
351
|
+
// ports the real one holds. Anyone else is refused, not given a new workspace.
|
|
352
|
+
const me = (0, route_deps_1.actor)(request);
|
|
353
|
+
const [mayAct, owner] = await (0, ownership_1.ownerGate)(target, me);
|
|
354
|
+
if (!mayAct) {
|
|
355
|
+
throw new errors_1.ConflictError(`${target} belongs to ${owner} — only ${owner} or an admin can bring it back up.`);
|
|
356
|
+
}
|
|
357
|
+
const creator = typeof extra.created_by === 'string' ? extra.created_by : me;
|
|
358
|
+
const req = (0, types_1.createReq)({
|
|
359
|
+
version: meta.rcVersion,
|
|
360
|
+
name: target,
|
|
361
|
+
exactName: true,
|
|
362
|
+
bringBack: true,
|
|
363
|
+
actor: creator,
|
|
364
|
+
wait: true,
|
|
365
|
+
offline: true,
|
|
366
|
+
...topology.axesOfMeta(meta),
|
|
367
|
+
// The params it was made with, which a Kubernetes start re-applies: without them it
|
|
368
|
+
// came back with each preset's defaults.
|
|
369
|
+
params: extra.preset_params === undefined
|
|
370
|
+
? { ...(0, route_deps_1.bag)(extra.params) }
|
|
371
|
+
: (0, composite_1.qualifiedParams)((0, route_deps_1.bag)(extra.preset_params)),
|
|
372
|
+
});
|
|
373
|
+
// With the monitoring hook, as the create has it: a monitored Kubernetes workspace came
|
|
374
|
+
// back without its monitoring, "not supplied by the caller".
|
|
375
|
+
return (0, route_deps_1.submit)(app, 'up', (emit) => (0, create_docker_1.createRepro)(req, emit, { streamOutput: true, monitorAttach: monitor.attach }), { label: target });
|
|
376
|
+
});
|
|
377
|
+
app.post('/api/repros/:name/ready', async (request) => {
|
|
378
|
+
const meta = await (0, record_1.readMeta)(await (0, naming_1.resolveName)(request.params.name));
|
|
379
|
+
return (0, route_deps_1.submit)(app, 'ready', (emit) => (0, ready_1.waitAndFinalize)(meta, emit), { label: meta.name });
|
|
380
|
+
});
|
|
381
|
+
app.post('/api/repros/:name/default', async (request) => {
|
|
382
|
+
const target = await (0, naming_1.resolveName)(request.params.name);
|
|
383
|
+
await (0, locks_1.updateConfig)((cfg) => {
|
|
384
|
+
cfg.default_repro = target;
|
|
385
|
+
});
|
|
386
|
+
return { ok: true, default: target };
|
|
387
|
+
});
|
|
388
|
+
app.post('/api/repros/:name/pat', async (request) => {
|
|
389
|
+
const rcapi = rcapiModule();
|
|
390
|
+
const body = (0, route_deps_1.requestBody)(request.body, false);
|
|
391
|
+
const target = await (0, naming_1.resolveName)(request.params.name);
|
|
392
|
+
await (0, preconditions_1.requireEngine)(target);
|
|
393
|
+
const meta = await (0, record_1.readMeta)(target);
|
|
394
|
+
const label = (0, route_deps_1.orText)(body.label, 'houston');
|
|
395
|
+
const bypass2fa = body.bypass_2fa === undefined || (0, route_deps_1.bool)(body.bypass_2fa);
|
|
396
|
+
try {
|
|
397
|
+
const auth = await (0, admin_1.login)(meta);
|
|
398
|
+
const token = await rcapi.generatePat(meta.rootUrl, auth, (0, record_1.adminPass)(meta), {
|
|
399
|
+
tokenName: label,
|
|
400
|
+
bypass2fa,
|
|
401
|
+
workspace: meta.name,
|
|
402
|
+
});
|
|
403
|
+
if (token === '')
|
|
404
|
+
throw new errors_1.NotReadyError('Rocket.Chat did not return a token (is it ready?)');
|
|
405
|
+
return {
|
|
406
|
+
token,
|
|
407
|
+
user_id: auth.userId,
|
|
408
|
+
label,
|
|
409
|
+
bypass_2fa: bypass2fa,
|
|
410
|
+
root_url: meta.rootUrl,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
if (error instanceof errors_1.NotReadyError)
|
|
415
|
+
throw error;
|
|
416
|
+
throw new errors_1.NotReadyError(`could not create a token (is it ready? \`houston ready -n ${meta.name}\`): ${(0, errors_1.errorText)(error)}`);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
app.get('/api/repros/:name/env', async (request) => await envvarsModule().current(request.params.name));
|
|
420
|
+
app.post('/api/repros/:name/env', async (request) => {
|
|
421
|
+
const envvars = envvarsModule();
|
|
422
|
+
const body = (0, route_deps_1.requestBody)(request.body, true);
|
|
423
|
+
// Refused HERE, as a 400, not as a job that fails after the GUI said it started.
|
|
424
|
+
const target = await envvars.envTarget(request.params.name);
|
|
425
|
+
const rawSets = (0, format_1.isTruthy)(body.set) ? body.set : {};
|
|
426
|
+
const rawSettings = (0, format_1.isTruthy)(body.setting) ? body.setting : {};
|
|
427
|
+
if (typeof rawSets !== 'object' || Array.isArray(rawSets)) {
|
|
428
|
+
throw new errors_1.ValidationError('`set` must be an object of KEY: VALUE');
|
|
429
|
+
}
|
|
430
|
+
if (typeof rawSettings !== 'object' || Array.isArray(rawSettings)) {
|
|
431
|
+
throw new errors_1.ValidationError('`setting` must be an object of SettingId: VALUE');
|
|
432
|
+
}
|
|
433
|
+
const rawUnset = (0, format_1.isTruthy)(body.unset) ? body.unset : [];
|
|
434
|
+
if (!Array.isArray(rawUnset)) {
|
|
435
|
+
throw new errors_1.ValidationError('`unset` must be a list of key names');
|
|
436
|
+
}
|
|
437
|
+
const sets = {
|
|
438
|
+
...rawSets,
|
|
439
|
+
...envvars.prefixSettings(rawSettings),
|
|
440
|
+
};
|
|
441
|
+
const unset = (0, route_deps_1.strings)(rawUnset);
|
|
442
|
+
return (0, route_deps_1.submit)(app, 'env', (emit) => envvars.setEnv(target, sets, unset, {
|
|
443
|
+
restart: body.restart === undefined || (0, route_deps_1.bool)(body.restart),
|
|
444
|
+
emit,
|
|
445
|
+
}), { label: target });
|
|
446
|
+
});
|
|
447
|
+
app.get('/api/repros/:name/tls', async (request) => {
|
|
448
|
+
const tls = tlsModule();
|
|
449
|
+
const meta = await (0, record_1.readMeta)(await (0, naming_1.resolveName)(request.params.name));
|
|
450
|
+
if (!(0, format_1.isTruthy)(meta.publicUrl))
|
|
451
|
+
throw new errors_1.ValidationError(`${(0, format_1.quotedText)(meta.name)} was not created with --https`);
|
|
452
|
+
const extra = (0, route_deps_1.bag)(meta.extra);
|
|
453
|
+
const mode = (0, route_deps_1.orText)(extra.tls);
|
|
454
|
+
const host = (meta.publicUrl.split('://', 2)[1] ?? '').split(':', 1)[0] ?? '';
|
|
455
|
+
const rawPorts = Array.isArray(extra.tls_ports) ? extra.tls_ports : [443];
|
|
456
|
+
const port = Number(rawPorts[0] ?? 443);
|
|
457
|
+
const cafile = mode === tls.MODE_LOCAL ? (0, home_1.joinPath)(tls.caDir(), tls.CA_CRT) : '';
|
|
458
|
+
const report = await tls.probeServed(host, port, extra, { cafile, ask: tls.verify });
|
|
459
|
+
const out = {
|
|
460
|
+
...report,
|
|
461
|
+
mode,
|
|
462
|
+
public_url: meta.publicUrl,
|
|
463
|
+
name: meta.name,
|
|
464
|
+
};
|
|
465
|
+
if (mode === tls.MODE_ACME) {
|
|
466
|
+
const publicReport = await tls.verify(host);
|
|
467
|
+
out.public_issuer = publicReport.issuer;
|
|
468
|
+
out.public_error = publicReport.error;
|
|
469
|
+
}
|
|
470
|
+
return out;
|
|
471
|
+
});
|
|
472
|
+
app.post('/api/repros/:name/call', async (request) => {
|
|
473
|
+
const rcapi = rcapiModule();
|
|
474
|
+
const body = (0, route_deps_1.requestBody)(request.body, true);
|
|
475
|
+
const target = await (0, naming_1.resolveName)(request.params.name);
|
|
476
|
+
await (0, preconditions_1.requireEngine)(target);
|
|
477
|
+
const meta = await (0, record_1.readMeta)(target);
|
|
478
|
+
const method = (0, route_deps_1.orText)(body.method, 'GET').toUpperCase();
|
|
479
|
+
if (!API_METHODS.includes(method)) {
|
|
480
|
+
throw new errors_1.ValidationError(`unsupported method ${(0, format_1.quotedText)(method)} (use ${API_METHODS.join(', ')})`);
|
|
481
|
+
}
|
|
482
|
+
const apiPath = (0, format_1.stripText)((0, route_deps_1.orText)(body.path));
|
|
483
|
+
if (apiPath === '')
|
|
484
|
+
throw new errors_1.ValidationError('no API path given, e.g. /api/v1/me');
|
|
485
|
+
const raw = (0, format_1.stripText)((0, route_deps_1.orText)(body.data));
|
|
486
|
+
let payload;
|
|
487
|
+
try {
|
|
488
|
+
const parsed = raw === '' ? undefined : JSON.parse(raw);
|
|
489
|
+
payload = parsed === null ? undefined : parsed;
|
|
490
|
+
}
|
|
491
|
+
catch (error) {
|
|
492
|
+
throw new errors_1.ValidationError(`request body is not valid JSON: ${(0, errors_1.errorText)(error)}`);
|
|
493
|
+
}
|
|
494
|
+
const usePat = (0, route_deps_1.bool)(body.pat);
|
|
495
|
+
const twoFa = (0, route_deps_1.bool)(body.two_fa);
|
|
496
|
+
let auth;
|
|
497
|
+
try {
|
|
498
|
+
auth = await (0, admin_1.login)(meta);
|
|
499
|
+
if (usePat) {
|
|
500
|
+
auth = {
|
|
501
|
+
token: await rcapi.generatePat(meta.rootUrl, auth, (0, record_1.adminPass)(meta), {
|
|
502
|
+
bypass2fa: true,
|
|
503
|
+
workspace: meta.name,
|
|
504
|
+
}),
|
|
505
|
+
userId: auth.userId,
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
throw new errors_1.NotReadyError(`could not authenticate (is it ready? \`houston ready -n ${meta.name}\`): ${(0, errors_1.errorText)(error)}`);
|
|
511
|
+
}
|
|
512
|
+
audit.record('api-call', `${meta.name} ${method} ${apiPath}`);
|
|
513
|
+
const extraHeaders = twoFa ? await rcapi.password2faHeaders((0, record_1.adminPass)(meta)) : undefined;
|
|
514
|
+
const started = node_perf_hooks_1.performance.now();
|
|
515
|
+
let result;
|
|
516
|
+
try {
|
|
517
|
+
result = await rcapi.call(meta.rootUrl, method, apiPath, {
|
|
518
|
+
auth,
|
|
519
|
+
...(payload === undefined ? {} : { data: payload }),
|
|
520
|
+
...(extraHeaders === undefined ? {} : { extraHeaders }),
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
catch (error) {
|
|
524
|
+
if (!(error instanceof rcapi.RequestFailed))
|
|
525
|
+
throw error;
|
|
526
|
+
throw new errors_1.NotReadyError(`request failed: ${(0, errors_1.errorText)(error)}`);
|
|
527
|
+
}
|
|
528
|
+
return {
|
|
529
|
+
status: result[0],
|
|
530
|
+
text: result[1],
|
|
531
|
+
tag: `${usePat ? 'PAT' : 'admin'}${twoFa ? '+2fa' : ''}`,
|
|
532
|
+
elapsed_ms: (0, route_deps_1.oneDecimal)(node_perf_hooks_1.performance.now() - started),
|
|
533
|
+
url: `${meta.rootUrl.replace(/\/+$/u, '')}/${apiPath.replace(/^\/+/, '')}`,
|
|
534
|
+
};
|
|
535
|
+
});
|
|
536
|
+
app.post('/api/repros/:name/owner', async (request) => await (0, ownership_1.setOwner)(request.params.name, (0, route_deps_1.orText)((0, route_deps_1.requestBody)(request.body, true).to), {
|
|
537
|
+
by: (0, route_deps_1.actor)(request),
|
|
538
|
+
}));
|
|
539
|
+
app.delete('/api/repros/:name', async (request) => {
|
|
540
|
+
const volumes = (0, route_deps_1.queryBool)(request.query.volumes, false, 'volumes');
|
|
541
|
+
const confirm = (0, route_deps_1.queryBool)(request.query.confirm, false, 'confirm');
|
|
542
|
+
const target = await (0, preconditions_1.checkTeardownRequest)(request.params.name, { volumes, confirm });
|
|
543
|
+
refuseWhileBusy(app, target);
|
|
544
|
+
return (0, route_deps_1.submit)(app, 'teardown', (emit) => (0, destroy_1.teardown)(target, { volumes, confirm, emit, streamOutput: true }), { label: target, verb: volumes ? 'delete' : 'take down' });
|
|
545
|
+
});
|
|
546
|
+
app.post('/api/prune', async (request) => {
|
|
547
|
+
const body = (0, route_deps_1.requestBody)(request.body, false);
|
|
548
|
+
return (0, route_deps_1.submit)(app, 'prune', (emit) => (0, pruning_1.prune)({ confirm: (0, route_deps_1.bool)(body.confirm), orphans: (0, route_deps_1.bool)(body.orphans), emit }));
|
|
549
|
+
});
|
|
550
|
+
}
|