@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
package/dist/commands/deploy.js
CHANGED
|
@@ -5,432 +5,311 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
require("reflect-metadata");
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
7
7
|
const _ = require("lodash");
|
|
8
|
-
// const autocomplete = require("inquirer-autocomplete-prompt");
|
|
9
8
|
const autocomplete = require("inquirer-autocomplete-prompt");
|
|
10
9
|
const inquirer = require("inquirer");
|
|
11
|
-
// import inquirer = require('inquirer');
|
|
12
10
|
const fuzzy = require("fuzzy");
|
|
13
11
|
const contracts_1 = require("@codiac.io/codiac-common/contracts");
|
|
14
|
-
const
|
|
15
|
-
const command_base_enterprise_1 = require("../command-base-enterprise");
|
|
12
|
+
const command_base_exec_1 = require("../command-base-exec");
|
|
16
13
|
const cloud_provider_contextualizer_1 = require("../uilogic/cloud-provider-contextualizer");
|
|
17
|
-
|
|
14
|
+
const config_ui_utils_1 = require("../uilogic/config-ui-utils");
|
|
15
|
+
let assetVersionChoices = [];
|
|
18
16
|
/** The value provided as input that indicates
|
|
19
17
|
* a user's desire to be prompted with a list from which choose the value(s),
|
|
20
18
|
* instead of entering them manually or taking a default. */
|
|
21
19
|
exports.PROMPT_ME_DESIGNATOR = "?";
|
|
22
20
|
exports.PROMPT_ME_DESIGNATOR_MACOS = "??";
|
|
23
|
-
class Deploy extends
|
|
24
|
-
// private get helmClient(): HelmController {
|
|
25
|
-
// if (this.__helmClient === undefined) {
|
|
26
|
-
// this.__helmClient = new HelmController(this._ui, this.logger);
|
|
27
|
-
// }
|
|
28
|
-
// return this.__helmClient;
|
|
29
|
-
// };
|
|
30
|
-
// private __helmClient: HelmController | undefined;
|
|
21
|
+
class Deploy extends command_base_exec_1.CommandBaseExec {
|
|
31
22
|
bootstrap() {
|
|
32
23
|
super.bootstrap();
|
|
33
24
|
cloud_provider_contextualizer_1.CloudProviderContextualizer.bootstrap(this.ioc);
|
|
34
25
|
}
|
|
35
|
-
|
|
26
|
+
captureArgs() {
|
|
27
|
+
var _a, _b;
|
|
36
28
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.__ui = new ops_1.ThrowingUserInputProvider(this.logger);
|
|
48
|
-
this._userCntx = yield this.establishTenantContext(this._userCntx);
|
|
49
|
-
let rootMap = yield this.getRootMap();
|
|
50
|
-
const interactionMode = this.getInteractionMode(flags.silent, flags.echo, flags['to-script']);
|
|
51
|
-
let enterprise = (yield this.establishEnterpriseContext(rootMap, flags.enterpriseCode, interactionMode)).enterprise;
|
|
52
|
-
_.remove(rootMap.enterprises, e => e.name != enterprise.name); // trim down to match legacy conditions
|
|
53
|
-
let enterpriseCode = enterprise.name;
|
|
54
|
-
// Select the asset(s) to deploy
|
|
55
|
-
let assetVersions;
|
|
56
|
-
if (flags.asset == exports.PROMPT_ME_DESIGNATOR
|
|
57
|
-
|| flags.asset == exports.PROMPT_ME_DESIGNATOR_MACOS
|
|
58
|
-
|| flags.asset
|
|
59
|
-
|| this._projCfg === undefined) {
|
|
60
|
-
if (flags.silent && flags.asset && flags.version)
|
|
61
|
-
assetVersions = [{ a: flags.asset, v: flags.version, t: (_b = flags.tagAsset) !== null && _b !== void 0 ? _b : undefined }];
|
|
62
|
-
else {
|
|
63
|
-
let asset = yield this.promptForAsset(enterpriseCode, (flags.asset == exports.PROMPT_ME_DESIGNATOR || flags.asset == exports.PROMPT_ME_DESIGNATOR_MACOS) ? undefined : flags.asset);
|
|
64
|
-
let selected = yield this.promptForVersion(enterpriseCode, asset, flags.version);
|
|
65
|
-
if (flags.tagAsset && flags.tagAsset.length > 0)
|
|
66
|
-
selected.t = flags.tagAsset; // ?? this.promptForTags()
|
|
67
|
-
// if (flags.labels && flags.labels.length > 0) selected.l = this.parseToDictionary(flags.labels); // ?? this.promptForLabels()
|
|
68
|
-
assetVersions = [selected];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
// USE ASSET IN PROJECT SCOPE
|
|
73
|
-
// Update sync codiac with what we've got here in the project.
|
|
74
|
-
let requestedAssets = yield this.establishAssetContext(enterprise, flags.silent);
|
|
75
|
-
let versions = yield this.declareAssetVersions(requestedAssets, enterpriseCode, this._projCfg.codeVersion);
|
|
76
|
-
// We've updated Codiac. Now trigger the deploy.
|
|
77
|
-
assetVersions = requestedAssets.map(a => {
|
|
78
|
-
let version = versions.find(v => v.assetName == a);
|
|
79
|
-
let av = { a: a, v: version ? version.assetVersion : undefined };
|
|
80
|
-
if (flags.tagAsset && flags.tagAsset.length > 0)
|
|
81
|
-
av.t = flags.tagAsset;
|
|
82
|
-
// if (flags.labels && flags.labels.length > 0) av.l = this.parseToDictionary(flags.labels); // ?? this.promptForLabels()
|
|
83
|
-
return av;
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
let cabCntx;
|
|
87
|
-
let cabCluster;
|
|
88
|
-
if (flags.tag != undefined) {
|
|
89
|
-
let selector = {
|
|
90
|
-
enterprise: enterprise.name,
|
|
91
|
-
tags: flags.tag
|
|
92
|
-
};
|
|
93
|
-
if (flags.tagMatch != undefined) {
|
|
94
|
-
if (["any", "all", "none"].includes(flags.tagMatch) != true) {
|
|
95
|
-
throw new Error("tagMatch must be one of: 'any', 'all', or 'none'.");
|
|
96
|
-
}
|
|
97
|
-
selector.matchTags = flags.tagMatch;
|
|
98
|
-
}
|
|
99
|
-
let cabRes = yield this.genRelayClient.Call.GetCabinets(selector);
|
|
100
|
-
if (cabRes.output && cabRes.output.length > 0) {
|
|
101
|
-
if (cabRes.output.length > 1) {
|
|
102
|
-
this.logger.detail("Found multiple cabinets matching deployment request; selecting the first of ".concat(cabRes.output.length.toString()));
|
|
103
|
-
}
|
|
104
|
-
let cab = cabRes.output[0];
|
|
105
|
-
cabCntx = Object.assign(Object.assign({}, _.pick(cab, "enterprise", "environment")), { cabinet: cab.name });
|
|
106
|
-
cabCluster = cab.cluster;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
throw new Error("No matching cabinets were found.");
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
let cabinet = yield this.establishCabinet(flags.cabinetName, flags.silent);
|
|
114
|
-
cabCntx = { enterprise: cabinet.enterpriseCode, environment: cabinet.environment, cabinet: cabinet.name };
|
|
115
|
-
cabCluster = cabinet.cluster;
|
|
116
|
-
}
|
|
117
|
-
// Get the clusterdef so we can get cloud pvd creds
|
|
118
|
-
let cluster = cabCluster !== null && cabCluster !== void 0 ? cabCluster : ((rootMap.clusters.length === 1) ? rootMap.clusters[0].name : undefined); // fall back to the one and only.
|
|
119
|
-
if (cluster === undefined) {
|
|
120
|
-
this.logger.warn(`Cannot confirm cloud provider credentials: cabinet has no cluster specified. Process will rely on cached credentials.`);
|
|
121
|
-
// throw new Error(`Cannot determine cloud provider: cabinet has no cluster specified.`);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
yield this.establishCloudProviderCreds(rootMap, cluster, flags.silent, flags.providerUserName, flags.providerPassword);
|
|
125
|
-
}
|
|
126
|
-
// COMMENTED OUT BC the relay service uses the k8s api client, which isnt bound to the singleton kubeconfig file.
|
|
127
|
-
// if (!cabinet.cluster) throw new Error(`The current cabinet record [${cabinet.name}] does not have a cluster reference.`);
|
|
128
|
-
// let kubeCntx = await this.establishK8sContext(cabinet.cluster);
|
|
129
|
-
yield this._ui.startSpinner(`Deploying to cabinet [${cabCntx.enterprise}/${cabCntx.environment}/${this._styler.hilite(cabCntx.cabinet)}]...`);
|
|
130
|
-
// let result: Result = await this.relayClient.deployAssets(cabCntx, assetVersions);
|
|
131
|
-
let result = yield this.genRelayClient.Call.postExecuteDeployment({ assets: assetVersions, target: cabCntx });
|
|
132
|
-
yield this._ui.stopSpinner(result.success ? "SUCCESS" : (result.error ? "ERROR" : "FAILED"));
|
|
133
|
-
if (result.success) {
|
|
134
|
-
this._ui.userMessage(`${this._styler.colorGood("SUCCESS")}: ${result.message}`);
|
|
135
|
-
}
|
|
136
|
-
else if (result.error) {
|
|
137
|
-
this._ui.userMessage(`${this._styler.colorCritical("ERROR")}: ${result.message}`);
|
|
138
|
-
throw result.error;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this._ui.userMessage(`FAILED: ${result.message}`);
|
|
142
|
-
throw result.error;
|
|
143
|
-
}
|
|
144
|
-
resolve();
|
|
145
|
-
}
|
|
146
|
-
catch (err) {
|
|
147
|
-
this.handleError(err);
|
|
148
|
-
// reject(err); // <-- dont rethrow - err handling in the observable isnt yet user-friendly.
|
|
149
|
-
}
|
|
150
|
-
finally {
|
|
151
|
-
yield this.closeConnections();
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
}));
|
|
155
|
-
}
|
|
156
|
-
catch (err) {
|
|
157
|
-
this.handleError(err);
|
|
158
|
-
reject(err);
|
|
159
|
-
}
|
|
160
|
-
finally {
|
|
161
|
-
yield this.closeConnections();
|
|
162
|
-
}
|
|
163
|
-
}));
|
|
29
|
+
const { flags } = yield this.parse(Deploy);
|
|
30
|
+
let partial = {};
|
|
31
|
+
if (flags.enterpriseCode)
|
|
32
|
+
partial.enterprise = flags.enterpriseCode;
|
|
33
|
+
if (flags["providerUserName"])
|
|
34
|
+
partial.providerUserName = flags["providerUserName"];
|
|
35
|
+
if (flags["providerPassword"])
|
|
36
|
+
partial.providerPassword = flags["providerPassword"];
|
|
37
|
+
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);
|
|
38
|
+
return [partial, interactionMode, false];
|
|
164
39
|
});
|
|
165
40
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
41
|
+
buildCandidate_silently(partial, rootMap) {
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const { flags } = yield this.parse(Deploy);
|
|
44
|
+
if (!flags.asset)
|
|
45
|
+
throw new Error("Asset name (--asset or -a) is required in silent mode.");
|
|
46
|
+
if (!flags.version)
|
|
47
|
+
throw new Error("Asset version (--version or -u) is required in silent mode.");
|
|
48
|
+
const assetVersion = { a: flags.asset, v: flags.version };
|
|
49
|
+
if (flags.tagAsset && flags.tagAsset.length > 0)
|
|
50
|
+
assetVersion.t = flags.tagAsset;
|
|
51
|
+
const [cabinetScope, cabCluster] = yield this.resolveCabinetSilently(partial.enterprise, rootMap, flags);
|
|
52
|
+
// CSP creds
|
|
53
|
+
const cluster = cabCluster !== null && cabCluster !== void 0 ? cabCluster : (rootMap.clusters.length === 1 ? rootMap.clusters[0].name : undefined);
|
|
54
|
+
if (cluster) {
|
|
55
|
+
yield this.establishCloudProviderCreds(rootMap, cluster, true, partial.providerUserName, partial.providerPassword);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.logger.warn(`Cannot confirm cloud provider credentials: cabinet has no cluster specified.`);
|
|
59
|
+
}
|
|
60
|
+
return { enterprise: partial.enterprise, assetVersions: [assetVersion], cabinetScope, cabCluster, providerUserName: partial.providerUserName, providerPassword: partial.providerPassword };
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
buildCandidate_interactively(partial, rootMap, takeDefaults) {
|
|
64
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const { flags } = yield this.parse(Deploy);
|
|
66
|
+
// Select asset + version
|
|
67
|
+
let assetVersions;
|
|
68
|
+
const assetFlag = flags.asset;
|
|
69
|
+
if (assetFlag === exports.PROMPT_ME_DESIGNATOR || assetFlag === exports.PROMPT_ME_DESIGNATOR_MACOS || assetFlag || this._projCfg === undefined) {
|
|
70
|
+
const resolvedAsset = (assetFlag === exports.PROMPT_ME_DESIGNATOR || assetFlag === exports.PROMPT_ME_DESIGNATOR_MACOS)
|
|
71
|
+
? undefined
|
|
72
|
+
: assetFlag;
|
|
73
|
+
const asset = yield this.promptForAsset(partial.enterprise, resolvedAsset);
|
|
74
|
+
const selected = yield this.promptForVersion(partial.enterprise, asset, flags.version);
|
|
75
|
+
if (flags.tagAsset && flags.tagAsset.length > 0)
|
|
76
|
+
selected.t = flags.tagAsset;
|
|
77
|
+
assetVersions = [selected];
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const requestedAssets = yield this.establishAssetContext(rootMap.enterprises.find(e => e.name === partial.enterprise), false);
|
|
81
|
+
const versions = yield this.declareAssetVersions(requestedAssets, partial.enterprise, this._projCfg.codeVersion);
|
|
82
|
+
assetVersions = requestedAssets.map(a => {
|
|
83
|
+
const version = versions.find(v => v.assetName === a);
|
|
84
|
+
const av = { a, v: version ? version.assetVersion : undefined };
|
|
85
|
+
if (flags.tagAsset && flags.tagAsset.length > 0)
|
|
86
|
+
av.t = flags.tagAsset;
|
|
87
|
+
return av;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Select cabinet
|
|
91
|
+
let cabinetScope;
|
|
92
|
+
let cabCluster;
|
|
93
|
+
if (flags.tag !== undefined) {
|
|
94
|
+
[cabinetScope, cabCluster] = yield this.resolveCabinetByTag(partial.enterprise, rootMap, flags);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const cabinet = yield this.establishCabinet(flags.cabinetName, false);
|
|
98
|
+
cabinetScope = { enterprise: cabinet.enterpriseCode, environment: cabinet.environment, cabinet: cabinet.name };
|
|
99
|
+
cabCluster = cabinet.cluster;
|
|
100
|
+
}
|
|
101
|
+
// CSP creds
|
|
102
|
+
const cluster = cabCluster !== null && cabCluster !== void 0 ? cabCluster : (rootMap.clusters.length === 1 ? rootMap.clusters[0].name : undefined);
|
|
103
|
+
if (cluster) {
|
|
104
|
+
yield this.establishCloudProviderCreds(rootMap, cluster, false, partial.providerUserName, partial.providerPassword);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.logger.warn(`Cannot confirm cloud provider credentials: cabinet has no cluster specified.`);
|
|
108
|
+
}
|
|
109
|
+
return { enterprise: partial.enterprise, assetVersions, cabinetScope, cabCluster, providerUserName: partial.providerUserName, providerPassword: partial.providerPassword };
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
buildCommandString(candidate, cmd) {
|
|
113
|
+
cmd.push("-e", candidate.enterprise);
|
|
114
|
+
if (candidate.assetVersions.length > 0) {
|
|
115
|
+
cmd.push("-a", candidate.assetVersions[0].a);
|
|
116
|
+
if (candidate.assetVersions[0].v)
|
|
117
|
+
cmd.push("-u", candidate.assetVersions[0].v);
|
|
181
118
|
}
|
|
119
|
+
cmd.push("-c", candidate.cabinetScope.cabinet);
|
|
120
|
+
if (candidate.providerUserName)
|
|
121
|
+
cmd.push("-n", candidate.providerUserName);
|
|
122
|
+
if (candidate.providerPassword)
|
|
123
|
+
cmd.push("-p", candidate.providerPassword);
|
|
124
|
+
cmd.push("--silent");
|
|
125
|
+
return cmd;
|
|
182
126
|
}
|
|
183
|
-
|
|
184
|
-
return
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (!enterprises || enterprises.length == 0) {
|
|
192
|
-
throw new Error(`Could not find enterprise [${enterprise}].`);
|
|
193
|
-
}
|
|
194
|
-
else if (!enterprises[0].assets || enterprises[0].assets.length == 0) {
|
|
195
|
-
throw new Error(`The current enterprise [${enterprise}] has no assets defined.`);
|
|
196
|
-
}
|
|
197
|
-
// console.log(`${readResult.output[0].assets.length} assets found`)
|
|
198
|
-
// Select from assets in the current enterprise
|
|
199
|
-
let assets = enterprises[0].assets;
|
|
200
|
-
if (assetSearch && assetSearch != exports.PROMPT_ME_DESIGNATOR) {
|
|
201
|
-
assets = assets.filter(a => a.name.startsWith(assetSearch));
|
|
202
|
-
}
|
|
203
|
-
// console.log(`${assets.length} assets found`)
|
|
204
|
-
let selectedAss = yield this._ui.promptSelect('asset', 'Select an Asset:', assets.map(a => a.name).sort());
|
|
205
|
-
let selected = assets.find(a => a.name == selectedAss);
|
|
206
|
-
if (!selected)
|
|
207
|
-
throw new Error(`User failed to select a valid asset to deploy.`);
|
|
208
|
-
resolve(selected);
|
|
127
|
+
executeTask(candidate) {
|
|
128
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const cabLabel = `${candidate.cabinetScope.enterprise}/${candidate.cabinetScope.environment}/${this._styler.hilite(candidate.cabinetScope.cabinet)}`;
|
|
130
|
+
yield this._ui.startSpinner(`Deploying to cabinet [${cabLabel}]...`);
|
|
131
|
+
const result = yield this.genRelayClient.Call.postExecuteDeployment({ assets: candidate.assetVersions, target: candidate.cabinetScope });
|
|
132
|
+
yield this._ui.stopSpinner(result.success ? "SUCCESS" : (result.error ? "ERROR" : "FAILED"));
|
|
133
|
+
if (result.success) {
|
|
134
|
+
this._ui.userMessage(`${this._styler.colorGood("SUCCESS")}: ${result.message}`);
|
|
209
135
|
}
|
|
210
|
-
|
|
211
|
-
|
|
136
|
+
else if (result.error) {
|
|
137
|
+
this._ui.userMessage(`${this._styler.colorCritical("ERROR")}: ${result.message}`);
|
|
138
|
+
throw result.error;
|
|
212
139
|
}
|
|
213
|
-
|
|
140
|
+
else {
|
|
141
|
+
this._ui.userMessage(`FAILED: ${result.message}`);
|
|
142
|
+
throw result.error;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
resolveCabinetSilently(enterprise, rootMap, flags) {
|
|
147
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
if (flags.tag !== undefined) {
|
|
149
|
+
return this.resolveCabinetByTag(enterprise, rootMap, flags);
|
|
150
|
+
}
|
|
151
|
+
if (!flags.cabinetName)
|
|
152
|
+
throw new Error("Cabinet name (--cabinetName or -c) or tags (--tag or -t) are required in silent mode.");
|
|
153
|
+
const cabinet = yield this.establishCabinet(flags.cabinetName, true);
|
|
154
|
+
const cabinetScope = { enterprise: cabinet.enterpriseCode, environment: cabinet.environment, cabinet: cabinet.name };
|
|
155
|
+
return [cabinetScope, cabinet.cluster];
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
resolveCabinetByTag(enterprise, rootMap, flags) {
|
|
159
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
const selector = { enterprise, tags: flags.tag };
|
|
161
|
+
if (flags.tagMatch !== undefined) {
|
|
162
|
+
if (!["any", "all", "none"].includes(flags.tagMatch))
|
|
163
|
+
throw new Error("tagMatch must be one of: 'any', 'all', or 'none'.");
|
|
164
|
+
selector.matchTags = flags.tagMatch;
|
|
165
|
+
}
|
|
166
|
+
const cabRes = yield this.genRelayClient.Call.GetCabinets(selector);
|
|
167
|
+
if (!cabRes.output || cabRes.output.length === 0)
|
|
168
|
+
throw new Error("No matching cabinets were found.");
|
|
169
|
+
if (cabRes.output.length > 1) {
|
|
170
|
+
this.logger.detail("Found multiple cabinets matching deployment request; selecting the first of ".concat(cabRes.output.length.toString()));
|
|
171
|
+
}
|
|
172
|
+
const cab = cabRes.output[0];
|
|
173
|
+
const cabinetScope = Object.assign(Object.assign({}, _.pick(cab, "enterprise", "environment")), { cabinet: cab.name });
|
|
174
|
+
return [cabinetScope, cab.cluster];
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
promptForAsset(enterprise, assetSearch) {
|
|
178
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
const ecrit = { code: enterprise };
|
|
180
|
+
const enterprises = yield this._codiacApi.Enterprise.readMany(ecrit, { throwNotFound: false });
|
|
181
|
+
if (!enterprises || enterprises.length === 0)
|
|
182
|
+
throw new Error(`Could not find enterprise [${enterprise}].`);
|
|
183
|
+
if (!enterprises[0].assets || enterprises[0].assets.length === 0)
|
|
184
|
+
throw new Error(`The enterprise [${enterprise}] has no assets defined.`);
|
|
185
|
+
let assets = enterprises[0].assets;
|
|
186
|
+
if (assetSearch && assetSearch !== exports.PROMPT_ME_DESIGNATOR) {
|
|
187
|
+
assets = assets.filter(a => a.name.startsWith(assetSearch));
|
|
188
|
+
}
|
|
189
|
+
const choices = assets.map(a => ({ name: a.name, value: a.name })).sort((a, b) => a.name.localeCompare(b.name));
|
|
190
|
+
const selectedName = yield this._ui.promptSelectFuzzy('asset', 'Select an Asset:', () => tslib_1.__awaiter(this, void 0, void 0, function* () { return choices; }));
|
|
191
|
+
const selected = assets.find(a => a.name === selectedName);
|
|
192
|
+
if (!selected)
|
|
193
|
+
throw new Error(`User failed to select a valid asset to deploy.`);
|
|
194
|
+
return selected;
|
|
195
|
+
});
|
|
214
196
|
}
|
|
215
197
|
promptForVersion(enterpriseCode, asset, versionSearch) {
|
|
198
|
+
var _a, _b;
|
|
216
199
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
resolve({ a: asset.name, v: verSelect.version });
|
|
237
|
-
}
|
|
238
|
-
catch (err) {
|
|
239
|
-
reject(err);
|
|
240
|
-
}
|
|
241
|
-
}));
|
|
200
|
+
const providerSubscriptionId = (_a = asset.image.registry.accountId) !== null && _a !== void 0 ? _a : asset.image.registry.subscriptionId;
|
|
201
|
+
yield this.cspContextualizer.promptForCloudProviderCreds(this.ioc, asset.image.registry.provider, undefined, undefined, undefined, providerSubscriptionId);
|
|
202
|
+
this._ui.startSpinner("Loading versions...");
|
|
203
|
+
const result = yield this.genRelayClient.Call.FetchAssetVersions({ image: asset.image, assetType: asset.type, versionSearch });
|
|
204
|
+
if (result.error)
|
|
205
|
+
throw result.error;
|
|
206
|
+
const sorted = (_b = result.output) !== null && _b !== void 0 ? _b : [];
|
|
207
|
+
const latest = sorted.length > 0 ? sorted[0] : undefined;
|
|
208
|
+
assetVersionChoices = sorted.map(v => ({ value: v, name: v }));
|
|
209
|
+
this._ui.stopSpinner(`found ${assetVersionChoices.length}`);
|
|
210
|
+
inquirer.registerPrompt('autocomplete', autocomplete);
|
|
211
|
+
const verSelect = yield inquirer.prompt([{
|
|
212
|
+
type: 'autocomplete',
|
|
213
|
+
name: 'version',
|
|
214
|
+
message: 'Select the asset version:',
|
|
215
|
+
source: this.searchVersions,
|
|
216
|
+
default: latest
|
|
217
|
+
}]);
|
|
218
|
+
return { a: asset.name, v: verSelect.version };
|
|
242
219
|
});
|
|
243
220
|
}
|
|
244
|
-
// async promptForVersionConfig_NOTUSED(enterpriseCode: string, asset: Asset, versionSearch?: string): Promise<AssetVersion> {
|
|
245
|
-
// return new Promise<AssetVersion>(async (resolve,reject) => {
|
|
246
|
-
// try {
|
|
247
|
-
// let crit = <VersionConfigCriteria>{ enterprise: enterpriseCode, assetName: asset.name };
|
|
248
|
-
// let versionFetch = await this._codiacApi.VersionConfig.tryReadMany(crit);
|
|
249
|
-
// if (!versionFetch.output || versionFetch.output.length == 0) {
|
|
250
|
-
// throw new Error(`No versions found for the asset [${asset.name}].`);
|
|
251
|
-
// }
|
|
252
|
-
// let versions: { value: string, name: string }[] = [];
|
|
253
|
-
// // let latest = new Date("2000-01-01T00:00:00.999Z");
|
|
254
|
-
// let latest = _.maxBy(versionFetch.output, v => v.created);
|
|
255
|
-
// let sorted = _.orderBy(versionFetch.output, v => v.created, 'desc');
|
|
256
|
-
// if (versionSearch) {
|
|
257
|
-
// sorted = sorted.filter(v => v.assetVersion.indexOf(versionSearch) >= 0);
|
|
258
|
-
// }
|
|
259
|
-
// if (sorted.length == 0) {
|
|
260
|
-
// throw new Error(`No versions like '${versionSearch}' found for the asset [${asset.name}].`);
|
|
261
|
-
// }
|
|
262
|
-
// for (let v of sorted) {
|
|
263
|
-
// let marker = (latest && v.assetVersion == latest.assetVersion) ? " (latest)" : "";
|
|
264
|
-
// versions.push({
|
|
265
|
-
// value: v.assetVersion,
|
|
266
|
-
// name: `${v.assetVersion} ${this._styler.dim(new Date(v.created).toLocaleDateString())} ${marker}`
|
|
267
|
-
// });
|
|
268
|
-
// }
|
|
269
|
-
// // Without autocomplete...
|
|
270
|
-
// // let verSelect = await inquirer.prompt({ type: 'list', name: 'version', message: 'Select the asset version:', choices: versions, default: latest });
|
|
271
|
-
// // With fuzzy autocomplete...
|
|
272
|
-
// inquirer.registerPrompt('autocomplete', autocomplete);
|
|
273
|
-
// assetVersions = versions;
|
|
274
|
-
// let verSelect = await inquirer.prompt([{ type: 'autocomplete', name: 'version', message: 'Select the asset version:', source: this.searchVersions, default: latest }]);
|
|
275
|
-
// resolve({ a: asset.name, v: verSelect.version });
|
|
276
|
-
// } catch (err) {
|
|
277
|
-
// reject(err);
|
|
278
|
-
// }
|
|
279
|
-
// });
|
|
280
|
-
// }
|
|
281
|
-
// private async fetchVersions(image: Image, assetType: AssetTypesEnum | undefined, versionSearch?: string): Promise<string[]> {
|
|
282
|
-
// return new Promise<string[]>(async (resolve, reject) => {
|
|
283
|
-
// try {
|
|
284
|
-
// let versionsFetch: string[];
|
|
285
|
-
// if (assetType == AssetTypesEnum.helm) {
|
|
286
|
-
// let chartName = image.name;
|
|
287
|
-
// let repoName = image.registry.code;
|
|
288
|
-
// let chartRegisryUrl = image.registry.url;
|
|
289
|
-
// let chartVersions = await this.helmClient.getVersionsOf(chartName, repoName, chartRegisryUrl);
|
|
290
|
-
// versionsFetch = chartVersions.output?.map(x => x.version) || [];
|
|
291
|
-
// } else {
|
|
292
|
-
// let result = await this.relayClient.tryReadImageTags(image.registry.url, (image.scope) ? `${image.scope}/${image.name}` : image.name); // is scope already prefixing the name?
|
|
293
|
-
// versionsFetch = result.output;
|
|
294
|
-
// }
|
|
295
|
-
// if (!versionsFetch || versionsFetch.length == 0) {
|
|
296
|
-
// throw new Error(`No versions found for the ${assetType} [${image.name}].`);
|
|
297
|
-
// }
|
|
298
|
-
// // let sorted = versionsFetch.filter(v => semver.clean(v)).sort(semver.rcompare);
|
|
299
|
-
// versionsFetch = versionsFetch.filter(av => av !== null && av !== undefined); // Ignore untagged images
|
|
300
|
-
// let semvers = _.remove(versionsFetch, v => semver.clean(v)).sort(semver.rcompare); // removes semvers so they can be sorted uniquely
|
|
301
|
-
// let sorted = semvers.concat(versionsFetch.sort().reverse());
|
|
302
|
-
// // let sorted = versionsFetch.reverse(); // the reg client shd do this for us...
|
|
303
|
-
// if (versionSearch) {
|
|
304
|
-
// sorted = sorted.filter(v => v.indexOf(versionSearch) >= 0); // this will give too many results - it shd be an equals not a contains
|
|
305
|
-
// }
|
|
306
|
-
// if (sorted.length == 0) {
|
|
307
|
-
// throw new Error(`No versions like '${versionSearch}' found for the ${assetType} [${image.name}].`);
|
|
308
|
-
// }
|
|
309
|
-
// // TODO: It would be nice to mark versions with their dates or their canonical tags (latest, stable, etc)
|
|
310
|
-
// // eg: name = `${v.assetVersion} ${this._styler.dim(new Date(v.created).toLocaleDateString())} (latest)`;
|
|
311
|
-
// resolve(sorted);
|
|
312
|
-
// } catch (err) {
|
|
313
|
-
// reject(err);
|
|
314
|
-
// }
|
|
315
|
-
// });
|
|
316
|
-
// }
|
|
317
221
|
searchVersions(answers, input) {
|
|
318
222
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
let options = { extract: (ver) => { return ver.value; } };
|
|
328
|
-
let results = fuzzy.filter(input, assetVersions, options);
|
|
329
|
-
let filtered = results.map((fr) => fr.original);
|
|
330
|
-
resolve(filtered);
|
|
331
|
-
}, _.random(30, 500)); // why a random number?
|
|
332
|
-
}
|
|
333
|
-
catch (err) {
|
|
334
|
-
reject(err);
|
|
335
|
-
}
|
|
336
|
-
}));
|
|
223
|
+
input = input || "";
|
|
224
|
+
return new Promise((resolve) => {
|
|
225
|
+
setTimeout(() => {
|
|
226
|
+
const options = { extract: (ver) => ver.value };
|
|
227
|
+
const results = fuzzy.filter(input, assetVersionChoices, options);
|
|
228
|
+
resolve(results.map((fr) => fr.original));
|
|
229
|
+
}, _.random(30, 500));
|
|
230
|
+
});
|
|
337
231
|
});
|
|
338
232
|
}
|
|
339
|
-
/**
|
|
233
|
+
/** Expands a string list of key=value into properties on an object. */
|
|
234
|
+
parseToDictionary(theseEqualThose) {
|
|
235
|
+
if (theseEqualThose && theseEqualThose.length > 0) {
|
|
236
|
+
const labels = {};
|
|
237
|
+
theseEqualThose.forEach(x => {
|
|
238
|
+
const [key, val] = x.split("=");
|
|
239
|
+
labels[key] = val;
|
|
240
|
+
});
|
|
241
|
+
return labels;
|
|
242
|
+
}
|
|
243
|
+
return {};
|
|
244
|
+
}
|
|
245
|
+
/** Writes Asset versions to the Codiac API. */
|
|
340
246
|
declareAssetVersions(assets, enterpriseCode, versionToUse) {
|
|
247
|
+
var _a, _b, _c, _d;
|
|
341
248
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
};
|
|
371
|
-
let check = yield this._codiacApi.VersionConfig.tryReadMany(crit);
|
|
372
|
-
if (check.error) {
|
|
373
|
-
this.logger.debug(`Error checking existence of VersionConfig: [${vc.assetName}, v${vc.assetVersion}]: ${check.message || ""}; ${check.error.stack}`);
|
|
374
|
-
}
|
|
375
|
-
else if (check.count == 0) {
|
|
376
|
-
// Idempotence: create this version config only if doesnt already exist
|
|
377
|
-
newVersions.push(vc);
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
versions.push(...check.output);
|
|
381
|
-
this.logger.debug(`Skipping version declaration for [${vc.assetName}:${vc.assetVersion}]: VersionConfig already exists [created: ${vc.created.toUTCString()}].`);
|
|
382
|
-
}
|
|
249
|
+
const versions = [];
|
|
250
|
+
const newVersions = [];
|
|
251
|
+
for (const asset of assets) {
|
|
252
|
+
const versionName = `${asset}-${versionToUse}`;
|
|
253
|
+
const vc = Object.assign({ name: versionName, enterprise: enterpriseCode, assetName: asset, assetVersion: versionToUse }, this.createAuditable());
|
|
254
|
+
const crit = { enterprise: vc.enterprise, assetName: vc.assetName, assetVersion: vc.assetVersion };
|
|
255
|
+
const check = yield this._codiacApi.VersionConfig.tryReadMany(crit);
|
|
256
|
+
if (check.error) {
|
|
257
|
+
this.logger.debug(`Error checking existence of VersionConfig: [${vc.assetName}, v${vc.assetVersion}]: ${check.message || ""}; ${check.error.stack}`);
|
|
258
|
+
}
|
|
259
|
+
else if (check.count === 0) {
|
|
260
|
+
newVersions.push(vc);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
versions.push(...check.output);
|
|
264
|
+
this.logger.debug(`Skipping version declaration for [${vc.assetName}:${vc.assetVersion}]: VersionConfig already exists.`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (newVersions.length > 0) {
|
|
268
|
+
const result = yield this._codiacApi.VersionConfig.tryCreateMany(newVersions);
|
|
269
|
+
if (result.success) {
|
|
270
|
+
versions.push(...result.successes);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
const failureCount = (_b = (_a = result.failures) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
274
|
+
const successCount = (_d = (_c = result.successes) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
|
|
275
|
+
if (result.error) {
|
|
276
|
+
throw new contracts_1.CodiacError(`Error declaring version configs for [${assets.join(",")}]: ${result.message || ""}; ${result.error.message}`, result.error);
|
|
383
277
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (result.success) {
|
|
387
|
-
versions.push(...result.successes);
|
|
388
|
-
this.logger.debug(`Asset versions successfully declared: [${newVersions.map(v => v.assetName + ':' + v.assetVersion).join(", ")}].`);
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
// Throw, even on partial successes.
|
|
392
|
-
if (result.successes && result.successes.length > 0) {
|
|
393
|
-
this.logger.debug(`Some Asset version declarations succeeded: ${result.successes.map(v => v.assetName + ':' + v.assetVersion).join(", ")}.`);
|
|
394
|
-
}
|
|
395
|
-
if (result.failures && result.failures.length > 0) {
|
|
396
|
-
this.logger.debug(`Asset version declaration failures: ${result.failures.map(f => f.message)}`);
|
|
397
|
-
}
|
|
398
|
-
let failureCount = (result.failures) ? result.failures.length : 0;
|
|
399
|
-
let successCount = (result.successes) ? result.successes.length : 0;
|
|
400
|
-
if (result.error) {
|
|
401
|
-
throw new contracts_1.CodiacError(`Error declaring version configs for [${assets.join(",")}]: ${result.message || ""}; ${result.error.message}`, result.error);
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
throw new contracts_1.CodiacError(`Partial failure declaring version configs [${successCount} succeeded, ${failureCount} failed] for ${assets.join(",")}: ${result.message}`);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
278
|
+
else {
|
|
279
|
+
throw new contracts_1.CodiacError(`Partial failure declaring version configs [${successCount} succeeded, ${failureCount} failed] for ${assets.join(",")}: ${result.message}`);
|
|
407
280
|
}
|
|
408
|
-
resolve(versions);
|
|
409
281
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
}));
|
|
282
|
+
}
|
|
283
|
+
return versions;
|
|
414
284
|
});
|
|
415
285
|
}
|
|
416
286
|
}
|
|
417
287
|
exports.default = Deploy;
|
|
418
|
-
Deploy.description = 'Deploys a given asset to a given cabinet.
|
|
419
|
-
Deploy.dependsOn = ["enterpriseCode", "cabinetName"];
|
|
288
|
+
Deploy.description = 'Deploys a given asset to a given cabinet. Defaults to current version.';
|
|
420
289
|
Deploy.flags = {
|
|
421
|
-
// ...commandBase.globalFlags,
|
|
422
290
|
help: core_1.Flags.help({ char: 'h' }),
|
|
423
|
-
enterpriseCode: core_1.Flags.string({ char: 'e', required: false, description:
|
|
424
|
-
cabinetName: core_1.Flags.string({ char: 'c', required: false, description:
|
|
425
|
-
tag: core_1.Flags.string({ char: 't', exclusive: ["cabinetName"], required: false, multiple: true, description:
|
|
426
|
-
tagMatch: core_1.Flags.string({ char: 'm', required: false, dependsOn: ["tag"], options: ["any", "all", "none"], description:
|
|
427
|
-
asset: core_1.Flags.string({ char: 'a', required: false, description: `
|
|
428
|
-
version: core_1.Flags.string({ char: 'u', required: false, description: `
|
|
429
|
-
tagAsset: core_1.Flags.string({ char: 'w', multiple: true, required: false, description:
|
|
430
|
-
//
|
|
431
|
-
providerUserName: core_1.Flags.string({ char: 'n', required: false, description:
|
|
432
|
-
providerPassword: core_1.Flags.string({ char: 'p', required: false, description:
|
|
433
|
-
|
|
291
|
+
enterpriseCode: core_1.Flags.string({ char: 'e', required: false, description: 'Code name of the enterprise to target.' }),
|
|
292
|
+
cabinetName: core_1.Flags.string({ char: 'c', required: false, description: 'Target cabinet name to deploy to.' }),
|
|
293
|
+
tag: core_1.Flags.string({ char: 't', exclusive: ["cabinetName"], required: false, multiple: true, description: 'Cabinet tags to select the target cabinet (alternative to --cabinetName).' }),
|
|
294
|
+
tagMatch: core_1.Flags.string({ char: 'm', required: false, dependsOn: ["tag"], options: ["any", "all", "none"], description: 'Logic for matching the given tags when selecting cabinets (defaults to any).' }),
|
|
295
|
+
asset: core_1.Flags.string({ char: 'a', required: false, description: `Name of the asset to deploy (use ${exports.PROMPT_ME_DESIGNATOR} or ${exports.PROMPT_ME_DESIGNATOR_MACOS} to be prompted).` }),
|
|
296
|
+
version: core_1.Flags.string({ char: 'u', required: false, description: `Version of the asset to deploy (use ${exports.PROMPT_ME_DESIGNATOR} or ${exports.PROMPT_ME_DESIGNATOR_MACOS} to be prompted).` }),
|
|
297
|
+
tagAsset: core_1.Flags.string({ char: 'w', multiple: true, required: false, description: 'Tags to apply to the selected asset version.' }),
|
|
298
|
+
// TODO: Deprecate camel-cased args in favor of kebab-case (below)
|
|
299
|
+
"providerUserName": core_1.Flags.string({ char: 'n', required: false, description: 'Cloud provider username for silent/scripted authentication.' }),
|
|
300
|
+
"providerPassword": core_1.Flags.string({ char: 'p', required: false, description: 'Cloud provider password for silent/scripted authentication.' }),
|
|
301
|
+
// "provider-username": Flags.string({ char: 'n', required: false, description: 'Cloud provider username for silent/scripted authentication.' }),
|
|
302
|
+
// "provider-password": Flags.string({ char: 'p', required: false, description: 'Cloud provider password for silent/scripted authentication.' }),
|
|
303
|
+
silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
|
|
304
|
+
echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
|
|
305
|
+
"to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
|
|
434
306
|
};
|
|
435
307
|
Deploy.args = {};
|
|
308
|
+
Deploy.examples = [
|
|
309
|
+
{ description: "Deploy interactively.", command: "<%= config.bin %> <%= command.id %>" },
|
|
310
|
+
{ description: "Deploy a specific asset version to a cabinet.", command: "<%= config.bin %> <%= command.id %> -e myEnterprise -a myApi -u 1.2.3 -c dev" },
|
|
311
|
+
{ description: "Deploy to a cabinet selected by tag.", command: "<%= config.bin %> <%= command.id %> -e myEnterprise -a myApi -u 1.2.3 -t staging" },
|
|
312
|
+
{ description: "Non-interactive (scripted) invocation.", command: "<%= config.bin %> <%= command.id %> -e myEnterprise -a myApi -u 1.2.3 -c dev --silent" },
|
|
313
|
+
{ description: "Renders the equivalent silent command without executing.", command: "<%= config.bin %> <%= command.id %> -e myEnterprise -a myApi -u 1.2.3 -c dev --to-script" },
|
|
314
|
+
];
|
|
436
315
|
//# sourceMappingURL=deploy.js.map
|