@codiac.io/codiac-cli 1.3.181 → 1.3.182
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/README.md +1 -1
- package/dist/apis/codiac-api/gen/client.d.ts +5 -1
- package/dist/apis/codiac-api/gen/client.js +12 -0
- package/dist/apis/codiac-api/gen/client.js.map +1 -1
- package/dist/apis/codiac-api/gen/contracts/types.gen.d.ts +25 -0
- package/dist/apis/codiac-api/gen/contracts/types.gen.js.map +1 -1
- package/dist/apis/codiac-api/i-client.d.ts +4 -0
- package/dist/apis/codiac-api-nats/gen/client.d.ts +4 -0
- package/dist/apis/codiac-api-nats/gen/client.js +17 -1
- package/dist/apis/codiac-api-nats/gen/client.js.map +1 -1
- package/dist/apis/codiac-api-nats/gen/contracts/types.gen.d.ts +25 -0
- package/dist/apis/codiac-api-nats/gen/contracts/types.gen.js.map +1 -1
- package/dist/apis/codiac-relay/gen/client.d.ts +16 -3
- package/dist/apis/codiac-relay/gen/client.js +58 -1
- package/dist/apis/codiac-relay/gen/client.js.map +1 -1
- package/dist/apis/codiac-relay/gen/contracts/types.gen.d.ts +173 -7
- package/dist/apis/codiac-relay/gen/contracts/types.gen.js.map +1 -1
- package/dist/apis/codiac-relay/i-client.d.ts +8 -0
- package/dist/apis/codiac-relay-nats/gen/client.d.ts +15 -7
- package/dist/apis/codiac-relay-nats/gen/client.js +86 -19
- package/dist/apis/codiac-relay-nats/gen/client.js.map +1 -1
- package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.d.ts +151 -15
- package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.js +4 -4
- package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.js.map +1 -1
- package/dist/apis/codiac-relay-nats/gen/contracts.ng.d.ts +6 -0
- package/dist/apis/codiac-relay-nats/gen/contracts.ng.js +1 -0
- package/dist/apis/codiac-relay-nats/gen/contracts.ng.js.map +1 -1
- package/dist/bootstrapper-for-api-clients.js +14 -2
- package/dist/bootstrapper-for-api-clients.js.map +1 -1
- package/dist/cli-common/built-in-cli-user-input.d.ts +2 -1
- package/dist/cli-common/built-in-cli-user-input.js +52 -1
- package/dist/cli-common/built-in-cli-user-input.js.map +1 -1
- package/dist/cli-common/entities/prompt-choice.d.ts +2 -7
- package/dist/cli-common/mock-ui.d.ts +2 -1
- package/dist/cli-common/mock-ui.js +3 -0
- package/dist/cli-common/mock-ui.js.map +1 -1
- package/dist/codiac-constants.d.ts +3 -0
- package/dist/codiac-constants.js +3 -0
- package/dist/codiac-constants.js.map +1 -1
- package/dist/command-base-enterprise.d.ts +23 -2
- package/dist/command-base-enterprise.js +82 -26
- package/dist/command-base-enterprise.js.map +1 -1
- package/dist/command-base-exec.js +4 -2
- package/dist/command-base-exec.js.map +1 -1
- package/dist/commands/asset/deploy.d.ts +2 -1
- package/dist/commands/asset/deploy.js +3 -2
- package/dist/commands/asset/deploy.js.map +1 -1
- package/dist/commands/asset/list.d.ts +26 -7
- package/dist/commands/asset/list.js +127 -112
- package/dist/commands/asset/list.js.map +1 -1
- package/dist/commands/asset/probe/create.d.ts +26 -5
- package/dist/commands/asset/probe/create.js +182 -164
- package/dist/commands/asset/probe/create.js.map +1 -1
- package/dist/commands/asset/recycle.js +3 -4
- package/dist/commands/asset/recycle.js.map +1 -1
- package/dist/commands/asset/undeploy.d.ts +24 -9
- package/dist/commands/asset/undeploy.js +162 -161
- package/dist/commands/asset/undeploy.js.map +1 -1
- package/dist/commands/asset/view.js +1 -1
- package/dist/commands/asset/view.js.map +1 -1
- package/dist/commands/asset/volume/create.d.ts +24 -13
- package/dist/commands/asset/volume/create.js +153 -158
- package/dist/commands/asset/volume/create.js.map +1 -1
- package/dist/commands/asset/volume/delete.d.ts +21 -7
- package/dist/commands/asset/volume/delete.js +107 -101
- package/dist/commands/asset/volume/delete.js.map +1 -1
- package/dist/commands/asset/volume/list.d.ts +23 -9
- package/dist/commands/asset/volume/list.js +74 -54
- package/dist/commands/asset/volume/list.js.map +1 -1
- package/dist/commands/cabinet/cluster/attach.d.ts +32 -0
- package/dist/commands/cabinet/cluster/attach.js +144 -0
- package/dist/commands/cabinet/cluster/attach.js.map +1 -0
- package/dist/commands/cabinet/create.d.ts +1 -0
- package/dist/commands/cabinet/create.js +5 -1
- package/dist/commands/cabinet/create.js.map +1 -1
- package/dist/commands/cabinet/list.d.ts +27 -6
- package/dist/commands/cabinet/list.js +130 -121
- package/dist/commands/cabinet/list.js.map +1 -1
- package/dist/commands/cabinet/obliterate.d.ts +1 -0
- package/dist/commands/cabinet/obliterate.js +5 -1
- package/dist/commands/cabinet/obliterate.js.map +1 -1
- package/dist/commands/cabinet/restore.d.ts +36 -0
- package/dist/commands/cabinet/restore.js +186 -0
- package/dist/commands/cabinet/restore.js.map +1 -0
- package/dist/commands/cluster/agent/configure.d.ts +47 -0
- package/dist/commands/cluster/agent/configure.js +320 -0
- package/dist/commands/cluster/agent/configure.js.map +1 -0
- package/dist/commands/cluster/agent/install.d.ts +32 -0
- package/dist/commands/cluster/agent/install.js +152 -0
- package/dist/commands/cluster/agent/install.js.map +1 -0
- package/dist/commands/cluster/agent/uninstall.d.ts +29 -0
- package/dist/commands/cluster/agent/uninstall.js +130 -0
- package/dist/commands/cluster/agent/uninstall.js.map +1 -0
- package/dist/commands/cluster/bootstrap.d.ts +50 -0
- package/dist/commands/cluster/bootstrap.js +310 -0
- package/dist/commands/cluster/bootstrap.js.map +1 -0
- package/dist/commands/cluster/connect.d.ts +0 -5
- package/dist/commands/cluster/connect.js +1 -26
- package/dist/commands/cluster/connect.js.map +1 -1
- package/dist/commands/cluster/install.d.ts +45 -0
- package/dist/commands/cluster/install.js +224 -0
- package/dist/commands/cluster/install.js.map +1 -0
- package/dist/commands/cluster/stack/capture.js +0 -2
- package/dist/commands/cluster/stack/capture.js.map +1 -1
- package/dist/commands/cluster/stack/install.d.ts +40 -0
- package/dist/commands/cluster/stack/install.js +196 -0
- package/dist/commands/cluster/stack/install.js.map +1 -0
- package/dist/commands/cluster/start.d.ts +0 -5
- package/dist/commands/cluster/start.js +1 -27
- package/dist/commands/cluster/start.js.map +1 -1
- package/dist/commands/cluster/stop.d.ts +0 -5
- package/dist/commands/cluster/stop.js +1 -27
- package/dist/commands/cluster/stop.js.map +1 -1
- package/dist/commands/config/add.d.ts +9 -11
- package/dist/commands/config/add.js +59 -125
- package/dist/commands/config/add.js.map +1 -1
- package/dist/commands/config/delete.d.ts +22 -11
- package/dist/commands/config/delete.js +28 -83
- package/dist/commands/config/delete.js.map +1 -1
- package/dist/commands/config/deploy.d.ts +26 -8
- package/dist/commands/config/deploy.js +169 -198
- package/dist/commands/config/deploy.js.map +1 -1
- package/dist/commands/config/import.d.ts +27 -22
- package/dist/commands/config/import.js +222 -253
- package/dist/commands/config/import.js.map +1 -1
- package/dist/commands/config/settings/get.d.ts +25 -14
- package/dist/commands/config/settings/get.js +30 -123
- package/dist/commands/config/settings/get.js.map +1 -1
- package/dist/commands/config/view.d.ts +26 -6
- package/dist/commands/config/view.js +112 -95
- package/dist/commands/config/view.js.map +1 -1
- package/dist/commands/csp/logout.d.ts +23 -6
- package/dist/commands/csp/logout.js +86 -63
- package/dist/commands/csp/logout.js.map +1 -1
- package/dist/commands/deploy.d.ts +31 -14
- package/dist/commands/deploy.js +264 -385
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/enterprise/list.d.ts +22 -4
- package/dist/commands/enterprise/list.js +97 -67
- package/dist/commands/enterprise/list.js.map +1 -1
- package/dist/commands/env/add.d.ts +26 -7
- package/dist/commands/env/add.js +182 -179
- package/dist/commands/env/add.js.map +1 -1
- package/dist/commands/environment/cluster/attach.d.ts +1 -0
- package/dist/commands/environment/cluster/attach.js +5 -1
- package/dist/commands/environment/cluster/attach.js.map +1 -1
- package/dist/commands/environment/cluster/detach.d.ts +1 -0
- package/dist/commands/environment/cluster/detach.js +5 -1
- package/dist/commands/environment/cluster/detach.js.map +1 -1
- package/dist/commands/environment/create.d.ts +1 -0
- package/dist/commands/environment/create.js +5 -1
- package/dist/commands/environment/create.js.map +1 -1
- package/dist/commands/environment/delete.d.ts +39 -0
- package/dist/commands/environment/delete.js +135 -0
- package/dist/commands/environment/delete.js.map +1 -0
- package/dist/commands/environment/list.d.ts +28 -9
- package/dist/commands/environment/list.js +128 -167
- package/dist/commands/environment/list.js.map +1 -1
- package/dist/commands/host/map.d.ts +29 -19
- package/dist/commands/host/map.js +263 -324
- package/dist/commands/host/map.js.map +1 -1
- package/dist/commands/imageRegistry/capture.d.ts +12 -11
- package/dist/commands/imageRegistry/capture.js +49 -113
- package/dist/commands/imageRegistry/capture.js.map +1 -1
- package/dist/commands/imageRegistry/forget.d.ts +12 -11
- package/dist/commands/imageRegistry/forget.js +53 -114
- package/dist/commands/imageRegistry/forget.js.map +1 -1
- package/dist/commands/imageRegistry/pullSecret/set.d.ts +21 -11
- package/dist/commands/imageRegistry/pullSecret/set.js +184 -278
- package/dist/commands/imageRegistry/pullSecret/set.js.map +1 -1
- package/dist/commands/imageRegistry/pullSecret/unset.d.ts +19 -11
- package/dist/commands/imageRegistry/pullSecret/unset.js +117 -190
- package/dist/commands/imageRegistry/pullSecret/unset.js.map +1 -1
- package/dist/commands/images/add.d.ts +19 -6
- package/dist/commands/images/add.js +63 -53
- package/dist/commands/images/add.js.map +1 -1
- package/dist/commands/kit/create.d.ts +22 -10
- package/dist/commands/kit/create.js +119 -121
- package/dist/commands/kit/create.js.map +1 -1
- package/dist/commands/logout.d.ts +21 -5
- package/dist/commands/logout.js +44 -25
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/noc/cluster/create.js +22 -10
- package/dist/commands/noc/cluster/create.js.map +1 -1
- package/dist/commands/noc/cluster/credentials-set.d.ts +38 -0
- package/dist/commands/noc/cluster/credentials-set.js +174 -0
- package/dist/commands/noc/cluster/credentials-set.js.map +1 -0
- package/dist/commands/noc/cluster/define.d.ts +46 -0
- package/dist/commands/noc/cluster/define.js +305 -0
- package/dist/commands/noc/cluster/define.js.map +1 -0
- package/dist/commands/noc/cluster/deinit.d.ts +22 -5
- package/dist/commands/noc/cluster/deinit.js +99 -106
- package/dist/commands/noc/cluster/deinit.js.map +1 -1
- package/dist/commands/noc/cluster/forget.js +2 -4
- package/dist/commands/noc/cluster/forget.js.map +1 -1
- package/dist/commands/noc/cluster/grant.d.ts +20 -11
- package/dist/commands/noc/cluster/grant.js +94 -132
- package/dist/commands/noc/cluster/grant.js.map +1 -1
- package/dist/commands/noc/cluster/init.d.ts +25 -7
- package/dist/commands/noc/cluster/init.js +121 -133
- package/dist/commands/noc/cluster/init.js.map +1 -1
- package/dist/commands/noc/cluster/journal.d.ts +0 -5
- package/dist/commands/noc/cluster/journal.js +1 -26
- package/dist/commands/noc/cluster/journal.js.map +1 -1
- package/dist/commands/noc/cluster/list.d.ts +23 -5
- package/dist/commands/noc/cluster/list.js +107 -111
- package/dist/commands/noc/cluster/list.js.map +1 -1
- package/dist/commands/noc/cluster/restore.d.ts +36 -0
- package/dist/commands/noc/cluster/restore.js +196 -0
- package/dist/commands/noc/cluster/restore.js.map +1 -0
- package/dist/commands/portal.d.ts +21 -5
- package/dist/commands/portal.js +37 -36
- package/dist/commands/portal.js.map +1 -1
- package/dist/commands/secretStore/capture.d.ts +13 -11
- package/dist/commands/secretStore/capture.js +63 -123
- package/dist/commands/secretStore/capture.js.map +1 -1
- package/dist/commands/secretStore/forget.d.ts +13 -11
- package/dist/commands/secretStore/forget.js +55 -111
- package/dist/commands/secretStore/forget.js.map +1 -1
- package/dist/commands/shell/init.d.ts +15 -0
- package/dist/commands/shell/init.js +96 -0
- package/dist/commands/shell/init.js.map +1 -0
- package/dist/commands/snapshot/deploy.d.ts +22 -42
- package/dist/commands/snapshot/deploy.js +173 -269
- package/dist/commands/snapshot/deploy.js.map +1 -1
- package/dist/commands/snapshot/list.d.ts +26 -5
- package/dist/commands/snapshot/list.js +116 -109
- package/dist/commands/snapshot/list.js.map +1 -1
- package/dist/commands/tenant/create.d.ts +18 -13
- package/dist/commands/tenant/create.js +69 -69
- package/dist/commands/tenant/create.js.map +1 -1
- package/dist/commands/tenant/switch.d.ts +18 -12
- package/dist/commands/tenant/switch.js +65 -59
- package/dist/commands/tenant/switch.js.map +1 -1
- package/dist/commands/whereami.d.ts +18 -8
- package/dist/commands/whereami.js +67 -102
- package/dist/commands/whereami.js.map +1 -1
- package/dist/commands/whoami.d.ts +19 -3
- package/dist/commands/whoami.js +44 -13
- package/dist/commands/whoami.js.map +1 -1
- package/dist/ops/i-user-input-provider.d.ts +20 -1
- package/dist/ops/i-user-input-provider.js.map +1 -1
- package/dist/ops/test/mock-ui.d.ts +2 -1
- package/dist/ops/test/mock-ui.js +3 -0
- package/dist/ops/test/mock-ui.js.map +1 -1
- package/dist/ops/throwing-user-input-provider.d.ts +2 -1
- package/dist/ops/throwing-user-input-provider.js +3 -0
- package/dist/ops/throwing-user-input-provider.js.map +1 -1
- package/dist/relay/relay-container.js +1 -1
- package/dist/uilogic/lrp-watcher-predef.d.ts +2 -1
- package/dist/uilogic/lrp-watcher-predef.js +31 -17
- package/dist/uilogic/lrp-watcher-predef.js.map +1 -1
- package/dist/uilogic/lrp-watcher-utils.d.ts +2 -0
- package/dist/uilogic/lrp-watcher-utils.js +2 -0
- package/dist/uilogic/lrp-watcher-utils.js.map +1 -1
- package/dist/uilogic/rootmap-ui-utils.d.ts +18 -1
- package/dist/uilogic/rootmap-ui-utils.js +30 -0
- package/dist/uilogic/rootmap-ui-utils.js.map +1 -1
- package/dist/uilogic/tenant-contextualizer.js +11 -1
- package/dist/uilogic/tenant-contextualizer.js.map +1 -1
- package/dist/user-context-loader.d.ts +12 -7
- package/dist/user-context-loader.js +89 -43
- package/dist/user-context-loader.js.map +1 -1
- package/oclif.manifest.json +3981 -1450
- package/package.json +2 -2
- package/dist/commands/noc/cluster/recreate.d.ts +0 -28
- package/dist/commands/noc/cluster/recreate.js +0 -197
- package/dist/commands/noc/cluster/recreate.js.map +0 -1
|
@@ -4,148 +4,151 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const host_name_strategy_enum_1 = require("@codiac.io/codiac-domain/host-name-strategy-enum");
|
|
6
6
|
const contracts_1 = require("../../apis/codiac-api/contracts");
|
|
7
|
-
const
|
|
7
|
+
const command_base_exec_tenant_1 = require("../../command-base-exec-tenant");
|
|
8
8
|
const delete_1 = require("./delete");
|
|
9
9
|
const type_safety_utils_1 = require("../../uilogic/type-safety-utils");
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const config_ui_utils_1 = require("../../uilogic/config-ui-utils");
|
|
11
|
+
class HostMap extends command_base_exec_tenant_1.CommandBaseExecTenant {
|
|
12
|
+
captureArgs() {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const { flags } = yield this.parse(HostMap);
|
|
16
|
+
const interactionMode = (this.pipedInput) ? config_ui_utils_1.InteractionModes.silent : (_b = (_a = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? config_ui_utils_1.InteractionModes.echo : undefined)) !== null && _a !== void 0 ? _a : (flags["to-script"] ? config_ui_utils_1.InteractionModes.toscript : undefined)) !== null && _b !== void 0 ? _b : (flags.silent ? config_ui_utils_1.InteractionModes.silent : undefined);
|
|
17
|
+
return [{}, interactionMode, false];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
buildCandidate_silently(_partial, rootMap) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const { args, flags } = yield this.parse(HostMap);
|
|
23
|
+
if (!args.domain)
|
|
24
|
+
throw new Error(`Domain argument is required in silent mode.`);
|
|
25
|
+
const scopesAvail = yield this.getCabinetScopes(rootMap);
|
|
26
|
+
const scope = this.validateGivenTarget(flags, scopesAvail, true);
|
|
27
|
+
if (!scope)
|
|
28
|
+
throw new Error(`Invalid or ambiguous scope. Provide --enterprise, --environment, or --cabinet.`);
|
|
29
|
+
const naming = this.validateGivenNaming(flags.naming, true);
|
|
30
|
+
if (!naming)
|
|
31
|
+
throw new Error(`Invalid host naming strategy [${flags.naming}].`);
|
|
32
|
+
const isPrivate = type_safety_utils_1.TypeSafetyUtils.toBoolean(flags.private);
|
|
33
|
+
const thisMachine = this.isLocalMachine(scope, rootMap);
|
|
34
|
+
return { domain: args.domain.trim(), scope, naming, isPrivate, thisMachine };
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
buildCandidate_interactively(_partial, _takeDefaults, rootMap) {
|
|
12
38
|
var _a;
|
|
13
39
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
this.bootstrap();
|
|
15
40
|
const { args, flags } = yield this.parse(HostMap);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// clusters: []
|
|
26
|
-
// };
|
|
27
|
-
// let scopesAvail = await repo.readMany(FullyQualifiedCabinetScopes, CabinetScopesCriteria, { all: true });
|
|
28
|
-
// let scopesAvailResult = await this._codiacApi.Call.getCabinetScopes({ all: true });
|
|
29
|
-
// if (scopesAvailResult.error) throw scopesAvailResult.error;
|
|
30
|
-
// let scopesAvail = scopesAvailResult.output ?? [];
|
|
31
|
-
// const rootMapResult = await this._codiacApi.Call.getRootMap({ all: true });
|
|
32
|
-
// if (rootMapResult.error) throw rootMapResult.error;
|
|
33
|
-
// if (rootMapResult.output == undefined) throw new Error("No enterprises found.");
|
|
34
|
-
// const rootMap = rootMapResult.output;
|
|
35
|
-
const rootMap = yield this.getRootMap();
|
|
36
|
-
let scopesAvail = yield this.getCabinetScopes(rootMap);
|
|
37
|
-
// this.logger.trace(`EnterpriseScopes: ${scopesAvail.length}`, scopesAvail);
|
|
38
|
-
let domain = (_b = args.domain) !== null && _b !== void 0 ? _b : (yield this._ui.prompt("domain", "Domain: "));
|
|
39
|
-
domain = domain.trim();
|
|
40
|
-
// Get the target scope
|
|
41
|
-
let scope = this.validateGivenTarget(flags, scopesAvail, flags.noninteractive);
|
|
42
|
-
if (!scope) {
|
|
43
|
-
let defLevel = (flags.cabinet) ? "cabinet" : ((flags.environment) ? "environment" : (flags.enterprise ? "enterprise" : undefined));
|
|
44
|
-
let level = yield this._ui.promptSelect("scope", "Scope", ["enterprise", "environment", "cabinet"]); // default = defLevel
|
|
45
|
-
if (!level) {
|
|
46
|
-
this._ui.userMessage("Operation cancelled. No work was done.");
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
// MarkStarthere("Make sure cabinet and environment scopes are fully qualified with enteprise");
|
|
50
|
-
let targets = this.getAvailableTargets(level, scopesAvail);
|
|
51
|
-
if (targets.length == 0) {
|
|
52
|
-
this._ui.userMessage(`No ${level}s were found. Operation cancelled.`);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
let selected = yield this._ui.promptSelect("target", level, targets);
|
|
56
|
-
if (!selected) {
|
|
57
|
-
this._ui.userMessage("Operation cancelled. No work was done.");
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// Parses the fully qualified scope from the target selection
|
|
61
|
-
scope = this.parseSelectedTarget(level, selected);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
let thisMachine = this.isLocalMachine(scope, rootMap);
|
|
67
|
-
// Get the host naming strategy
|
|
68
|
-
let naming;
|
|
69
|
-
if (scope) {
|
|
70
|
-
naming = this.validateGivenNaming(flags.naming, flags.noninteractive);
|
|
71
|
-
if (!naming) {
|
|
72
|
-
const strategies = Object.values(host_name_strategy_enum_1.HostNameStrategyEnum).sort().map(x => {
|
|
73
|
-
return { value: x, name: x.replace(/_dot_/g, ".").replace(/_slash_/g, "/") };
|
|
74
|
-
});
|
|
75
|
-
let selected = yield this._ui.promptSelect("naming", "Host Naming Strategy", strategies);
|
|
76
|
-
if (!selected) {
|
|
77
|
-
this._ui.userMessage("Operation cancelled. No work was done.");
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
naming = selected;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// External/Internal | Public/Private
|
|
85
|
-
let isPrivate = type_safety_utils_1.TypeSafetyUtils.toBoolean(flags.private);
|
|
86
|
-
let keep = yield this._ui.promptConfirm("isPrivateKeep", "Usage: ".concat(this._styler.hilite(isPrivate ? "private" : "external")), true);
|
|
87
|
-
if (!keep) {
|
|
88
|
-
let choices = [{ name: "External (Public DNS)", value: "false" }, { name: "Private (not available on the internet)", value: "true" }];
|
|
89
|
-
let selected = yield this._ui.promptSelect("isPrivate", "Usage:", choices, false, true);
|
|
90
|
-
isPrivate = type_safety_utils_1.TypeSafetyUtils.toBoolean(selected);
|
|
91
|
-
}
|
|
92
|
-
if (scope && naming) {
|
|
93
|
-
this.logger.trace("Scope", scope);
|
|
94
|
-
this.logger.trace("domain", domain);
|
|
95
|
-
this.logger.trace("Naming", naming);
|
|
96
|
-
let preview = yield this.buildPreview(scope, domain, naming, isPrivate);
|
|
97
|
-
this._ui.userMessage("You are about to submit the following domain host mapping strategy: ".concat("\n", preview));
|
|
98
|
-
let confirm = yield this._ui.promptConfirm("confirmGo", "Continue? ", false);
|
|
99
|
-
if (!confirm) {
|
|
100
|
-
this._ui.userMessage("Cancelled. No work was done.");
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
this._ui.startSpinner("Applying domain mapping");
|
|
104
|
-
let result = yield this.genRelayClient.Call.executeDomainUpsert({
|
|
105
|
-
domain: domain.trim(),
|
|
106
|
-
namingStrategy: naming,
|
|
107
|
-
scope: scope.level,
|
|
108
|
-
target: scope.target,
|
|
109
|
-
enterprise: scope.enterprise,
|
|
110
|
-
isPrivate: isPrivate,
|
|
111
|
-
thisMachine: thisMachine
|
|
112
|
-
});
|
|
113
|
-
this._ui.stopSpinner(result.success ? "Completed" : "Failed");
|
|
114
|
-
if (result.success) {
|
|
115
|
-
this._ui.userMessage(`Success!`);
|
|
116
|
-
}
|
|
117
|
-
else if (result.error) {
|
|
118
|
-
this.logger.debug(`Error`, result);
|
|
119
|
-
this._ui.userMessage(`Error: ${result.error.message}`);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
41
|
+
const scopesAvail = yield this.getCabinetScopes(rootMap);
|
|
42
|
+
const domain = ((_a = args.domain) !== null && _a !== void 0 ? _a : (yield this._ui.prompt("domain", "Domain: "))).trim();
|
|
43
|
+
// Get the target scope
|
|
44
|
+
let scope = this.validateGivenTarget(flags, scopesAvail, false);
|
|
45
|
+
if (!scope) {
|
|
46
|
+
const level = yield this._ui.promptSelect("scope", "Scope", ["enterprise", "environment", "cabinet"]);
|
|
47
|
+
if (!level) {
|
|
48
|
+
this._ui.userMessage("Operation cancelled. No work was done.");
|
|
49
|
+
return undefined;
|
|
123
50
|
}
|
|
124
|
-
|
|
125
|
-
|
|
51
|
+
const targets = this.getAvailableTargets(level, scopesAvail);
|
|
52
|
+
if (targets.length === 0) {
|
|
53
|
+
this._ui.userMessage(`No ${level}s were found. Operation cancelled.`);
|
|
54
|
+
return undefined;
|
|
126
55
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
56
|
+
const selected = yield this._ui.promptSelect("target", level, targets);
|
|
57
|
+
if (!selected) {
|
|
58
|
+
this._ui.userMessage("Operation cancelled. No work was done.");
|
|
59
|
+
return undefined;
|
|
130
60
|
}
|
|
131
|
-
|
|
61
|
+
scope = this.parseSelectedTarget(level, selected);
|
|
62
|
+
}
|
|
63
|
+
// Get the host naming strategy
|
|
64
|
+
let naming = this.validateGivenNaming(flags.naming, false);
|
|
65
|
+
if (!naming) {
|
|
66
|
+
const strategies = Object.values(host_name_strategy_enum_1.HostNameStrategyEnum).sort().map(x => ({
|
|
67
|
+
value: x,
|
|
68
|
+
name: x.replace(/_dot_/g, ".").replace(/_slash_/g, "/")
|
|
69
|
+
}));
|
|
70
|
+
const selected = yield this._ui.promptSelect("naming", "Host Naming Strategy", strategies);
|
|
71
|
+
if (!selected) {
|
|
72
|
+
this._ui.userMessage("Operation cancelled. No work was done.");
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
naming = selected;
|
|
76
|
+
}
|
|
77
|
+
// External/Internal
|
|
78
|
+
let isPrivate = type_safety_utils_1.TypeSafetyUtils.toBoolean(flags.private);
|
|
79
|
+
const keep = yield this._ui.promptConfirm("isPrivateKeep", "Usage: ".concat(this._styler.hilite(isPrivate ? "private" : "external")), true);
|
|
80
|
+
if (!keep) {
|
|
81
|
+
const choices = [
|
|
82
|
+
{ name: "External (Public DNS)", value: "false" },
|
|
83
|
+
{ name: "Private (not available on the internet)", value: "true" }
|
|
84
|
+
];
|
|
85
|
+
const selected = yield this._ui.promptSelect("isPrivate", "Usage:", choices, false, true);
|
|
86
|
+
isPrivate = type_safety_utils_1.TypeSafetyUtils.toBoolean(selected);
|
|
87
|
+
}
|
|
88
|
+
const thisMachine = this.isLocalMachine(scope, rootMap);
|
|
89
|
+
const preview = yield this.buildPreview(scope, domain, naming, isPrivate);
|
|
90
|
+
this._ui.userMessage("You are about to submit the following domain host mapping strategy: ".concat("\n", preview));
|
|
91
|
+
const confirm = yield this._ui.promptConfirm("confirmGo", "Continue? ", false);
|
|
92
|
+
if (!confirm) {
|
|
93
|
+
this._ui.userMessage("Cancelled. No work was done.");
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
return { domain, scope, naming, isPrivate, thisMachine };
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
buildCommandString(candidate, cmd) {
|
|
100
|
+
cmd.push(candidate.domain);
|
|
101
|
+
if (candidate.scope.level === "enterprise" && candidate.scope.target)
|
|
102
|
+
cmd.push("-e", candidate.scope.target);
|
|
103
|
+
if (candidate.scope.level === "environment" && candidate.scope.target)
|
|
104
|
+
cmd.push("-v", candidate.scope.target);
|
|
105
|
+
if (candidate.scope.level === "cabinet" && candidate.scope.target)
|
|
106
|
+
cmd.push("-c", candidate.scope.target);
|
|
107
|
+
if (candidate.scope.enterprise)
|
|
108
|
+
cmd.push("-e", candidate.scope.enterprise);
|
|
109
|
+
cmd.push("-n", candidate.naming);
|
|
110
|
+
if (candidate.isPrivate)
|
|
111
|
+
cmd.push("--private");
|
|
112
|
+
cmd.push("--silent");
|
|
113
|
+
return cmd;
|
|
114
|
+
}
|
|
115
|
+
executeTask(candidate) {
|
|
116
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
this._ui.startSpinner("Applying domain mapping");
|
|
118
|
+
const result = yield this.genRelayClient.Call.executeDomainUpsert({
|
|
119
|
+
domain: candidate.domain,
|
|
120
|
+
namingStrategy: candidate.naming,
|
|
121
|
+
scope: candidate.scope.level,
|
|
122
|
+
target: candidate.scope.target,
|
|
123
|
+
enterprise: candidate.scope.enterprise,
|
|
124
|
+
isPrivate: candidate.isPrivate,
|
|
125
|
+
thisMachine: candidate.thisMachine
|
|
126
|
+
});
|
|
127
|
+
this._ui.stopSpinner(result.success ? "Completed" : "Failed");
|
|
128
|
+
if (result.success) {
|
|
129
|
+
this._ui.userMessage(`Success!`);
|
|
130
|
+
}
|
|
131
|
+
else if (result.error) {
|
|
132
|
+
this.logger.debug(`Error`, result);
|
|
133
|
+
this._ui.userMessage(`Error: ${result.error.message}`);
|
|
134
|
+
}
|
|
132
135
|
});
|
|
133
136
|
}
|
|
134
|
-
/** Determines whether the given scope is local machine or not. */
|
|
135
137
|
isLocalMachine(scope, rootMap) {
|
|
136
138
|
let isLocal;
|
|
137
|
-
if (scope &&
|
|
138
|
-
|
|
139
|
+
if (scope && scope.level !== contracts_1.ScopeLevel.enterprise) {
|
|
140
|
+
const ent = rootMap.enterprises.find(e => e.name === scope.enterprise);
|
|
139
141
|
if (ent != undefined) {
|
|
140
142
|
switch (scope.level) {
|
|
141
143
|
case contracts_1.ScopeLevel.environment:
|
|
142
|
-
const env = ent.environments.find(e => e.name
|
|
144
|
+
const env = ent.environments.find(e => e.name === scope.target);
|
|
143
145
|
isLocal = env === null || env === void 0 ? void 0 : env.thisMachine;
|
|
144
146
|
break;
|
|
145
147
|
case contracts_1.ScopeLevel.cabinet:
|
|
146
|
-
for (
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
for (const env of ent.environments) {
|
|
149
|
+
const cab = env.cabinets.find(c => c.name === scope.target);
|
|
150
|
+
if (cab)
|
|
151
|
+
isLocal = cab.thisMachine;
|
|
149
152
|
}
|
|
150
153
|
break;
|
|
151
154
|
}
|
|
@@ -153,28 +156,21 @@ class HostMap extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
153
156
|
}
|
|
154
157
|
return isLocal;
|
|
155
158
|
}
|
|
156
|
-
/** Consider moving this to RootMapUtils. */
|
|
157
159
|
getCabinetScopes(rootMap) {
|
|
158
160
|
var _a;
|
|
159
161
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
160
162
|
try {
|
|
161
|
-
|
|
162
|
-
for (
|
|
163
|
-
|
|
164
|
-
for (
|
|
165
|
-
|
|
166
|
-
let envScope = {
|
|
163
|
+
const scopes = [];
|
|
164
|
+
for (const ent of rootMap.enterprises) {
|
|
165
|
+
const entScope = { id: undefined, name: ent.name, environments: [] };
|
|
166
|
+
for (const env of ent.environments) {
|
|
167
|
+
const envScope = {
|
|
167
168
|
name: env.name,
|
|
168
|
-
cabinets:
|
|
169
|
+
cabinets: env.cabinets.map(c => ({ name: c.name, cluster: c.cluster }))
|
|
169
170
|
};
|
|
170
171
|
entScope.environments.push(envScope);
|
|
171
|
-
// cabs.forEach(c => {
|
|
172
|
-
// if (c.cluster && !scopes.clusters.includes(c.cluster)) scopes.clusters.push(c.cluster);
|
|
173
|
-
// });
|
|
174
172
|
}
|
|
175
173
|
scopes.push(entScope);
|
|
176
|
-
// this.logger.write(`Available scopes: ${scopes.length} enterprises.`);
|
|
177
|
-
// this.logger.write(JSON.stringify(scopes, undefined, 2));
|
|
178
174
|
}
|
|
179
175
|
return scopes;
|
|
180
176
|
}
|
|
@@ -186,27 +182,23 @@ class HostMap extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
186
182
|
}
|
|
187
183
|
buildPreview(scope, domain, naming, isPrivate) {
|
|
188
184
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
let candidate = {
|
|
192
|
-
enterprise: scope.enterprise, domainName: domain, strategy: naming, scope: scope.level, target: scope.target, isPrivate: isPrivate
|
|
185
|
+
const candidate = {
|
|
186
|
+
enterprise: scope.enterprise, domainName: domain, strategy: naming, scope: scope.level, target: scope.target, isPrivate
|
|
193
187
|
};
|
|
194
|
-
return delete_1.HostNameUiLogic.displayNameFor(candidate, this._styler);
|
|
188
|
+
return delete_1.HostNameUiLogic.displayNameFor(candidate, this._styler);
|
|
195
189
|
});
|
|
196
190
|
}
|
|
197
191
|
validateGivenNaming(naming, nonInteractive = false) {
|
|
198
|
-
|
|
199
|
-
if (!selected && nonInteractive)
|
|
192
|
+
const selected = (naming && naming in host_name_strategy_enum_1.HostNameStrategyEnum) ? naming : undefined;
|
|
193
|
+
if (!selected && nonInteractive)
|
|
200
194
|
throw new Error(`Invalid host naming strategy [${naming}].`);
|
|
201
|
-
}
|
|
202
195
|
return selected;
|
|
203
196
|
}
|
|
204
|
-
/** Returns a sorted array of all available scope targets for the given level. */
|
|
205
197
|
getAvailableTargets(level, scopesAvail) {
|
|
206
198
|
let targets = [];
|
|
207
199
|
switch (level) {
|
|
208
200
|
case "enterprise":
|
|
209
|
-
targets = scopesAvail.map(e => e.name);
|
|
201
|
+
targets = scopesAvail.map(e => e.name);
|
|
210
202
|
break;
|
|
211
203
|
case "environment":
|
|
212
204
|
scopesAvail.forEach(e => {
|
|
@@ -233,208 +225,148 @@ class HostMap extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
233
225
|
}
|
|
234
226
|
return targets;
|
|
235
227
|
}
|
|
236
|
-
/** Parses the fully-qualified scope from the selected target,
|
|
237
|
-
* which was built by this.getAvailableTargets().
|
|
238
|
-
*/
|
|
239
228
|
parseSelectedTarget(level, selected) {
|
|
240
|
-
let scope;
|
|
241
229
|
let parts;
|
|
242
230
|
switch (level) {
|
|
243
231
|
case "enterprise":
|
|
244
|
-
|
|
245
|
-
break;
|
|
232
|
+
return { level, target: selected };
|
|
246
233
|
case "environment":
|
|
247
234
|
parts = selected.split("/");
|
|
248
|
-
|
|
249
|
-
level: level,
|
|
250
|
-
target: parts[1],
|
|
251
|
-
enterprise: parts[0]
|
|
252
|
-
};
|
|
253
|
-
break;
|
|
235
|
+
return { level, target: parts[1], enterprise: parts[0] };
|
|
254
236
|
case "cabinet":
|
|
255
237
|
parts = selected.split("/");
|
|
256
|
-
|
|
257
|
-
level: level,
|
|
258
|
-
target: parts[2],
|
|
259
|
-
enterprise: parts[0]
|
|
260
|
-
};
|
|
261
|
-
break;
|
|
238
|
+
return { level, target: parts[2], enterprise: parts[0] };
|
|
262
239
|
}
|
|
263
|
-
return scope;
|
|
264
240
|
}
|
|
265
|
-
/** Returns the requested target by name if it exists in the available scopes.
|
|
266
|
-
* Returns undefined otherwise.
|
|
267
|
-
* Throws on an invalid scopes if not interactive.
|
|
268
|
-
*/
|
|
269
241
|
validateGivenTarget(given, scopesAvail, nonInteractive = false) {
|
|
270
242
|
let scope;
|
|
271
|
-
|
|
272
|
-
if (level)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
if (given.enterprise) { // if they gave us one, it's gotta exist
|
|
283
|
-
target = (scopesAvail.find(e => e.name == given.enterprise)) ? given.enterprise : undefined;
|
|
284
|
-
}
|
|
285
|
-
else if (scopesAvail.length == 1) {
|
|
286
|
-
// if they called for the "only", there can be only one.
|
|
287
|
-
target = scopesAvail[0].name;
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
if (nonInteractive) {
|
|
291
|
-
throw new Error(`Enterprise argument with unspecified value was ambiguous because there are more than one enterprise available.`);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
243
|
+
const level = (given.cabinet) ? "cabinet" : (given.environment) ? "environment" : (given.enterprise) ? "enterprise" : undefined;
|
|
244
|
+
if (!level)
|
|
245
|
+
return undefined;
|
|
246
|
+
let target;
|
|
247
|
+
let enterprise;
|
|
248
|
+
switch (level) {
|
|
249
|
+
case "enterprise":
|
|
250
|
+
if (scopesAvail.length === 0) {
|
|
251
|
+
if (nonInteractive)
|
|
252
|
+
throw new Error(`Cannot scope to the enterprise level because no enterprises currently exist.`);
|
|
294
253
|
break;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
scopesAvail.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
254
|
+
}
|
|
255
|
+
if (given.enterprise) {
|
|
256
|
+
target = scopesAvail.find(e => e.name === given.enterprise) ? given.enterprise : undefined;
|
|
257
|
+
}
|
|
258
|
+
else if (scopesAvail.length === 1) {
|
|
259
|
+
target = scopesAvail[0].name;
|
|
260
|
+
}
|
|
261
|
+
else if (nonInteractive) {
|
|
262
|
+
throw new Error(`Enterprise argument with unspecified value was ambiguous because there is more than one enterprise available.`);
|
|
263
|
+
}
|
|
264
|
+
break;
|
|
265
|
+
case "environment": {
|
|
266
|
+
const envs = [];
|
|
267
|
+
scopesAvail.forEach(ent => {
|
|
268
|
+
ent.environments.forEach(env => {
|
|
269
|
+
if (!envs.find(x => x.ent === ent.name && x.env === env.name))
|
|
270
|
+
envs.push({ ent: ent.name, env: env.name });
|
|
302
271
|
});
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
272
|
+
});
|
|
273
|
+
if (envs.length === 0) {
|
|
274
|
+
if (nonInteractive)
|
|
275
|
+
throw new Error(`Cannot scope to the environment level because no environments currently exist.`);
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
if (given.environment && given.enterprise) {
|
|
279
|
+
if (scopesAvail.find(e => e.name === given.enterprise && e.environments.find(v => v.name === given.environment))) {
|
|
280
|
+
target = given.environment;
|
|
281
|
+
enterprise = given.enterprise;
|
|
307
282
|
}
|
|
308
|
-
|
|
309
|
-
|
|
283
|
+
}
|
|
284
|
+
else if (given.environment) {
|
|
285
|
+
if (scopesAvail.length === 1) {
|
|
286
|
+
if (scopesAvail[0].environments.find(v => v.name === given.environment)) {
|
|
310
287
|
target = given.environment;
|
|
311
|
-
enterprise =
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
else if (given.environment) {
|
|
315
|
-
if (scopesAvail.length == 1) {
|
|
316
|
-
// If there's only one enterprise, and if their env is in it, we're good.
|
|
317
|
-
if (scopesAvail[0].environments.find(v => v.name == given.environment)) {
|
|
318
|
-
target = given.environment;
|
|
319
|
-
enterprise = scopesAvail[0].name;
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
if (nonInteractive) {
|
|
323
|
-
throw new Error(`Environment [${given.environment}] does not exist.`);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
288
|
+
enterprise = scopesAvail[0].name;
|
|
326
289
|
}
|
|
327
|
-
else if (
|
|
328
|
-
|
|
329
|
-
let found = [];
|
|
330
|
-
for (let eScope of scopesAvail) {
|
|
331
|
-
let envFound = eScope.environments.find(env => env.name == given.environment);
|
|
332
|
-
if (envFound)
|
|
333
|
-
found.push({ ent: eScope.name, env: envFound.name });
|
|
334
|
-
}
|
|
335
|
-
if (found.length == 1) {
|
|
336
|
-
target = found[0].env;
|
|
337
|
-
enterprise = found[0].ent;
|
|
338
|
-
}
|
|
339
|
-
else if (found.length > 1) {
|
|
340
|
-
if (nonInteractive) {
|
|
341
|
-
throw new Error(`Environment argument [${given.environment}] with unspecified enterprise value was ambiguous because there are more than one environments with that name.`);
|
|
342
|
-
}
|
|
343
|
-
// Here we should ask them to specify which one. of the ones that were found
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
if (nonInteractive) {
|
|
347
|
-
throw new Error(`Environment [${given.environment}] does not exist.`);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
290
|
+
else if (nonInteractive) {
|
|
291
|
+
throw new Error(`Environment [${given.environment}] does not exist.`);
|
|
350
292
|
}
|
|
351
293
|
}
|
|
352
294
|
else {
|
|
353
|
-
|
|
354
|
-
if (
|
|
355
|
-
target =
|
|
356
|
-
enterprise =
|
|
357
|
-
}
|
|
358
|
-
else if (nonInteractive) {
|
|
359
|
-
throw new Error(`Environment argument with unspecified value was ambiguous because there are more than one environments available.`);
|
|
295
|
+
const found = scopesAvail.flatMap(e => e.environments.filter(v => v.name === given.environment).map(v => ({ ent: e.name, env: v.name })));
|
|
296
|
+
if (found.length === 1) {
|
|
297
|
+
target = found[0].env;
|
|
298
|
+
enterprise = found[0].ent;
|
|
360
299
|
}
|
|
300
|
+
else if (found.length > 1 && nonInteractive)
|
|
301
|
+
throw new Error(`Environment [${given.environment}] was ambiguous across multiple enterprises.`);
|
|
302
|
+
else if (found.length === 0 && nonInteractive)
|
|
303
|
+
throw new Error(`Environment [${given.environment}] does not exist.`);
|
|
361
304
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
305
|
+
}
|
|
306
|
+
else if (envs.length === 1) {
|
|
307
|
+
target = envs[0].env;
|
|
308
|
+
enterprise = envs[0].ent;
|
|
309
|
+
}
|
|
310
|
+
else if (nonInteractive) {
|
|
311
|
+
throw new Error(`Environment argument with unspecified value was ambiguous because there is more than one environment available.`);
|
|
312
|
+
}
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
case "cabinet": {
|
|
316
|
+
const cabs = [];
|
|
317
|
+
scopesAvail.forEach(ent => {
|
|
318
|
+
ent.environments.forEach(env => {
|
|
319
|
+
env.cabinets.forEach(c => {
|
|
320
|
+
if (!cabs.find(exc => exc.name === c.name && exc.enterprise === ent.name))
|
|
321
|
+
cabs.push({ name: c.name, enterprise: ent.name });
|
|
371
322
|
});
|
|
372
323
|
});
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
324
|
+
});
|
|
325
|
+
if (cabs.length === 0) {
|
|
326
|
+
if (nonInteractive)
|
|
327
|
+
throw new Error(`Cannot scope to the cabinet level because no cabinets currently exist.`);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
if (given.cabinet && given.enterprise) {
|
|
331
|
+
if (cabs.find(c => c.enterprise === given.enterprise && c.name === given.cabinet)) {
|
|
332
|
+
target = given.cabinet;
|
|
333
|
+
enterprise = given.enterprise;
|
|
377
334
|
}
|
|
378
|
-
if (
|
|
379
|
-
if (
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
else {
|
|
384
|
-
if (nonInteractive) {
|
|
385
|
-
if (scopesAvail.find(s => s.name == given.enterprise)) {
|
|
386
|
-
throw new Error(`No cabinet [${given.cabinet}] exists in enterprise [${given.enterprise}].`);
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
throw new Error(`Enterprise [${given.enterprise}] does not exist.`);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
335
|
+
else if (nonInteractive) {
|
|
336
|
+
if (scopesAvail.find(s => s.name === given.enterprise))
|
|
337
|
+
throw new Error(`No cabinet [${given.cabinet}] exists in enterprise [${given.enterprise}].`);
|
|
338
|
+
else
|
|
339
|
+
throw new Error(`Enterprise [${given.enterprise}] does not exist.`);
|
|
393
340
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
else if (found.length > 1) {
|
|
402
|
-
if (nonInteractive) {
|
|
403
|
-
throw new Error(`Cabinet argument [${given.cabinet}] with unspecified enterprise value was ambiguous because there are more than one cabinets with that name.`);
|
|
404
|
-
}
|
|
405
|
-
// Here we should ask them to specify which one. of the ones that were found
|
|
406
|
-
}
|
|
407
|
-
else if (found.length == 0) {
|
|
408
|
-
if (nonInteractive) {
|
|
409
|
-
throw new Error(`Cabinet [${given.cabinet}] does not exist.`);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
else {
|
|
414
|
-
// if they called for "the only", then there can be only one.
|
|
415
|
-
if (cabs.length == 1) {
|
|
416
|
-
target = cabs[0].name; // TODO: Consider adding enteprise as prefix
|
|
417
|
-
enterprise = cabs[0].enterprise;
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
if (nonInteractive) {
|
|
421
|
-
throw new Error(`Cabinet argument with unspecified value was ambiguous because there are more than one cabinets available.`);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
341
|
+
}
|
|
342
|
+
else if (given.cabinet) {
|
|
343
|
+
const found = cabs.filter(c => c.name === given.cabinet);
|
|
344
|
+
if (found.length === 1) {
|
|
345
|
+
target = found[0].name;
|
|
346
|
+
enterprise = found[0].enterprise;
|
|
424
347
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
if (nonInteractive) {
|
|
434
|
-
throw new Error(`Invalid scope.`); // logic above should already have caught this scenario. This is here as a double check.
|
|
348
|
+
else if (found.length > 1 && nonInteractive)
|
|
349
|
+
throw new Error(`Cabinet [${given.cabinet}] was ambiguous across multiple enterprises.`);
|
|
350
|
+
else if (found.length === 0 && nonInteractive)
|
|
351
|
+
throw new Error(`Cabinet [${given.cabinet}] does not exist.`);
|
|
352
|
+
}
|
|
353
|
+
else if (cabs.length === 1) {
|
|
354
|
+
target = cabs[0].name;
|
|
355
|
+
enterprise = cabs[0].enterprise;
|
|
435
356
|
}
|
|
357
|
+
else if (nonInteractive) {
|
|
358
|
+
throw new Error(`Cabinet argument with unspecified value was ambiguous because there is more than one cabinet available.`);
|
|
359
|
+
}
|
|
360
|
+
break;
|
|
436
361
|
}
|
|
437
362
|
}
|
|
363
|
+
if (target) {
|
|
364
|
+
scope = { level, target };
|
|
365
|
+
if (enterprise)
|
|
366
|
+
scope.enterprise = enterprise;
|
|
367
|
+
}
|
|
368
|
+
if (!scope && nonInteractive)
|
|
369
|
+
throw new Error(`Invalid scope.`);
|
|
438
370
|
return scope;
|
|
439
371
|
}
|
|
440
372
|
}
|
|
@@ -444,13 +376,20 @@ HostMap.aliases = ['domain:map'];
|
|
|
444
376
|
HostMap.flags = {
|
|
445
377
|
help: core_1.Flags.help({ char: 'h' }),
|
|
446
378
|
naming: core_1.Flags.string({ char: 'n', required: false, description: "The host naming strategy to apply." }),
|
|
447
|
-
enterprise: core_1.Flags.string({ char: 'e', exclusive: ["environment"], description: 'The name of the enterprise on which to apply this naming strategy.
|
|
448
|
-
environment: core_1.Flags.string({ char: 'v',
|
|
449
|
-
cabinet: core_1.Flags.string({ char: 'c',
|
|
379
|
+
enterprise: core_1.Flags.string({ char: 'e', exclusive: ["environment"], description: 'The name of the enterprise on which to apply this naming strategy. Leave blank if there is only one.' }),
|
|
380
|
+
environment: core_1.Flags.string({ char: 'v', exclusive: ["cabinet"], description: 'The name of the environment on which to apply this naming strategy. Must be qualified by also setting enterprise if there are more than one.' }),
|
|
381
|
+
cabinet: core_1.Flags.string({ char: 'c', exclusive: ["environment"], description: 'The name of the cabinet on which to apply this naming strategy. Must be qualified by also setting enterprise if cabinet names are not unique.' }),
|
|
450
382
|
private: core_1.Flags.boolean({ description: "Declares that this domain mapping is for internal use and not available from the internet." }),
|
|
451
|
-
|
|
383
|
+
silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
|
|
384
|
+
echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
|
|
385
|
+
"to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
|
|
452
386
|
};
|
|
453
387
|
HostMap.args = {
|
|
454
|
-
domain: core_1.Args.string({ required: false, description: 'The domain name to route (eg: "my-company.com")' })
|
|
388
|
+
domain: core_1.Args.string({ required: false, description: 'The domain name to route (eg: "my-company.com").' })
|
|
455
389
|
};
|
|
390
|
+
HostMap.examples = [
|
|
391
|
+
{ description: "Map a domain interactively.", command: "<%= config.bin %> <%= command.id %> my-company.com" },
|
|
392
|
+
{ description: "Map an enterprise-level domain.", command: "<%= config.bin %> <%= command.id %> my-company.com -e myEnterprise -n subdomain_dot_cabinet --silent" },
|
|
393
|
+
{ description: "Renders the equivalent silent command without executing.", command: "<%= config.bin %> <%= command.id %> my-company.com -e myEnterprise --to-script" },
|
|
394
|
+
];
|
|
456
395
|
//# sourceMappingURL=map.js.map
|