@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
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const _ = require("lodash");
|
|
6
|
+
const contracts_1 = require("../../../apis/codiac-api/contracts");
|
|
7
|
+
const contracts_2 = require("../../../apis/codiac-relay/contracts");
|
|
8
|
+
const cluster_def_1 = require("@codiac.io/codiac-domain/cluster-def");
|
|
9
|
+
const security_account_1 = require("@codiac.io/codiac-domain/security-account");
|
|
10
|
+
const codiac_ops_common_1 = require("@codiac.io/codiac-ops-common");
|
|
11
|
+
const command_base_exec_tenant_1 = require("../../../command-base-exec-tenant");
|
|
12
|
+
const config_ui_utils_1 = require("../../../uilogic/config-ui-utils");
|
|
13
|
+
const cloud_provider_contextualizer_1 = require("../../../uilogic/cloud-provider-contextualizer");
|
|
14
|
+
const prettify_1 = require("../../../prettify");
|
|
15
|
+
class NocClusterDefine extends command_base_exec_tenant_1.CommandBaseExecTenant {
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Lazy-loaded dependencies
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
get uiCloudPvd() {
|
|
20
|
+
if (this._uiCloudPvd === undefined)
|
|
21
|
+
this._uiCloudPvd = this.ioc.get(cloud_provider_contextualizer_1.CloudProviderContextualizer);
|
|
22
|
+
return this._uiCloudPvd;
|
|
23
|
+
}
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// Bootstrap
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
bootstrap() {
|
|
28
|
+
super.bootstrap();
|
|
29
|
+
cloud_provider_contextualizer_1.CloudProviderContextualizer.bootstrap(this.ioc);
|
|
30
|
+
}
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Lifecycle methods
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
captureArgs() {
|
|
35
|
+
var _a, _b, _c;
|
|
36
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { args, flags } = yield this.parse(NocClusterDefine);
|
|
38
|
+
const partial = {
|
|
39
|
+
name: args.name,
|
|
40
|
+
provider: this.stringToEnum(contracts_2.CloudProviderEnum, flags.provider),
|
|
41
|
+
providerSubscription: flags.providerSubscription,
|
|
42
|
+
providerGroup: flags.resourceGroup,
|
|
43
|
+
locationName: flags.location,
|
|
44
|
+
nodeSpec: flags.nodeSpec,
|
|
45
|
+
startingNodeCount: flags.nodeQty,
|
|
46
|
+
k8sVersion: flags.k8sVersion,
|
|
47
|
+
nodesMin: flags.nodesMin,
|
|
48
|
+
nodesMax: flags.nodesMax,
|
|
49
|
+
subnet: flags.subnet,
|
|
50
|
+
networkPlugin: flags.networkPlugin,
|
|
51
|
+
};
|
|
52
|
+
if (args.name) {
|
|
53
|
+
partial.identitySpec = {
|
|
54
|
+
type: cluster_def_1.ClusterDefConstants.DEFAULT_IDENTITY_TYPE,
|
|
55
|
+
name: cluster_def_1.ClusterDefConstants.buildDefaultIdentityName(args.name),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (flags.identityUserId && flags.identityUserName) {
|
|
59
|
+
partial.identityInstance = new security_account_1.SecurityAccount(flags.identityUserId, flags.identityUserName, flags.identityUserName, flags.identityUserPassword);
|
|
60
|
+
}
|
|
61
|
+
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);
|
|
62
|
+
const takeDefaults = (_c = flags['take-defaults']) !== null && _c !== void 0 ? _c : false;
|
|
63
|
+
return [partial, interactionMode, takeDefaults];
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
buildCandidate_silently(partial, _rootMap) {
|
|
67
|
+
var _a;
|
|
68
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
if (!partial.name)
|
|
70
|
+
throw new Error('Cluster name must be provided.');
|
|
71
|
+
if (!partial.provider)
|
|
72
|
+
throw new Error('--provider must be provided.');
|
|
73
|
+
if (!partial.providerSubscription)
|
|
74
|
+
throw new Error('--providerSubscription must be provided.');
|
|
75
|
+
if (!partial.locationName)
|
|
76
|
+
throw new Error('--location must be provided.');
|
|
77
|
+
if (!partial.nodeSpec)
|
|
78
|
+
throw new Error('--nodeSpec must be provided.');
|
|
79
|
+
if (!partial.startingNodeCount)
|
|
80
|
+
throw new Error('--nodeQty must be provided.');
|
|
81
|
+
if (!partial.providerGroup)
|
|
82
|
+
throw new Error('--resourceGroup must be provided.');
|
|
83
|
+
if (!partial.k8sVersion)
|
|
84
|
+
throw new Error('--k8sVersion must be provided.');
|
|
85
|
+
partial.privateOwner = this.ioc.get(codiac_ops_common_1.UserNameTenantCode).tenantCode;
|
|
86
|
+
partial.identitySpec = (_a = partial.identitySpec) !== null && _a !== void 0 ? _a : { type: contracts_1.SecurityAccountTypeEnum.servicePrincipal, name: '' };
|
|
87
|
+
return partial;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
buildCandidate_interactively(partial, takeDefaults, _rootMap) {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
let candidate = Object.assign({}, partial);
|
|
94
|
+
// Pre-populate from existing record if the cluster is already defined
|
|
95
|
+
if (candidate.name) {
|
|
96
|
+
const existing = yield this.tryLoadExistingDef(candidate.name);
|
|
97
|
+
if (existing) {
|
|
98
|
+
this._ui.userMessage(this._styler.dim(`Loaded existing definition for [${candidate.name}]. Edit to update.`));
|
|
99
|
+
candidate = _.defaultsDeep(candidate, existing);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
let confirmed = false;
|
|
103
|
+
do {
|
|
104
|
+
this._ui.userMessage(this._styler.bold('Define Cluster:'));
|
|
105
|
+
const allPvds = this.cspUiFactory.getAllClusterProviders(this.ioc);
|
|
106
|
+
candidate.provider = yield this.uiCloudPvd.promptForCloudProvider(allPvds, candidate.provider);
|
|
107
|
+
const cspUser = yield this.uiCloudPvd.promptForCloudProviderCreds(this.ioc, candidate.provider, undefined, undefined, undefined, candidate.providerSubscription);
|
|
108
|
+
if (candidate.providerSubscription == undefined && cspUser.subscriptionId) {
|
|
109
|
+
candidate.providerSubscription = cspUser.subscriptionId;
|
|
110
|
+
}
|
|
111
|
+
const regCfg = this.cspUiFactory.create(candidate.provider, this.ioc);
|
|
112
|
+
const def = yield regCfg.defineCluster(candidate, undefined, cspUser.cspTenantId);
|
|
113
|
+
candidate = def.spec;
|
|
114
|
+
if (typeof candidate.startingNodeCount === 'string') {
|
|
115
|
+
candidate.startingNodeCount = Number.parseInt(candidate.startingNodeCount);
|
|
116
|
+
}
|
|
117
|
+
console.clear();
|
|
118
|
+
this._ui.userMessage((0, prettify_1.prettify)(candidate, [(_a = candidate.identityInstance) === null || _a === void 0 ? void 0 : _a.password]));
|
|
119
|
+
this._ui.userMessage('Codiac will save this cluster definition (no infrastructure will be created or modified).');
|
|
120
|
+
confirmed = yield this._ui.promptConfirm('confirmDefine', `Continue? (hit 'N' to edit your input)`, false);
|
|
121
|
+
} while (!confirmed);
|
|
122
|
+
candidate.privateOwner = this.ioc.get(codiac_ops_common_1.UserNameTenantCode).tenantCode;
|
|
123
|
+
candidate.identitySpec = (_b = candidate.identitySpec) !== null && _b !== void 0 ? _b : { type: contracts_1.SecurityAccountTypeEnum.servicePrincipal, name: '' };
|
|
124
|
+
return candidate;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
buildCommandString(candidate, cmd) {
|
|
128
|
+
cmd.push(candidate.name);
|
|
129
|
+
cmd.push('--provider', candidate.provider);
|
|
130
|
+
cmd.push('--providerSubscription', candidate.providerSubscription);
|
|
131
|
+
cmd.push('--resourceGroup', candidate.providerGroup);
|
|
132
|
+
cmd.push('--location', candidate.locationName);
|
|
133
|
+
cmd.push('--nodeSpec', candidate.nodeSpec);
|
|
134
|
+
cmd.push('--nodeQty', candidate.startingNodeCount.toString());
|
|
135
|
+
if (candidate.nodesMin != undefined)
|
|
136
|
+
cmd.push('--nodesMin', candidate.nodesMin.toString());
|
|
137
|
+
if (candidate.nodesMax != undefined)
|
|
138
|
+
cmd.push('--nodesMax', candidate.nodesMax.toString());
|
|
139
|
+
if (candidate.k8sVersion)
|
|
140
|
+
cmd.push('--k8sVersion', candidate.k8sVersion);
|
|
141
|
+
if (candidate.networkPlugin)
|
|
142
|
+
cmd.push('--networkPlugin', candidate.networkPlugin);
|
|
143
|
+
if (candidate.subnet && !_.isEmpty(candidate.subnet)) {
|
|
144
|
+
(typeof candidate.subnet === 'string' ? [candidate.subnet] : candidate.subnet)
|
|
145
|
+
.forEach(s => cmd.push('--subnet', s));
|
|
146
|
+
}
|
|
147
|
+
if (candidate.identityInstance) {
|
|
148
|
+
cmd.push('--identityUserName', candidate.identityInstance.name);
|
|
149
|
+
cmd.push('--identityUserId', candidate.identityInstance.id);
|
|
150
|
+
if (candidate.identityInstance.password)
|
|
151
|
+
cmd.push('--identityUserPassword', candidate.identityInstance.password);
|
|
152
|
+
}
|
|
153
|
+
cmd.push('--silent');
|
|
154
|
+
return cmd;
|
|
155
|
+
}
|
|
156
|
+
executeTask(candidate) {
|
|
157
|
+
var _a, _b, _c;
|
|
158
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const result = yield this.genRelayClient.Call.clusterDefine({ spec: candidate });
|
|
160
|
+
if (result.error) {
|
|
161
|
+
const msg = `Error defining cluster [${candidate.name}]: ${(_a = result.message) !== null && _a !== void 0 ? _a : ''} ${(_b = result.error.message) !== null && _b !== void 0 ? _b : ''}`.trimEnd();
|
|
162
|
+
this.logger.error(msg, result.error);
|
|
163
|
+
this._ui.userMessage(`${this._styler.colorCritical('ERROR!')} ${msg}`);
|
|
164
|
+
}
|
|
165
|
+
else if (!result.success) {
|
|
166
|
+
const msg = `Cluster define failed for [${candidate.name}]: ${(_c = result.message) !== null && _c !== void 0 ? _c : ''}`.trimEnd();
|
|
167
|
+
this.logger.notice(msg, result);
|
|
168
|
+
this._ui.userMessage(`${this._styler.colorCritical('FAILED!')} ${msg}`);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
this._ui.userMessage(`${this._styler.colorGood('SUCCESS!')} Cluster [${this._styler.hilite(candidate.name)}] defined. ` +
|
|
172
|
+
`Run \`cod noc cluster restore ${candidate.name}\` to provision and bootstrap it.`);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
// Helpers
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
/** Attempts to load an existing ClusterDef by name. Returns undefined if not found. */
|
|
180
|
+
tryLoadExistingDef(clusterName) {
|
|
181
|
+
var _a;
|
|
182
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
try {
|
|
184
|
+
const found = yield this._codiacApi.ClusterDef.tryReadMany({
|
|
185
|
+
name: { $eq: clusterName },
|
|
186
|
+
privateOwner: this._userCntx.currentTenantCode,
|
|
187
|
+
});
|
|
188
|
+
return (_a = found.output) === null || _a === void 0 ? void 0 : _a[0];
|
|
189
|
+
}
|
|
190
|
+
catch (_b) {
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
stringToEnum(enumObj, str) {
|
|
196
|
+
if (str === undefined)
|
|
197
|
+
return undefined;
|
|
198
|
+
return Object.values(enumObj).includes(str) ? str : undefined;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.default = NocClusterDefine;
|
|
202
|
+
NocClusterDefine.description = 'Creates or updates a cluster metadata record (ClusterDef) without provisioning any physical infrastructure. ' +
|
|
203
|
+
'Use this to register a cluster definition before running `cod noc cluster restore`, or to update metadata ' +
|
|
204
|
+
'on a cluster that has no live instance. If the cluster already has a running instance, destroy it first ' +
|
|
205
|
+
'(`cod cluster destroy <name>`), then redefine.';
|
|
206
|
+
NocClusterDefine.aliases = ['cluster:define'];
|
|
207
|
+
NocClusterDefine.examples = [
|
|
208
|
+
{
|
|
209
|
+
description: 'Define a cluster interactively.',
|
|
210
|
+
command: '<%= config.bin %> <%= command.id %>',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
description: 'Define an Azure cluster non-interactively.',
|
|
214
|
+
command: '<%= config.bin %> <%= command.id %> my-cluster --provider azure --providerSubscription <sub-id> --resourceGroup my-rg --location eastus --nodeSpec Standard_D4s_v3 --nodeQty 3 --k8sVersion 1.29.0 --silent',
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
description: 'Renders the equivalent silent command and then executes.',
|
|
218
|
+
command: '<%= config.bin %> <%= command.id %> my-cluster --echo',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
description: 'Renders the equivalent silent command without executing.',
|
|
222
|
+
command: '<%= config.bin %> <%= command.id %> my-cluster --to-script',
|
|
223
|
+
},
|
|
224
|
+
];
|
|
225
|
+
NocClusterDefine.flags = {
|
|
226
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
227
|
+
provider: core_1.Flags.string({
|
|
228
|
+
options: [contracts_2.CloudProviderEnum.azure, contracts_2.CloudProviderEnum.aws, contracts_2.CloudProviderEnum.localMachine],
|
|
229
|
+
description: 'Cloud service provider on which the cluster resides or will reside.',
|
|
230
|
+
}),
|
|
231
|
+
providerSubscription: core_1.Flags.string({
|
|
232
|
+
char: 's',
|
|
233
|
+
description: 'The cloud provider subscription Id (Azure) or account Id (AWS) for the cluster.',
|
|
234
|
+
}),
|
|
235
|
+
resourceGroup: core_1.Flags.string({
|
|
236
|
+
char: 'g',
|
|
237
|
+
description: '(Azure only) The resource group associated with the cluster.',
|
|
238
|
+
}),
|
|
239
|
+
location: core_1.Flags.string({
|
|
240
|
+
char: 'l',
|
|
241
|
+
description: 'The short name of the regional data center where the cluster resides.',
|
|
242
|
+
}),
|
|
243
|
+
nodeSpec: core_1.Flags.string({
|
|
244
|
+
char: 'n',
|
|
245
|
+
description: 'The VM size used for cluster nodes.',
|
|
246
|
+
}),
|
|
247
|
+
nodeQty: core_1.Flags.integer({
|
|
248
|
+
char: 'q',
|
|
249
|
+
default: 2,
|
|
250
|
+
description: 'Starting node count recorded in the cluster definition.',
|
|
251
|
+
}),
|
|
252
|
+
k8sVersion: core_1.Flags.string({
|
|
253
|
+
description: 'The version of Kubernetes the cluster runs.',
|
|
254
|
+
}),
|
|
255
|
+
nodesMin: core_1.Flags.integer({
|
|
256
|
+
description: 'Minimum number of nodes for autoscaling.',
|
|
257
|
+
}),
|
|
258
|
+
nodesMax: core_1.Flags.integer({
|
|
259
|
+
description: 'Maximum number of nodes for autoscaling.',
|
|
260
|
+
}),
|
|
261
|
+
subnet: core_1.Flags.string({
|
|
262
|
+
char: 'k',
|
|
263
|
+
multiple: true,
|
|
264
|
+
description: '(Optional) Resource Id of the subnet in which the cluster was or will be created.',
|
|
265
|
+
}),
|
|
266
|
+
networkPlugin: core_1.Flags.string({
|
|
267
|
+
description: '(Optional) Network plugin for the cluster.',
|
|
268
|
+
options: ['kubenet', 'azure'],
|
|
269
|
+
}),
|
|
270
|
+
identityUserName: core_1.Flags.string({
|
|
271
|
+
char: 'u',
|
|
272
|
+
description: '(Optional) Name of the Service Principal or Managed Identity the cluster executes as.',
|
|
273
|
+
}),
|
|
274
|
+
identityUserId: core_1.Flags.string({
|
|
275
|
+
description: '(Optional) Id of the Service Principal or Managed Identity the cluster executes as.',
|
|
276
|
+
}),
|
|
277
|
+
identityUserPassword: core_1.Flags.string({
|
|
278
|
+
char: 'c',
|
|
279
|
+
hidden: true,
|
|
280
|
+
description: '(Optional) Password of the Service Principal or Managed Identity the cluster executes as.',
|
|
281
|
+
}),
|
|
282
|
+
silent: core_1.Flags.boolean({
|
|
283
|
+
exclusive: ['echo', 'to-script'],
|
|
284
|
+
description: 'Executes without any user interaction; fails on missing or invalid arguments.',
|
|
285
|
+
relationships: [
|
|
286
|
+
{ type: 'all', flags: ['k8sVersion', 'provider', 'providerSubscription', 'location', 'nodeSpec', 'nodeQty', 'resourceGroup'] },
|
|
287
|
+
],
|
|
288
|
+
}),
|
|
289
|
+
echo: core_1.Flags.boolean({
|
|
290
|
+
exclusive: ['to-script', 'silent'],
|
|
291
|
+
description: 'Renders the equivalent non-interactive command for future use before executing.',
|
|
292
|
+
}),
|
|
293
|
+
'to-script': core_1.Flags.boolean({
|
|
294
|
+
exclusive: ['echo', 'silent'],
|
|
295
|
+
description: 'Renders the equivalent non-interactive command without executing it.',
|
|
296
|
+
}),
|
|
297
|
+
'take-defaults': core_1.Flags.boolean({
|
|
298
|
+
exclusive: ['silent'],
|
|
299
|
+
description: 'Prevents prompting for confirmation on parameters that were passed in or automatically set to default values.',
|
|
300
|
+
}),
|
|
301
|
+
};
|
|
302
|
+
NocClusterDefine.args = {
|
|
303
|
+
name: core_1.Args.string({ description: 'Name of the cluster to define or update.' }),
|
|
304
|
+
};
|
|
305
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../../../src/commands/noc/cluster/define.ts"],"names":[],"mappings":";;;AAAA,sCAAmD;AACnD,4BAA6B;AAE7B,kEAAyF;AACzF,oEAAyE;AACzE,sEAA2E;AAC3E,gFAA4E;AAC5E,oEAAkE;AAClE,gFAA0E;AAC1E,sEAAoE;AACpE,kGAA6F;AAC7F,gDAA6C;AAI7C,MAAqB,gBAAiB,SAAQ,gDAAiC;IAkH7E,8EAA8E;IAC9E,2BAA2B;IAC3B,8EAA8E;IAE9E,IAAY,UAAU;QACpB,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAA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C;IAEF,MAAM,EAAE,YAAK,CAAC,OAAO,CAAC;QACpB,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;QAChC,WAAW,EAAE,+EAA+E;QAC5F,aAAa,EAAE;YACb,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,CAAC,EAAE;SAC/H;KACF,CAAC;IACF,IAAI,EAAE,YAAK,CAAC,OAAO,CAAC;QAClB,SAAS,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC;QAClC,WAAW,EAAE,iFAAiF;KAC/F,CAAC;IACF,WAAW,EAAE,YAAK,CAAC,OAAO,CAAC;QACzB,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;QAC7B,WAAW,EAAE,sEAAsE;KACpF,CAAC;IACF,eAAe,EAAE,YAAK,CAAC,OAAO,CAAC;QAC7B,SAAS,EAAE,CAAC,QAAQ,CAAC;QACrB,WAAW,EAAE,+GAA+G;KAC7H,CAAC;CACH,CAAC;AAEK,qBAAI,GAAG;IACZ,IAAI,EAAE,WAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;CAC/E,CAAC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { CloudProviderEnum } from '../../../apis/codiac-api/contracts';
|
|
3
|
+
import { CommandBaseExecTenant } from '../../../command-base-exec-tenant';
|
|
4
|
+
import { RootMap } from '../../../apis/codiac-api/contracts';
|
|
5
|
+
import { InteractionModes } from '../../../uilogic/config-ui-utils';
|
|
6
|
+
type ClusterDeinitRequest = {
|
|
7
|
+
cluster: {
|
|
8
|
+
name: string;
|
|
9
|
+
provider: CloudProviderEnum;
|
|
10
|
+
providerSubscription?: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default class NocClusterDeinit extends CommandBaseExecTenant<ClusterDeinitRequest> {
|
|
4
14
|
static description: string;
|
|
5
15
|
static aliases: string[];
|
|
6
16
|
static flags: {
|
|
@@ -8,9 +18,16 @@ export default class NocClusterDeinit extends CommandBaseEnterprise {
|
|
|
8
18
|
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
19
|
provider: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
20
|
silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
22
|
+
"to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
23
|
};
|
|
12
24
|
static args: {};
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
static examples: Command.Example[];
|
|
26
|
+
captureArgs(): Promise<[Partial<ClusterDeinitRequest>, InteractionModes | undefined, boolean]>;
|
|
27
|
+
buildCandidate_silently(_partial: Partial<ClusterDeinitRequest>, _rootMap: RootMap): Promise<ClusterDeinitRequest | undefined>;
|
|
28
|
+
buildCandidate_interactively(_partial: Partial<ClusterDeinitRequest>, _takeDefaults: boolean, _rootMap: RootMap): Promise<ClusterDeinitRequest | undefined>;
|
|
29
|
+
buildCommandString(candidate: ClusterDeinitRequest, cmd: string[]): string[];
|
|
30
|
+
executeTask(candidate: ClusterDeinitRequest): Promise<void>;
|
|
15
31
|
private describe;
|
|
16
32
|
}
|
|
33
|
+
export {};
|
|
@@ -1,115 +1,103 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
require("reflect-metadata");
|
|
5
4
|
const core_1 = require("@oclif/core");
|
|
6
5
|
const contracts_1 = require("../../../apis/codiac-api/contracts");
|
|
7
|
-
const
|
|
8
|
-
const command_base_enterprise_1 = require("../../../command-base-enterprise");
|
|
6
|
+
const command_base_exec_tenant_1 = require("../../../command-base-exec-tenant");
|
|
9
7
|
const type_safety_utils_1 = require("../../../uilogic/type-safety-utils");
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const config_ui_utils_1 = require("../../../uilogic/config-ui-utils");
|
|
9
|
+
class NocClusterDeinit extends command_base_exec_tenant_1.CommandBaseExecTenant {
|
|
10
|
+
captureArgs() {
|
|
11
|
+
var _a, _b;
|
|
12
12
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
let def = clusterDefs.find(c => c.name === name);
|
|
66
|
-
cluster = { name: name, provider: def.provider, providerSubscription: def.providerSubscription };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
confirm = yield this._ui.promptConfirm("confirmDeinit", `Deinitialize the cluster: ${this._styler.hilite(this.describe(cluster))} ? `, false);
|
|
70
|
-
if (!confirm)
|
|
71
|
-
candidate = {}; // if cluster was set as a cmd flag, but they denied the confirm, this allows selecting a different one.
|
|
72
|
-
} while (confirm !== true);
|
|
73
|
-
}
|
|
74
|
-
if (cluster) {
|
|
75
|
-
if (confirm == true || flags.silent) {
|
|
76
|
-
if (!flags.silent) {
|
|
77
|
-
yield this.cspContextualizer.promptForCloudProviderCreds(this.ioc, cluster.provider, undefined, undefined, undefined, cluster.providerSubscription);
|
|
78
|
-
}
|
|
79
|
-
// this._ui.startSpinner(`Deinitializing cluster: ${this._styler.hilite(cluster.name)}`);
|
|
80
|
-
// let resultIngress = await this.genRelayClient.Call.clusterDeinit({ clusterName: cluster.name });
|
|
81
|
-
// this._ui.stopSpinner(resultIngress.success ? "SUCCESS" : "FAILED");
|
|
82
|
-
const result = yield this.watcher.triggerAndWatch((correlationId, socketId) => this.genRelayClient.Call.clusterDeinit({ spec: { clusterName: cluster.name }, socketId: socketId, correlationId: correlationId }) // Assertion ok - verified above
|
|
83
|
-
);
|
|
84
|
-
let msg = `Cluster Deinitialize ${result.success ? "SUCCESS" : "FAILED"}: ${result.message || ""}`;
|
|
85
|
-
this.logger.debug(msg, result);
|
|
86
|
-
this._ui.userMessage(msg);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
this._ui.userMessage("Operation cancelled. No work was done.");
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
catch (err) {
|
|
94
|
-
this.handleError(err);
|
|
95
|
-
}
|
|
96
|
-
finally {
|
|
97
|
-
yield this.closeConnections();
|
|
98
|
-
resolve();
|
|
99
|
-
}
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
102
|
-
catch (err) {
|
|
103
|
-
this.handleError(err);
|
|
13
|
+
const { flags } = yield this.parse(NocClusterDeinit);
|
|
14
|
+
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);
|
|
15
|
+
return [{}, interactionMode, false];
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
buildCandidate_silently(_partial, _rootMap) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const { flags } = yield this.parse(NocClusterDeinit);
|
|
22
|
+
if (!flags.name)
|
|
23
|
+
throw new Error(`Cluster name (--name / -n) is required in silent mode.`);
|
|
24
|
+
const provider = (flags.provider) ? type_safety_utils_1.TypeSafetyUtils.toEnum(contracts_1.CloudProviderEnum, flags.provider) : undefined;
|
|
25
|
+
if (!provider)
|
|
26
|
+
throw new Error(`Cloud provider (--provider / -p) is required in silent mode.`);
|
|
27
|
+
const crit = { privateOwner: (_a = this._userCntx) === null || _a === void 0 ? void 0 : _a.currentTenantCode };
|
|
28
|
+
const projection = { pathsIncluded: ["id", "name", "provider", "providerSubscription", "locationName", "privateOwner", "instance"], pathsExcluded: [] };
|
|
29
|
+
const readResult = yield this._codiacApi.ClusterDef.tryReadMany(crit, { projection: projection });
|
|
30
|
+
const clusterDefs = ((_b = readResult.output) !== null && _b !== void 0 ? _b : []).map(c => c).filter(c => c.instance != undefined);
|
|
31
|
+
const found = clusterDefs.find(c => c.name === flags.name && c.provider === provider);
|
|
32
|
+
if (!found)
|
|
33
|
+
throw new Error(`Cluster [${flags.name}] not found for provider [${provider}].`);
|
|
34
|
+
return { cluster: { name: found.name, provider: found.provider, providerSubscription: found.providerSubscription } };
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
buildCandidate_interactively(_partial, _takeDefaults, _rootMap) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const { flags } = yield this.parse(NocClusterDeinit);
|
|
41
|
+
const provider = (flags.provider) ? type_safety_utils_1.TypeSafetyUtils.toEnum(contracts_1.CloudProviderEnum, flags.provider) : undefined;
|
|
42
|
+
const crit = { privateOwner: (_a = this._userCntx) === null || _a === void 0 ? void 0 : _a.currentTenantCode };
|
|
43
|
+
const projection = { pathsIncluded: ["id", "name", "provider", "providerSubscription", "locationName", "privateOwner", "instance"], pathsExcluded: [] };
|
|
44
|
+
const readResult = yield this._codiacApi.ClusterDef.tryReadMany(crit, { projection: projection });
|
|
45
|
+
let clusterDefs = ((_b = readResult.output) !== null && _b !== void 0 ? _b : []).map(c => c).filter(c => c.instance != undefined);
|
|
46
|
+
if (type_safety_utils_1.TypeSafetyUtils.isEnum(contracts_1.CloudProviderEnum, provider)) {
|
|
47
|
+
clusterDefs = clusterDefs.filter(c => c.provider === provider);
|
|
48
|
+
}
|
|
49
|
+
if (readResult.error === undefined && clusterDefs.length === 0) {
|
|
50
|
+
this._ui.userMessage("No clusters exist with instances to deinitialize.");
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
let cluster;
|
|
54
|
+
let confirmed = false;
|
|
55
|
+
const candidate = {};
|
|
56
|
+
if (flags.name)
|
|
57
|
+
candidate.name = flags.name;
|
|
58
|
+
do {
|
|
59
|
+
if (readResult.error) {
|
|
60
|
+
const allPvds = this.cspUiFactory.getAllClusterProviders(this.ioc);
|
|
61
|
+
const csp = yield this.cspContextualizer.promptForCloudProvider(allPvds, undefined);
|
|
62
|
+
const name = (yield this._ui.prompt("clusterName", "Name of the cluster to deinitialize:", true));
|
|
63
|
+
const subx = (yield this._ui.prompt("clusterSubx", (csp === contracts_1.CloudProviderEnum.aws ? "AccountId" : "SubscriptionId").concat(" of the cluster to deinitialize:"), true));
|
|
64
|
+
cluster = { name, provider: csp, providerSubscription: subx };
|
|
104
65
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
66
|
+
else {
|
|
67
|
+
const found = candidate.name ? clusterDefs.find(c => c.name === candidate.name) : undefined;
|
|
68
|
+
if (found) {
|
|
69
|
+
cluster = found;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const choices = clusterDefs.map(c => ({ name: this.describe(c), value: c.name }));
|
|
73
|
+
const name = (yield this._ui.promptSelect("clusterName", "Select the cluster to deinitialize:", choices));
|
|
74
|
+
const def = clusterDefs.find(c => c.name === name);
|
|
75
|
+
cluster = { name, provider: def.provider, providerSubscription: def.providerSubscription };
|
|
76
|
+
}
|
|
108
77
|
}
|
|
109
|
-
|
|
78
|
+
confirmed = yield this._ui.promptConfirm("confirmDeinit", `Deinitialize the cluster: ${this._styler.hilite(this.describe(cluster))} ?`, false);
|
|
79
|
+
if (!confirmed)
|
|
80
|
+
candidate.name = undefined;
|
|
81
|
+
} while (!confirmed);
|
|
82
|
+
yield this.cspContextualizer.promptForCloudProviderCreds(this.ioc, cluster.provider, undefined, undefined, undefined, cluster.providerSubscription);
|
|
83
|
+
return { cluster: cluster };
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
buildCommandString(candidate, cmd) {
|
|
87
|
+
cmd.push("-n", candidate.cluster.name);
|
|
88
|
+
cmd.push("-p", candidate.cluster.provider);
|
|
89
|
+
cmd.push("--silent");
|
|
90
|
+
return cmd;
|
|
91
|
+
}
|
|
92
|
+
executeTask(candidate) {
|
|
93
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const { cluster } = candidate;
|
|
95
|
+
const result = yield this.watcher.triggerAndWatch((correlationId, socketId) => this.genRelayClient.Call.clusterDeinit({ spec: { clusterName: cluster.name }, socketId, correlationId }));
|
|
96
|
+
const msg = `Cluster Deinitialize ${result.success ? "SUCCESS" : "FAILED"}: ${result.message || ""}`;
|
|
97
|
+
this.logger.debug(msg, result);
|
|
98
|
+
this._ui.userMessage(msg);
|
|
110
99
|
});
|
|
111
100
|
}
|
|
112
|
-
/** Renders a user-friendly cluster description. */
|
|
113
101
|
describe(cluster) {
|
|
114
102
|
return `${cluster.name} ${this._styler.dim("(" + cluster.provider + (cluster.locationName ? ", " + cluster.locationName : "") + ")")}`;
|
|
115
103
|
}
|
|
@@ -119,11 +107,16 @@ NocClusterDeinit.description = 'Deinitialization of the cluster (uninstalls the
|
|
|
119
107
|
NocClusterDeinit.aliases = ["cluster:deinit"];
|
|
120
108
|
NocClusterDeinit.flags = {
|
|
121
109
|
help: core_1.Flags.help({ char: 'h' }),
|
|
122
|
-
name: core_1.Flags.string({ char: 'n', required: false, description: 'Name of the cluster.' }),
|
|
110
|
+
name: core_1.Flags.string({ char: 'n', required: false, description: 'Name of the cluster to deinitialize.' }),
|
|
123
111
|
provider: core_1.Flags.string({ char: 'p', options: Object.keys(contracts_1.CloudProviderEnum), required: false, description: 'Code for the cloud service provider.' }),
|
|
124
|
-
silent: core_1.Flags.boolean({
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// name: Args.string({ description: 'Name of existing cluster.' })
|
|
112
|
+
silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
|
|
113
|
+
echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
|
|
114
|
+
"to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
|
|
128
115
|
};
|
|
116
|
+
NocClusterDeinit.args = {};
|
|
117
|
+
NocClusterDeinit.examples = [
|
|
118
|
+
{ description: "Deinitialize a cluster interactively.", command: "<%= config.bin %> <%= command.id %>" },
|
|
119
|
+
{ description: "Non-interactive invocation.", command: "<%= config.bin %> <%= command.id %> -n my-cluster --silent" },
|
|
120
|
+
{ description: "Renders the equivalent silent command without executing.", command: "<%= config.bin %> <%= command.id %> -n my-cluster --to-script" },
|
|
121
|
+
];
|
|
129
122
|
//# sourceMappingURL=deinit.js.map
|