@codiac.io/codiac-cli 1.2.255 → 1.2.257
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/contracts.d.ts +5 -1
- package/dist/apis/codiac-api/gen/contracts.js +3 -0
- package/dist/apis/codiac-api/gen/contracts.js.map +1 -1
- package/dist/apis/codiac-relay/gen/client.d.ts +5 -1
- package/dist/apis/codiac-relay/gen/client.js +28 -0
- package/dist/apis/codiac-relay/gen/client.js.map +1 -1
- package/dist/apis/codiac-relay/gen/contracts.d.ts +19 -6
- package/dist/apis/codiac-relay/gen/contracts.js +1 -0
- package/dist/apis/codiac-relay/gen/contracts.js.map +1 -1
- package/dist/cli-common/argument-manager.d.ts +1 -1
- package/dist/cli-common/built-in-cli-user-input.d.ts +3 -2
- package/dist/cli-common/built-in-cli-user-input.js +3 -1
- package/dist/cli-common/built-in-cli-user-input.js.map +1 -1
- package/dist/cli-common/command-base.d.ts +1 -2
- package/dist/cli-common/command-base.js +13 -11
- package/dist/cli-common/command-base.js.map +1 -1
- package/dist/cli-common/entities/prompt-choice.d.ts +6 -2
- package/dist/cli-common/mock-ui.d.ts +2 -2
- package/dist/cli-common/mock-ui.js.map +1 -1
- package/dist/cli-common/prompt-select-fuzzy.d.ts +4 -5
- package/dist/cli-common/prompt-select-fuzzy.js +11 -9
- package/dist/cli-common/prompt-select-fuzzy.js.map +1 -1
- package/dist/cli-common/test/tenant-contextualizer.spec.js +2 -2
- package/dist/command-base-enterprise.d.ts +3 -3
- package/dist/command-base-enterprise.js +38 -22
- package/dist/command-base-enterprise.js.map +1 -1
- package/dist/command-base-exec.js.map +1 -1
- package/dist/command-base-tenantless.js +2 -2
- package/dist/command-base-tenantless.js.map +1 -1
- package/dist/commands/asset/create.d.ts +16 -1
- package/dist/commands/asset/create.js +239 -85
- package/dist/commands/asset/create.js.map +1 -1
- package/dist/commands/asset/deploy.d.ts +0 -4
- package/dist/commands/asset/deploy.js +3 -15
- package/dist/commands/asset/deploy.js.map +1 -1
- package/dist/commands/asset/destroy.js +3 -3
- package/dist/commands/asset/destroy.js.map +1 -1
- package/dist/commands/asset/recycle.js +5 -5
- package/dist/commands/asset/recycle.js.map +1 -1
- package/dist/commands/asset/view.d.ts +9 -6
- package/dist/commands/asset/view.js +220 -127
- package/dist/commands/asset/view.js.map +1 -1
- package/dist/commands/cabinet/create.js +20 -21
- package/dist/commands/cabinet/create.js.map +1 -1
- package/dist/commands/cabinet/obliterate.js +1 -1
- package/dist/commands/cabinet/obliterate.js.map +1 -1
- package/dist/commands/config/add.js +47 -24
- package/dist/commands/config/add.js.map +1 -1
- package/dist/commands/config/delete.js +8 -7
- package/dist/commands/config/delete.js.map +1 -1
- package/dist/commands/config/deploy.d.ts +2 -2
- package/dist/commands/config/deploy.js +121 -64
- package/dist/commands/config/deploy.js.map +1 -1
- package/dist/commands/config/import.d.ts +19 -5
- package/dist/commands/config/import.js +112 -52
- package/dist/commands/config/import.js.map +1 -1
- package/dist/commands/config/settings/get.js +7 -6
- package/dist/commands/config/settings/get.js.map +1 -1
- package/dist/commands/config/view.js +11 -4
- package/dist/commands/config/view.js.map +1 -1
- package/dist/commands/csp/login.js +3 -3
- package/dist/commands/csp/login.js.map +1 -1
- package/dist/commands/dep/list.js +2 -1
- package/dist/commands/dep/list.js.map +1 -1
- package/dist/commands/deploy.js +2 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/env/add.d.ts +1 -1
- package/dist/commands/env/add.js +12 -12
- package/dist/commands/env/add.js.map +1 -1
- package/dist/commands/filestore/capture.js +22 -4
- package/dist/commands/filestore/capture.js.map +1 -1
- package/dist/commands/host/list.d.ts +30 -0
- package/dist/commands/host/list.js +106 -0
- package/dist/commands/host/list.js.map +1 -0
- package/dist/commands/host/map.js +7 -1
- package/dist/commands/host/map.js.map +1 -1
- package/dist/commands/host/view.d.ts +31 -0
- package/dist/commands/host/view.js +111 -0
- package/dist/commands/host/view.js.map +1 -0
- package/dist/commands/init.js +1 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/kit/create.js +1 -1
- package/dist/commands/kit/create.js.map +1 -1
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/noc/cluster/deinit.d.ts +1 -0
- package/dist/commands/noc/cluster/deinit.js +4 -3
- package/dist/commands/noc/cluster/deinit.js.map +1 -1
- package/dist/commands/noc/cluster/destroy.js +3 -3
- package/dist/commands/noc/cluster/destroy.js.map +1 -1
- package/dist/commands/noc/cluster/forget.js +4 -4
- package/dist/commands/noc/cluster/forget.js.map +1 -1
- package/dist/commands/noc/cluster/grant.js +2 -2
- package/dist/commands/noc/cluster/grant.js.map +1 -1
- package/dist/commands/noc/cluster/init.js +3 -3
- package/dist/commands/noc/cluster/init.js.map +1 -1
- package/dist/commands/noc/cluster/recreate.js +2 -2
- package/dist/commands/noc/cluster/recreate.js.map +1 -1
- package/dist/commands/publish.js +3 -2
- package/dist/commands/publish.js.map +1 -1
- package/dist/ops/INTERFACES_CLI.d.ts +7 -1
- package/dist/ops/INTERFACES_CLI.js +7 -0
- package/dist/ops/INTERFACES_CLI.js.map +1 -1
- package/dist/ops/LocalOps.js +29 -28
- package/dist/ops/LocalOps.js.map +1 -1
- package/dist/ops/cli-path-walker.d.ts +18 -0
- package/dist/ops/cli-path-walker.js +58 -53
- package/dist/ops/cli-path-walker.js.map +1 -1
- package/dist/ops/data/cli-context-repo.js +11 -9
- package/dist/ops/data/cli-context-repo.js.map +1 -1
- package/dist/ops/i-entry-validator.d.ts +21 -0
- package/dist/ops/i-entry-validator.js +3 -0
- package/dist/ops/i-entry-validator.js.map +1 -0
- package/dist/ops/i-identity-handler.js +2 -2
- package/dist/ops/i-identity-handler.js.map +1 -1
- package/dist/ops/i-output-styler.d.ts +15 -0
- package/dist/ops/i-output-styler.js +1 -15
- package/dist/ops/i-output-styler.js.map +1 -1
- package/dist/ops/i-user-input-provider.d.ts +56 -0
- package/dist/ops/i-user-input-provider.js +12 -0
- package/dist/ops/i-user-input-provider.js.map +1 -0
- package/dist/ops/index.d.ts +8 -0
- package/dist/ops/index.js +8 -0
- package/dist/ops/index.js.map +1 -1
- package/dist/ops/no-style-output-styler.d.ts +12 -0
- package/dist/ops/no-style-output-styler.js +34 -28
- package/dist/ops/no-style-output-styler.js.map +1 -1
- package/dist/ops/ops-constants.d.ts +7 -0
- package/dist/ops/ops-constants.js +12 -0
- package/dist/ops/ops-constants.js.map +1 -0
- package/dist/ops/test/mock-ui.d.ts +1 -1
- package/dist/ops/test/when-git-branchline-is-attempted.spec.js +5 -4
- package/dist/ops/test/when-git-branchline-is-attempted.spec.js.map +1 -1
- package/dist/ops/test/when-versions-are-parsed.spec.js +3 -2
- package/dist/ops/test/when-versions-are-parsed.spec.js.map +1 -1
- package/dist/ops/throwing-user-input-provider.d.ts +24 -0
- package/dist/ops/throwing-user-input-provider.js +65 -35
- package/dist/ops/throwing-user-input-provider.js.map +1 -1
- package/dist/prettify.js.map +1 -1
- package/dist/relay/contracts/contracts.d.ts +2 -20
- package/dist/relay/contracts/contracts.js +24 -30
- package/dist/relay/contracts/contracts.js.map +1 -1
- package/dist/relay/extended-relay-client.d.ts +0 -27
- package/dist/relay/extended-relay-client.js +36 -26
- package/dist/relay/extended-relay-client.js.map +1 -1
- package/dist/relay/relay-container.d.ts +1 -1
- package/dist/relay/relay-container.js +6 -6
- package/dist/relay/relay-container.js.map +1 -1
- package/dist/uilogic/build-configurator.d.ts +1 -1
- package/dist/uilogic/build-configurator.js +3 -3
- package/dist/uilogic/build-configurator.js.map +1 -1
- package/dist/uilogic/cloud-provider-contextualizer.d.ts +2 -4
- package/dist/uilogic/cloud-provider-contextualizer.js +9 -15
- package/dist/uilogic/cloud-provider-contextualizer.js.map +1 -1
- package/dist/uilogic/cloud-resource-configurator-factory.js +5 -0
- package/dist/uilogic/cloud-resource-configurator-factory.js.map +1 -1
- package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.d.ts +3 -4
- package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.js +10 -13
- package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.js.map +1 -1
- package/dist/uilogic/cloud-resource-configurators/az-interactive-login-configurator.d.ts +2 -1
- package/dist/uilogic/cloud-resource-configurators/az-interactive-login-configurator.js +4 -3
- package/dist/uilogic/cloud-resource-configurators/az-interactive-login-configurator.js.map +1 -1
- package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.d.ts +3 -4
- package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.js +27 -24
- package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.js.map +1 -1
- package/dist/uilogic/cloud-resource-configurators/docker-hub-resource-configurator.d.ts +1 -1
- package/dist/uilogic/cloud-resource-configurators/docker-hub-resource-configurator.js +3 -3
- package/dist/uilogic/cloud-resource-configurators/docker-hub-resource-configurator.js.map +1 -1
- package/dist/uilogic/cloud-resource-configurators/helm-resource-configurator.d.ts +2 -2
- package/dist/uilogic/cloud-resource-configurators/helm-resource-configurator.js +7 -4
- package/dist/uilogic/cloud-resource-configurators/helm-resource-configurator.js.map +1 -1
- package/dist/uilogic/cloud-resource-configurators/unsupported-resource-configurator.d.ts +1 -1
- package/dist/uilogic/cloud-resource-configurators/unsupported-resource-configurator.js +2 -2
- package/dist/uilogic/cloud-resource-configurators/unsupported-resource-configurator.js.map +1 -1
- package/dist/uilogic/config-ui-utils.d.ts +3 -3
- package/dist/uilogic/config-ui-utils.js +24 -13
- package/dist/uilogic/config-ui-utils.js.map +1 -1
- package/dist/uilogic/enterprise-contextualizer.d.ts +1 -1
- package/dist/uilogic/environment-contextualizer.d.ts +1 -1
- package/dist/uilogic/image-configurator.d.ts +2 -2
- package/dist/uilogic/image-configurator.js +1 -1
- package/dist/uilogic/image-configurator.js.map +1 -1
- package/dist/uilogic/image-contextualizer.d.ts +1 -1
- package/dist/uilogic/image-contextualizer.js +11 -6
- package/dist/uilogic/image-contextualizer.js.map +1 -1
- package/dist/uilogic/image-registry-contextualizer.d.ts +7 -1
- package/dist/uilogic/image-registry-contextualizer.js +56 -3
- package/dist/uilogic/image-registry-contextualizer.js.map +1 -1
- package/dist/uilogic/prompt-select-fuzzy.js +3 -3
- package/dist/uilogic/prompt-select-fuzzy.js.map +1 -1
- package/dist/uilogic/render-methods.d.ts +1 -0
- package/dist/uilogic/render-methods.js +2 -1
- package/dist/uilogic/render-methods.js.map +1 -1
- package/dist/uilogic/rootmap-ui-utils.d.ts +28 -8
- package/dist/uilogic/rootmap-ui-utils.js +132 -8
- package/dist/uilogic/rootmap-ui-utils.js.map +1 -1
- package/dist/uilogic/tenant-contextualizer.d.ts +1 -1
- package/dist/user-context-loader.js +4 -3
- package/dist/user-context-loader.js.map +1 -1
- package/oclif.manifest.json +210 -28
- package/package.json +4 -5
- package/dist/cli-common/i-user-input-provider.d.ts +0 -0
- package/dist/cli-common/i-user-input-provider.js +0 -19
- package/dist/cli-common/i-user-input-provider.js.map +0 -1
- package/dist/cli-common/tenant-contextualizer.d.ts +0 -0
- package/dist/cli-common/tenant-contextualizer.js +0 -436
- package/dist/cli-common/tenant-contextualizer.js.map +0 -1
- package/dist/ops/docker-registry-api-client/docker-registry-api-client.d.ts +0 -0
- package/dist/ops/docker-registry-api-client/docker-registry-api-client.js +0 -289
- package/dist/ops/docker-registry-api-client/docker-registry-api-client.js.map +0 -1
- package/dist/uilogic/cloud-resource-configurators/az-acr-cli-authenticator.d.ts +0 -0
- package/dist/uilogic/cloud-resource-configurators/az-acr-cli-authenticator.js +0 -78
- package/dist/uilogic/cloud-resource-configurators/az-acr-cli-authenticator.js.map +0 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LogStreamer = exports.K8sContainerRef = exports.TermArgs = exports.ConfigFileArgs = exports.ExecArgs = exports.K8S_POD_PHASES = exports.InteractionModes = exports.AssetContentType = exports.PROMPT_ME_DESIGNATOR = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
//import * as path from 'path';
|
|
6
5
|
const stream = require("stream");
|
|
7
6
|
const core_1 = require("@oclif/core");
|
|
8
7
|
const _ = require("lodash");
|
|
@@ -10,13 +9,14 @@ const SplitCmd = require('split-cmd');
|
|
|
10
9
|
const request = require("request");
|
|
11
10
|
const semver = require("semver");
|
|
12
11
|
const k8s = require("@kubernetes/client-node");
|
|
12
|
+
const client_node_1 = require("@kubernetes/client-node");
|
|
13
|
+
const web_socket_handler_1 = require("@kubernetes/client-node/dist/web-socket-handler");
|
|
13
14
|
const command_base_enterprise_1 = require("../../command-base-enterprise");
|
|
15
|
+
const contracts_1 = require("../../apis/codiac-api/contracts");
|
|
14
16
|
const CodiacConstants = require("../../codiac-constants");
|
|
15
17
|
const render = require("../../uilogic/render-methods");
|
|
16
18
|
const cloud_provider_contextualizer_1 = require("../../uilogic/cloud-provider-contextualizer");
|
|
17
|
-
const
|
|
18
|
-
const web_socket_handler_1 = require("@kubernetes/client-node/dist/web-socket-handler");
|
|
19
|
-
const codiac_ops_common_1 = require("@codiac.io/codiac-ops-common");
|
|
19
|
+
const ops_1 = require("../../ops");
|
|
20
20
|
// let logUpdate: any;
|
|
21
21
|
// (async function () {
|
|
22
22
|
// logUpdate = (await import("log-update")).default;
|
|
@@ -171,10 +171,51 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
+
captureArgs(enterpriseCode) {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
const { args, flags } = yield this.parse(AssetView);
|
|
178
|
+
let partial = { enterprise: enterpriseCode };
|
|
179
|
+
let repReq = {};
|
|
180
|
+
repReq.enterprise = flags.enterprise;
|
|
181
|
+
repReq.asset = flags.asset;
|
|
182
|
+
repReq.environment = flags.environment;
|
|
183
|
+
repReq.cabinet = flags.cabinet;
|
|
184
|
+
repReq.content = (flags.type) ? AssetContentType[flags.type] : undefined;
|
|
185
|
+
repReq.replica = flags.replica;
|
|
186
|
+
let givenCmd;
|
|
187
|
+
if (args.cmd) {
|
|
188
|
+
givenCmd = args.cmd;
|
|
189
|
+
let isep = this.argv.indexOf("--");
|
|
190
|
+
if (isep >= 0) {
|
|
191
|
+
if (isep + 1 < this.argv.length) {
|
|
192
|
+
givenCmd = this.argv.slice(isep + 1);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
givenCmd = undefined;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
partial.contentOptions = {
|
|
200
|
+
follow: flags.logsFollow,
|
|
201
|
+
tailLines: flags.logsTail,
|
|
202
|
+
/* tty: flags.tty, */
|
|
203
|
+
command: givenCmd,
|
|
204
|
+
terminalStartup: flags.terminal,
|
|
205
|
+
rootPathName: flags.configFile
|
|
206
|
+
};
|
|
207
|
+
// ---------------------------------------------------------------
|
|
208
|
+
// TODO: move everything from here down into the base class
|
|
209
|
+
// ---------------------------------------------------------------
|
|
210
|
+
const interactionMode = (this.pipedInput) ? InteractionModes.silent : (_b = (_a = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? InteractionModes.echo : undefined)) !== null && _a !== void 0 ? _a : (flags["to-script"] ? InteractionModes.toscript : undefined)) !== null && _b !== void 0 ? _b : (flags.silent ? InteractionModes.silent : undefined);
|
|
211
|
+
const takeDefaults = flags['take-defaults'];
|
|
212
|
+
return [partial, interactionMode, takeDefaults];
|
|
213
|
+
});
|
|
214
|
+
}
|
|
174
215
|
buildCandidate_silently(partialReq, content, contentOptions) {
|
|
175
216
|
var _a, _b, _c, _d, _e, _f;
|
|
176
217
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
this.__ui = new
|
|
218
|
+
this.__ui = new ops_1.ThrowingUserInputProvider(this.logger);
|
|
178
219
|
if (content === undefined || _.isEmpty(partialReq.content))
|
|
179
220
|
throw new Error(`No content type specified.`);
|
|
180
221
|
if (partialReq.enterprise === undefined || _.isEmpty(partialReq.enterprise))
|
|
@@ -185,96 +226,120 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
185
226
|
throw new Error(`No environment specified.`);
|
|
186
227
|
if (partialReq.cabinet === undefined || _.isEmpty(partialReq.cabinet))
|
|
187
228
|
throw new Error(`No cabinet specified.`);
|
|
188
|
-
// Replica should not be required
|
|
189
|
-
// (though this can be confusing when there's more than one;
|
|
190
|
-
// the user will have to know they're only getting a single replica of logs,
|
|
191
|
-
// and they need to know they might have to call out for one.
|
|
192
|
-
// if (partialReq.replica === undefined || _.isEmpty(partialReq.replica)) throw new Error(`No replica specified.`);
|
|
193
|
-
let options;
|
|
194
|
-
switch (partialReq.content) {
|
|
195
|
-
case AssetContentType.logs:
|
|
196
|
-
options = (contentOptions !== null && contentOptions !== void 0 ? contentOptions : {});
|
|
197
|
-
// defaults?
|
|
198
|
-
break;
|
|
199
|
-
case AssetContentType.exec:
|
|
200
|
-
if (_.isEmpty(contentOptions.command))
|
|
201
|
-
throw new Error(`No command specified.`);
|
|
202
|
-
options = {
|
|
203
|
-
command: contentOptions.command,
|
|
204
|
-
tty: (_a = contentOptions.tty) !== null && _a !== void 0 ? _a : false
|
|
205
|
-
};
|
|
206
|
-
break;
|
|
207
|
-
case AssetContentType.config:
|
|
208
|
-
if (_.isEmpty(contentOptions.rootPathName))
|
|
209
|
-
throw new Error(`No file specified.`);
|
|
210
|
-
options = {
|
|
211
|
-
rootPathName: contentOptions.rootPathName
|
|
212
|
-
};
|
|
213
|
-
break;
|
|
214
|
-
case AssetContentType.term:
|
|
215
|
-
options = {
|
|
216
|
-
terminalStartup: (_b = contentOptions.terminalStartup) !== null && _b !== void 0 ? _b : DEFAULT_TERMINAL_STARTER
|
|
217
|
-
};
|
|
218
|
-
break;
|
|
219
|
-
case AssetContentType.env: /* env has no user input */
|
|
220
|
-
default:
|
|
221
|
-
options = {};
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
229
|
// Retrieve the list of replicas for the given cabinet.
|
|
225
|
-
let rootMap = yield this.getRootMap(partialReq.enterprise);
|
|
230
|
+
let rootMap = yield this.getRootMap(partialReq.enterprise); // <-- TODO: provide a rootmap with all enterprises so we can relieve single-enteprise tenants from specifying it everywhere.
|
|
231
|
+
let ent = rootMap.enterprises.find(e => e.name == partialReq.enterprise);
|
|
232
|
+
if (ent == undefined)
|
|
233
|
+
throw new Error("Given enterprise was not found.");
|
|
234
|
+
let asset = ent.assets.find(a => a.name == partialReq.asset);
|
|
235
|
+
if (asset == undefined)
|
|
236
|
+
throw new Error("Given asset was not found.");
|
|
237
|
+
partialReq.assetType = asset.type;
|
|
226
238
|
let env = this.configUtils.deriveEnvironmentFrom(partialReq.enterprise, partialReq.cabinet, rootMap); // this is fkng stupid. Put this value into the cab value
|
|
227
239
|
let cabObj = this.configUtils.getCabinetInfrx(partialReq.enterprise, env.name, partialReq.cabinet, rootMap);
|
|
228
240
|
if (cabObj.infrx == undefined || _.isEmpty(cabObj.infrx))
|
|
229
241
|
throw new Error(`Cannot connect to cabinet ${cabObj.name}: it has no infrastructure record.`);
|
|
230
242
|
let k8sObj = { namespace: cabObj.infrx.namespace };
|
|
231
|
-
let
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (partialReq.
|
|
236
|
-
|
|
237
|
-
|
|
243
|
+
let options;
|
|
244
|
+
let replicas;
|
|
245
|
+
if (partialReq.assetType == contracts_1.AssetTypesEnum.helm) {
|
|
246
|
+
// Enforce the only view that a helm asset can invoke
|
|
247
|
+
if (partialReq.content == undefined)
|
|
248
|
+
partialReq.content = AssetContentType.config;
|
|
249
|
+
if (partialReq.content != AssetContentType.config) {
|
|
250
|
+
throw new Error("Invalid content type. Helm assets can only invoke a config view.");
|
|
238
251
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
252
|
+
options = new ConfigFileArgs(undefined, config_ui_utils_1.SpecialConfigTypes.helm);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
// SELECT REPLICA
|
|
256
|
+
// Replica should not be required
|
|
257
|
+
// (though this can be confusing when there's more than one;
|
|
258
|
+
// the user will have to know they're only getting a single replica of logs,
|
|
259
|
+
// and they need to know they might have to call out for one.
|
|
260
|
+
// if (partialReq.replica === undefined || _.isEmpty(partialReq.replica)) throw new Error(`No replica specified.`);
|
|
261
|
+
switch (partialReq.content) {
|
|
262
|
+
case AssetContentType.logs:
|
|
263
|
+
options = (contentOptions !== null && contentOptions !== void 0 ? contentOptions : {});
|
|
264
|
+
// defaults?
|
|
265
|
+
break;
|
|
266
|
+
case AssetContentType.exec:
|
|
267
|
+
if (_.isEmpty(contentOptions.command))
|
|
268
|
+
throw new Error(`No command specified.`);
|
|
269
|
+
options = {
|
|
270
|
+
command: contentOptions.command,
|
|
271
|
+
tty: (_a = contentOptions.tty) !== null && _a !== void 0 ? _a : false
|
|
272
|
+
};
|
|
273
|
+
break;
|
|
274
|
+
case AssetContentType.config:
|
|
275
|
+
if (_.isEmpty(contentOptions.rootPathName))
|
|
276
|
+
throw new Error(`No file specified.`);
|
|
277
|
+
options = {
|
|
278
|
+
rootPathName: contentOptions.rootPathName
|
|
279
|
+
};
|
|
280
|
+
break;
|
|
281
|
+
case AssetContentType.term:
|
|
282
|
+
options = {
|
|
283
|
+
terminalStartup: (_b = contentOptions.terminalStartup) !== null && _b !== void 0 ? _b : DEFAULT_TERMINAL_STARTER
|
|
284
|
+
};
|
|
285
|
+
break;
|
|
286
|
+
case AssetContentType.env: /* env has no user input */
|
|
287
|
+
default:
|
|
288
|
+
options = {};
|
|
289
|
+
break;
|
|
246
290
|
}
|
|
247
|
-
|
|
248
|
-
if (
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
291
|
+
replicas = yield this.fetchReplicas(partialReq, cabObj.infrx.namespace);
|
|
292
|
+
if (replicas.length > 0) {
|
|
293
|
+
// Capture the user's "any" override.
|
|
294
|
+
let anyReplica = false;
|
|
295
|
+
if (partialReq.replica === CodiacConstants.CliConstants.ARGUMENT_VALUE_FOR_ANY) {
|
|
296
|
+
anyReplica = true;
|
|
297
|
+
delete partialReq.replica;
|
|
298
|
+
}
|
|
299
|
+
// Find the requested replica
|
|
300
|
+
let found;
|
|
301
|
+
if (partialReq.replica) {
|
|
302
|
+
found = replicas.find(r => { var _a; return ((_a = r.metadata) === null || _a === void 0 ? void 0 : _a.name) === partialReq.replica; });
|
|
303
|
+
if (!found) {
|
|
304
|
+
throw new Error(`Specified replica was not found.`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
// Force a replica selection (unless it's an asset-level operation, where replica is optional)
|
|
308
|
+
if (content !== AssetContentType.status) {
|
|
309
|
+
// Set first as default
|
|
310
|
+
if (!found) {
|
|
311
|
+
found = replicas[0];
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// Finally, grab any selected replica
|
|
315
|
+
if (found) {
|
|
316
|
+
k8sObj = {
|
|
317
|
+
namespace: cabObj.infrx.namespace,
|
|
318
|
+
pod: (_d = (_c = found.metadata) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "unnamed",
|
|
319
|
+
container: (_f = (_e = found.spec) === null || _e === void 0 ? void 0 : _e.containers[0].name) !== null && _f !== void 0 ? _f : "unnamed"
|
|
320
|
+
};
|
|
321
|
+
partialReq.replica = k8sObj.pod;
|
|
252
322
|
}
|
|
253
|
-
}
|
|
254
|
-
// Finally, grab any selected replica
|
|
255
|
-
if (found) {
|
|
256
|
-
k8sObj = {
|
|
257
|
-
namespace: cabObj.infrx.namespace,
|
|
258
|
-
pod: (_d = (_c = found.metadata) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "unnamed",
|
|
259
|
-
container: (_f = (_e = found.spec) === null || _e === void 0 ? void 0 : _e.containers[0].name) !== null && _f !== void 0 ? _f : "unnamed"
|
|
260
|
-
};
|
|
261
|
-
partialReq.replica = k8sObj.pod;
|
|
262
323
|
}
|
|
263
324
|
}
|
|
264
325
|
// Assemble
|
|
265
326
|
let candidate = {
|
|
327
|
+
enterprise: partialReq.enterprise,
|
|
266
328
|
context: {
|
|
267
329
|
enterprise: partialReq.enterprise,
|
|
268
330
|
environment: partialReq.environment,
|
|
269
331
|
asset: partialReq.asset,
|
|
270
|
-
|
|
271
|
-
|
|
332
|
+
assetType: partialReq.assetType,
|
|
333
|
+
cabinet: partialReq.cabinet
|
|
272
334
|
},
|
|
273
335
|
contentType: content,
|
|
274
336
|
contentOptions: options,
|
|
275
|
-
k8sEntities: k8sObj
|
|
276
|
-
replicas: replicas
|
|
337
|
+
k8sEntities: k8sObj
|
|
277
338
|
};
|
|
339
|
+
if (partialReq.replica)
|
|
340
|
+
candidate.context.replica = partialReq.replica;
|
|
341
|
+
if (replicas)
|
|
342
|
+
candidate.replicas = replicas;
|
|
278
343
|
return candidate;
|
|
279
344
|
});
|
|
280
345
|
}
|
|
@@ -292,6 +357,8 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
292
357
|
do {
|
|
293
358
|
// 1. Select Asset
|
|
294
359
|
partialReq.asset = yield this.promptForAsset(enterprise.assets, partialReq.asset);
|
|
360
|
+
const asset = (enterprise.assets.find(a => a.name == partialReq.asset));
|
|
361
|
+
partialReq.assetType = asset.type;
|
|
295
362
|
// 2. Cabinet
|
|
296
363
|
let [cabObj, enviro] = yield this.configUtils.promptForCabinet(partialReq.enterprise, rootMap, partialReq.cabinet);
|
|
297
364
|
partialReq.cabinet = cabObj.name;
|
|
@@ -302,43 +369,48 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
302
369
|
throw new Error(`Cannot connect to cabinet ${cabObj.name}: it has no infrastructure record.`);
|
|
303
370
|
k8sObj = { namespace: cabObj.infrx.namespace };
|
|
304
371
|
// 3. Content type
|
|
305
|
-
content = yield this.promptForContentType(content);
|
|
372
|
+
content = yield this.promptForContentType(partialReq.assetType, content);
|
|
306
373
|
// 4. Content-specific arguments
|
|
307
374
|
// MarkStartHere("implement prompt-me designator.")
|
|
308
375
|
// MarkStartHere("Support the current logger or ioc ctr inside the ws event handlers");
|
|
309
376
|
// MarkStartHere("Need UI to operate a different stream than stdout (so piping stdout wont include the ui content");
|
|
310
|
-
[contentOptions, optionsArgs] = yield this.promptForContentOptions(content, partialReq, contentOptions);
|
|
377
|
+
[contentOptions, optionsArgs] = yield this.promptForContentOptions(content, partialReq, partialReq.assetType, contentOptions);
|
|
311
378
|
// 5. Authenticate with CSP
|
|
312
379
|
this.uiCloudPvd.takeDefaults = this.takeDefaults;
|
|
313
380
|
yield this.uiCloudPvd.promptForCloudProviderCreds(this.ioc, cluster.provider);
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
throw new Error(`Cannot connect to cabinet ${cabObj.name}: it has no infrastructure record.`);
|
|
317
|
-
replicas = yield this.fetchReplicas(partialReq, cabObj.infrx.namespace);
|
|
318
|
-
if (replicas.length > 0) {
|
|
319
|
-
// Capture the user's "any" override.
|
|
320
|
-
let anyReplica = false;
|
|
321
|
-
if (partialReq.replica === CodiacConstants.CliConstants.ARGUMENT_VALUE_FOR_ANY) {
|
|
322
|
-
anyReplica = true;
|
|
323
|
-
delete partialReq.replica;
|
|
324
|
-
}
|
|
325
|
-
// Set first as default
|
|
326
|
-
partialReq.replica = (_b = (_a = replicas[0].metadata) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "unnamed";
|
|
327
|
-
k8sObj = {
|
|
328
|
-
namespace: cabObj.infrx.namespace,
|
|
329
|
-
pod: partialReq.replica,
|
|
330
|
-
container: (_d = (_c = replicas[0].spec) === null || _c === void 0 ? void 0 : _c.containers[0].name) !== null && _d !== void 0 ? _d : "unnamed"
|
|
331
|
-
};
|
|
332
|
-
// Select a replica unless it's an asset-level operation
|
|
333
|
-
if (content !== AssetContentType.status) {
|
|
334
|
-
if ((replicas.length > 1) && (anyReplica !== true)) {
|
|
335
|
-
k8sObj = yield this.promptForReplica(replicas, undefined, partialReq.replica);
|
|
336
|
-
partialReq.replica = k8sObj.pod;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
381
|
+
if (partialReq.assetType == contracts_1.AssetTypesEnum.helm) {
|
|
382
|
+
// Nothing to do; We'll be looking at the helm chart release, not pods.
|
|
339
383
|
}
|
|
340
384
|
else {
|
|
341
|
-
|
|
385
|
+
// 6. Replica (Pod)
|
|
386
|
+
if (cabObj.infrx == undefined || _.isEmpty(cabObj.infrx))
|
|
387
|
+
throw new Error(`Cannot connect to cabinet ${cabObj.name}: it has no infrastructure record.`);
|
|
388
|
+
replicas = yield this.fetchReplicas(partialReq, cabObj.infrx.namespace);
|
|
389
|
+
if (replicas.length > 0) {
|
|
390
|
+
// Capture the user's "any" override.
|
|
391
|
+
let anyReplica = false;
|
|
392
|
+
if (partialReq.replica === CodiacConstants.CliConstants.ARGUMENT_VALUE_FOR_ANY) {
|
|
393
|
+
anyReplica = true;
|
|
394
|
+
delete partialReq.replica;
|
|
395
|
+
}
|
|
396
|
+
// Set first as default
|
|
397
|
+
partialReq.replica = (_b = (_a = replicas[0].metadata) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "unnamed";
|
|
398
|
+
k8sObj = {
|
|
399
|
+
namespace: cabObj.infrx.namespace,
|
|
400
|
+
pod: partialReq.replica,
|
|
401
|
+
container: (_d = (_c = replicas[0].spec) === null || _c === void 0 ? void 0 : _c.containers[0].name) !== null && _d !== void 0 ? _d : "unnamed"
|
|
402
|
+
};
|
|
403
|
+
// Select a replica unless it's an asset-level operation
|
|
404
|
+
if (content !== AssetContentType.status) {
|
|
405
|
+
if ((replicas.length > 1) && (anyReplica !== true)) {
|
|
406
|
+
k8sObj = yield this.promptForReplica(replicas, undefined, partialReq.replica);
|
|
407
|
+
partialReq.replica = k8sObj.pod;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
throw new Error(`No [${partialReq.asset}] replicas found in [${cabObj.name}]`);
|
|
413
|
+
}
|
|
342
414
|
}
|
|
343
415
|
// 7. Confirm or loop back around to enterprise
|
|
344
416
|
confirmed = true; // This is a readonly ui (no danger), and we want to enable fast switching among diff content types, so let's not waste time confirming. // await this._ui.promptConfirm("confirm", "Apply? ");
|
|
@@ -346,18 +418,22 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
346
418
|
// We're hard-coding instead of casting here to validate at build-time that each partial property is fully-hydrated.
|
|
347
419
|
// Assemble
|
|
348
420
|
let candidate = {
|
|
421
|
+
enterprise: partialReq.enterprise,
|
|
349
422
|
context: {
|
|
350
423
|
enterprise: partialReq.enterprise,
|
|
351
424
|
environment: partialReq.environment,
|
|
352
425
|
asset: partialReq.asset,
|
|
353
|
-
|
|
354
|
-
|
|
426
|
+
assetType: partialReq.assetType,
|
|
427
|
+
cabinet: partialReq.cabinet
|
|
355
428
|
},
|
|
356
429
|
contentType: content,
|
|
357
430
|
contentOptions: contentOptions,
|
|
358
|
-
k8sEntities: k8sObj
|
|
359
|
-
replicas: replicas
|
|
431
|
+
k8sEntities: k8sObj
|
|
360
432
|
};
|
|
433
|
+
if (partialReq.replica)
|
|
434
|
+
candidate.context.replica = partialReq.replica;
|
|
435
|
+
if (replicas)
|
|
436
|
+
candidate.replicas = replicas;
|
|
361
437
|
// Build command string
|
|
362
438
|
let cmd = ["cod", "asset", "view"];
|
|
363
439
|
cmd.push("--silent");
|
|
@@ -372,7 +448,7 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
372
448
|
return [candidate, cmd];
|
|
373
449
|
});
|
|
374
450
|
}
|
|
375
|
-
promptForContentOptions(contentType, context, defaults) {
|
|
451
|
+
promptForContentOptions(contentType, context, assetType, defaults) {
|
|
376
452
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
377
453
|
let cmdArgs = [];
|
|
378
454
|
try {
|
|
@@ -395,12 +471,16 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
395
471
|
let configType = defaults === null || defaults === void 0 ? void 0 : defaults.configType;
|
|
396
472
|
let typeFileChanged;
|
|
397
473
|
let existingSettings;
|
|
398
|
-
[configType, rootPathName, existingSettings, typeFileChanged] = yield this.configUtils.promptForTypeAndFile(context.enterprise, context.asset, configType, rootPathName, undefined, true, false);
|
|
399
|
-
let cfgArgs = {
|
|
400
|
-
if (rootPathName)
|
|
474
|
+
[configType, rootPathName, existingSettings, typeFileChanged] = yield this.configUtils.promptForTypeAndFile(context.enterprise, context.asset, assetType, configType, rootPathName, undefined, true, false);
|
|
475
|
+
let cfgArgs = {};
|
|
476
|
+
if (rootPathName) {
|
|
477
|
+
cfgArgs.rootPathName = rootPathName;
|
|
401
478
|
cmdArgs.push("-F", rootPathName);
|
|
402
|
-
|
|
479
|
+
}
|
|
480
|
+
if (configType) {
|
|
481
|
+
cfgArgs.configType = configType;
|
|
403
482
|
cmdArgs.push("-T", configType);
|
|
483
|
+
}
|
|
404
484
|
return [cfgArgs, cmdArgs];
|
|
405
485
|
case AssetContentType.term:
|
|
406
486
|
let termArgs = yield this.promptForTerminalOptions(defaults);
|
|
@@ -470,20 +550,31 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
470
550
|
return options;
|
|
471
551
|
});
|
|
472
552
|
}
|
|
473
|
-
promptForContentType(defaultValue) {
|
|
553
|
+
promptForContentType(assetType, defaultValue) {
|
|
474
554
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
475
555
|
try {
|
|
476
556
|
let output;
|
|
477
557
|
let choices = Object.keys(AssetContentType);
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
558
|
+
if (assetType == contracts_1.AssetTypesEnum.helm) {
|
|
559
|
+
// Enforce the only view that a helm asset can invoke
|
|
560
|
+
choices = [AssetContentType.config];
|
|
481
561
|
}
|
|
482
|
-
if (
|
|
483
|
-
|
|
562
|
+
if (choices.length == 1) {
|
|
563
|
+
// select the one and only and inform the user
|
|
564
|
+
output = AssetContentType[choices[0]];
|
|
565
|
+
this._ui.userMessage("Type of content: ".concat(this._styler.hilite(output)));
|
|
484
566
|
}
|
|
485
567
|
else {
|
|
486
|
-
|
|
568
|
+
let keep = this.takeDefaults;
|
|
569
|
+
if (defaultValue && choices.find(x => x == defaultValue) && !this.takeDefaults) {
|
|
570
|
+
keep = yield this._ui.promptConfirm("keepType", `Type of content: ${this._styler.hilite(defaultValue)} `);
|
|
571
|
+
}
|
|
572
|
+
if (keep && defaultValue !== undefined) {
|
|
573
|
+
output = defaultValue;
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
output = (yield this._ui.promptSelect("type", "Type of content: ", choices));
|
|
577
|
+
}
|
|
487
578
|
}
|
|
488
579
|
return output;
|
|
489
580
|
}
|
|
@@ -798,10 +889,12 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
798
889
|
yield this.runExec(context, execArgs, k8sEntities);
|
|
799
890
|
break;
|
|
800
891
|
case (AssetContentType.config):
|
|
801
|
-
if (context.
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
892
|
+
if (context.assetType != contracts_1.AssetTypesEnum.helm) {
|
|
893
|
+
if (context.replica == undefined)
|
|
894
|
+
throw new Error("No replica selected.");
|
|
895
|
+
if (k8sEntities.pod == undefined || k8sEntities.container == undefined)
|
|
896
|
+
throw new Error("No replica selected.");
|
|
897
|
+
}
|
|
805
898
|
let cfgInput = contentOptions;
|
|
806
899
|
if (cfgInput.rootPathName != undefined) {
|
|
807
900
|
if (!cfgInput.rootPathName.startsWith("/"))
|
|
@@ -818,7 +911,7 @@ class AssetView extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
818
911
|
// probing --> writes probe specs to the k8s deployment/podspec
|
|
819
912
|
// label --> writes meta labels to the k8s deployment/podspec
|
|
820
913
|
// annotation --> writes meta annotations to the k8s deployment/podspec
|
|
821
|
-
// helm --> writes chart config to a k8s
|
|
914
|
+
// helm --> writes chart config to a k8s secret (I think... havent tried decrypting the release secret - or it may just be a hash. Best to call the relay to use the Helm client)
|
|
822
915
|
this._ui.userMessage(`Viewing runtime configs of type: [${(_b = cfgInput.configType) !== null && _b !== void 0 ? _b : "(unspecified)"}] not supported yet.`);
|
|
823
916
|
}
|
|
824
917
|
break;
|
|
@@ -1344,10 +1437,10 @@ AssetView.flags = {
|
|
|
1344
1437
|
logsTail: core_1.Flags.integer({ char: 'l', default: 10, description: '(requires type=logs) Lines of recent logs to include in the output. Enter -1 to include the entire log history stored in the container.' }),
|
|
1345
1438
|
configFile: core_1.Flags.string({ char: 'F', description: '(requires type=config) The root pathname to the config file to fetch.' }),
|
|
1346
1439
|
configType: core_1.Flags.string({ char: 'T', exclusive: ["file"], options: Object.keys(config_ui_utils_1.SpecialConfigTypes), description: 'Filters for the settings types that do not land in a config file (such as... env: OS environment variables, footprint: container footprint specs, helm: helm chart settings, label: container meta labels, annotation: container platform key-value pairs).' }),
|
|
1347
|
-
silent: core_1.Flags.boolean({ exclusive: ["echo", "
|
|
1348
|
-
echo: core_1.Flags.boolean({ exclusive: ["
|
|
1349
|
-
|
|
1350
|
-
|
|
1440
|
+
silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Non-Interactive mode; executes without any user interaction and fails on any missing or invalid arguments.' }),
|
|
1441
|
+
echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Echo interaction mode; renders the equivalent non-interactive cli command for future use before final execution.' }),
|
|
1442
|
+
"to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Toscript interaction mode; renders the equivalent non-interactive cli command WITHOUT any execution.' }),
|
|
1443
|
+
"take-defaults": core_1.Flags.boolean({ exclusive: ["silent"], description: "Prevents prompting for confirmation on parameters that were passed in or were set to default values." })
|
|
1351
1444
|
// tty: Flags.boolean({ char: 'i', default: false, description: '(requires type=exec) Specifies an interactive console session.' })
|
|
1352
1445
|
};
|
|
1353
1446
|
AssetView.strict = false; // disables argument validation so we can support variable-length arguments.
|