@codiac.io/codiac-cli 1.2.261 → 1.2.262

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.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/dist/apis/codiac-api/common/api-client-base.js +1 -1
  3. package/dist/apis/codiac-api/common/api-client-base.js.map +1 -1
  4. package/dist/apis/codiac-api/gen/client.d.ts +1477 -1473
  5. package/dist/apis/codiac-api/gen/client.js +5554 -5528
  6. package/dist/apis/codiac-api/gen/client.js.map +1 -1
  7. package/dist/apis/codiac-api/gen/contracts.d.ts +10 -2
  8. package/dist/apis/codiac-api/gen/contracts.js +12 -1
  9. package/dist/apis/codiac-api/gen/contracts.js.map +1 -1
  10. package/dist/commands/asset/probe/delete.d.ts +39 -0
  11. package/dist/commands/asset/probe/delete.js +282 -0
  12. package/dist/commands/asset/probe/delete.js.map +1 -0
  13. package/dist/commands/asset/probe/list.d.ts +48 -0
  14. package/dist/commands/asset/probe/list.js +205 -0
  15. package/dist/commands/asset/probe/list.js.map +1 -0
  16. package/dist/commands/asset/view.d.ts +1 -1
  17. package/dist/commands/environment/cluster/attach.d.ts +43 -0
  18. package/dist/commands/environment/cluster/attach.js +214 -0
  19. package/dist/commands/environment/cluster/attach.js.map +1 -0
  20. package/dist/commands/environment/cluster/detach.d.ts +38 -0
  21. package/dist/commands/environment/cluster/detach.js +193 -0
  22. package/dist/commands/environment/cluster/detach.js.map +1 -0
  23. package/dist/commands/environment/list.js +2 -2
  24. package/dist/commands/environment/list.js.map +1 -1
  25. package/dist/commands/filestore/capture.js +2 -2
  26. package/dist/commands/filestore/capture.js.map +1 -1
  27. package/dist/commands/filestore/forget.d.ts +29 -0
  28. package/dist/commands/filestore/forget.js +137 -0
  29. package/dist/commands/filestore/forget.js.map +1 -0
  30. package/dist/commands/filestore/list.d.ts +41 -0
  31. package/dist/commands/filestore/list.js +169 -0
  32. package/dist/commands/filestore/list.js.map +1 -0
  33. package/dist/commands/host/delete.js +2 -1
  34. package/dist/commands/host/delete.js.map +1 -1
  35. package/dist/commands/host/list.js +5 -1
  36. package/dist/commands/host/list.js.map +1 -1
  37. package/dist/commands/secretStore/list.d.ts +44 -0
  38. package/dist/commands/secretStore/list.js +183 -0
  39. package/dist/commands/secretStore/list.js.map +1 -0
  40. package/dist/commands/tenant/switch.d.ts +1 -1
  41. package/dist/commands/tenant/switch.js +9 -5
  42. package/dist/commands/tenant/switch.js.map +1 -1
  43. package/dist/relay/contracts/index.d.ts +1 -0
  44. package/dist/relay/contracts/index.js +5 -0
  45. package/dist/relay/contracts/index.js.map +1 -0
  46. package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.d.ts +1 -1
  47. package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.js +1 -1
  48. package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.js.map +1 -1
  49. package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.d.ts +1 -1
  50. package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.js +1 -1
  51. package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.js.map +1 -1
  52. package/dist/uilogic/i-secret-store-configurator.d.ts +1 -1
  53. package/dist/uilogic/rootmap-ui-utils.d.ts +35 -1
  54. package/dist/uilogic/rootmap-ui-utils.js +146 -4
  55. package/dist/uilogic/rootmap-ui-utils.js.map +1 -1
  56. package/dist/uilogic/tenant-contextualizer.d.ts +1 -1
  57. package/dist/uilogic/tenant-contextualizer.js.map +1 -1
  58. package/oclif.manifest.json +646 -20
  59. package/package.json +1 -1
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssetProbeUiLogic = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path = require("path");
6
+ const core_1 = require("@oclif/core");
7
+ const YAML = require("yaml");
8
+ const _ = require("lodash");
9
+ const contracts_1 = require("../../../apis/codiac-api/contracts");
10
+ const command_base_exec_1 = require("../../../command-base-exec");
11
+ const config_ui_utils_1 = require("../../../uilogic/config-ui-utils");
12
+ const prettify_1 = require("../../../prettify");
13
+ const output_format_enum_1 = require("../../../cli-entities/output-format-enum");
14
+ const contracts_2 = require("../../../relay/contracts");
15
+ class AssetProbeUiLogic {
16
+ /** Determines an overall true/false result for the given input
17
+ * over the given collection of individual boolean checks. */
18
+ static checkAll(input, filters) {
19
+ let ultimate = true;
20
+ for (let filter of filters) {
21
+ ultimate = ultimate && filter(input);
22
+ if (!ultimate)
23
+ break;
24
+ }
25
+ return ultimate;
26
+ }
27
+ /** COnverts to the name of the kvp store technology WITHOUT the cloud provider prefix.
28
+ * eg: `azKeyVault` converts to `"Key Vault"`
29
+ */
30
+ static friendlyNameFor(type) {
31
+ switch (type) {
32
+ case contracts_2.KvpStoreTypesEnum.awsKeyVault: return "SecretStore";
33
+ case contracts_2.KvpStoreTypesEnum.azKeyVault: return "KeyVault";
34
+ case contracts_2.KvpStoreTypesEnum.azBlob: return "BlobStorage";
35
+ default: return type.toString();
36
+ }
37
+ }
38
+ static actionTypeFor(entity) {
39
+ var _a;
40
+ let actionType;
41
+ if (typeof entity.action == "string") {
42
+ return contracts_1.ProbeActionTypesEnum.exec;
43
+ }
44
+ else {
45
+ return (_a = entity.action.actionType) !== null && _a !== void 0 ? _a : contracts_1.ProbeActionTypesEnum.exec;
46
+ }
47
+ }
48
+ static actionAbbrvFor(entity) {
49
+ var _a, _b;
50
+ if (typeof entity.action == "string") {
51
+ return entity.action; // exec action
52
+ }
53
+ else {
54
+ switch (entity.action.actionType) {
55
+ case contracts_1.ProbeActionTypesEnum.exec: return entity.action.command.join(" ");
56
+ case contracts_1.ProbeActionTypesEnum.http: {
57
+ let axn = entity.action;
58
+ return ((_a = axn.scheme) !== null && _a !== void 0 ? _a : "http").concat("://", path.posix.join((_b = axn.host) !== null && _b !== void 0 ? _b : "<podIP>" + (axn.port ? ":" + axn.port : ""), axn.path));
59
+ }
60
+ case contracts_1.ProbeActionTypesEnum.socket: return "";
61
+ case contracts_1.ProbeActionTypesEnum.grpc: return "";
62
+ }
63
+ }
64
+ }
65
+ static displayNameFor(entity, styler, hilite = true) {
66
+ let abbrv = this.actionAbbrvFor(entity);
67
+ let display = entity.asset.concat(": ", (hilite ? styler.hilite(entity.type.toString()) : styler.bold(entity.type.toString())), entity.periodSeconds ? styler.dim(" @ " + entity.periodSeconds + "s") : "", styler.dim(" -> "), this.actionTypeFor(entity), (abbrv) ? " (" + abbrv + ")" : "");
68
+ if (entity.disabled == true) {
69
+ display = styler.dim("[DISABLED] ".concat(display));
70
+ }
71
+ return display;
72
+ }
73
+ }
74
+ exports.AssetProbeUiLogic = AssetProbeUiLogic;
75
+ class AssetProbeList extends command_base_exec_1.CommandBaseExec {
76
+ captureArgs(enterpriseCode) {
77
+ var _a, _b;
78
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
79
+ const { args, flags } = yield this.parse(AssetProbeList);
80
+ let partial = {
81
+ enterprise: enterpriseCode
82
+ };
83
+ if (flags.asset)
84
+ partial.asset = flags.asset;
85
+ // if (flags.type) partial.type = (<any>ProbeUsageTypesEnum)(flags.type); // TODO: Add this to the criteria
86
+ if (flags.action)
87
+ partial.actionType = contracts_1.ProbeActionTypesEnum[flags.action];
88
+ if (flags.output)
89
+ partial.outputFormat = output_format_enum_1.OutputFormatEnum[flags.output];
90
+ // ---------------------------------------------------------------
91
+ // TODO: move everything from here down into the base class
92
+ // ---------------------------------------------------------------
93
+ 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);
94
+ const takeDefaults = flags['take-defaults'];
95
+ return [partial, interactionMode, takeDefaults];
96
+ });
97
+ }
98
+ buildCandidate_silently(partial, rootMap) {
99
+ var _a;
100
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
101
+ let candidate = {
102
+ enterprise: partial.enterprise,
103
+ outputFormat: (_a = partial.outputFormat) !== null && _a !== void 0 ? _a : output_format_enum_1.OutputFormatEnum.auto
104
+ };
105
+ if (partial.asset)
106
+ candidate.asset = partial.asset;
107
+ // if (partial.type) candidate.type = partial.type;
108
+ if (partial.actionType)
109
+ candidate.actionType = partial.actionType;
110
+ return candidate;
111
+ });
112
+ }
113
+ buildCandidate_interactively(partial, rootMap, takeDefaults) {
114
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
115
+ // TODO: Add interactive prompts for provider and type
116
+ return this.buildCandidate_silently(partial, rootMap);
117
+ });
118
+ }
119
+ buildCommandString(candidate, cmd) {
120
+ if (candidate.enterprise)
121
+ cmd.push("--enterprise", candidate.enterprise);
122
+ if (candidate.asset)
123
+ cmd.push("--asset", candidate.asset);
124
+ // if (candidate.type) cmd.push("--type", candidate.type.toString();
125
+ if (candidate.actionType)
126
+ cmd.push("--action", candidate.actionType);
127
+ if (candidate.outputFormat)
128
+ cmd.push("-o", candidate.outputFormat);
129
+ // TODO: Capture takeDefaults
130
+ cmd.push("--silent");
131
+ return cmd;
132
+ }
133
+ executeTask(candidate) {
134
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
135
+ // Commented out bc the relay endpoint requires provider, and we want it as an optional filter
136
+ // --------------------------------------------------------------------------------------------------------------------------------
137
+ // let req: GetSecretStoresRequest = {
138
+ // provider: candidate.provider,
139
+ // spec: candidate
140
+ // };
141
+ //
142
+ // let output: string;
143
+ // let listRes = await this.genRelayClient.Call.GetSecretStores({ provider: candidate.provider, spec: req })
144
+ // if (listRes.error) throw listRes.error;
145
+ //
146
+ // output = this.renderAs(listRes.output ?? [], candidate.outputFormat, x => SecretStoreUiLogic.displayNameFor(x, this._styler));
147
+ // --------------------------------------------------------------------------------------------------------------------------------
148
+ let req = Object.assign({}, _.omit(candidate, "outputFormat"));
149
+ let list = yield this._codiacApi.Probe.readMany(req);
150
+ // TODO: Render as a tree with assets as parent branch
151
+ let output = this.renderAs(list, candidate.outputFormat, entity => AssetProbeUiLogic.displayNameFor(entity, this._styler));
152
+ console.log(output);
153
+ });
154
+ }
155
+ /** TODO: This method is generic. Promote it to a shared utility lib. */
156
+ renderAs(list, format, textFormatter) {
157
+ let output = "";
158
+ switch (format) {
159
+ case output_format_enum_1.OutputFormatEnum.json:
160
+ output = JSON.stringify(list, undefined, 2);
161
+ break;
162
+ case output_format_enum_1.OutputFormatEnum.yaml:
163
+ output = YAML.stringify(list, { indent: 2 });
164
+ break;
165
+ case output_format_enum_1.OutputFormatEnum.pretty:
166
+ case output_format_enum_1.OutputFormatEnum.auto:
167
+ default:
168
+ if (list.length > 0) {
169
+ if (textFormatter) {
170
+ output = list.map(x => textFormatter(x)).join("\n");
171
+ }
172
+ else {
173
+ output = (0, prettify_1.prettify)(list);
174
+ }
175
+ }
176
+ else {
177
+ output = "None found.";
178
+ }
179
+ break;
180
+ }
181
+ return output;
182
+ }
183
+ }
184
+ exports.default = AssetProbeList;
185
+ AssetProbeList.description = 'Retrieves the list of existing secret stores captured for a given enterprise.';
186
+ AssetProbeList.examples = [
187
+ '<%= config.bin %> <%= command.id %>',
188
+ ];
189
+ /** The values that this command supports for the "type" flag. */
190
+ AssetProbeList.STORE_TYPE_OPTIONS = ["aws-secrets", "az-key-vault"];
191
+ AssetProbeList.flags = {
192
+ enterprise: core_1.Flags.string({ char: 'e', description: '(optional if there is only one) The enterprise in which the probes are defined.' }),
193
+ asset: core_1.Flags.string({ char: 'a', required: false, description: 'The asset that owns the probe.' }),
194
+ type: core_1.Flags.string({ char: 't', options: Object.values(contracts_1.ProbeUsageTypesEnum), required: false, description: "Filter on the purpose/lifecycle role of the probe." }),
195
+ action: core_1.Flags.string({ char: 'x', options: Object.values(contracts_1.ProbeActionTypesEnum), required: false, description: "Filter on the type of action used by the probe." }),
196
+ // output list, table, json, yaml (wd love to have jmespath and/or a template and/or a projection)
197
+ output: core_1.Flags.string({ char: 'o', default: output_format_enum_1.OutputFormatEnum.auto, description: "format in which to render the data.", options: [output_format_enum_1.OutputFormatEnum.json, output_format_enum_1.OutputFormatEnum.yaml, output_format_enum_1.OutputFormatEnum.auto] }),
198
+ // TODO: Move these into the base class
199
+ 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.' }),
200
+ 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.' }),
201
+ "to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Toscript interaction mode; renders the equivalent non-interactive cli command WITHOUT any execution.' }),
202
+ "take-defaults": core_1.Flags.boolean({ exclusive: ["silent"], description: "Setting this to true prevents prompting for confirmation on parameters that were passed in or were automatically set to default values (Irrelevant in --silent mode). This behavior does NOT apply to scenarios that the command needs to override invalid user input; such cases will always prompt for confirmation. eg: when no argument was provided for file or type, and only one exists, the system will render the autoselected file unless this flag is set." })
203
+ };
204
+ AssetProbeList.args = {};
205
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/asset/probe/list.ts"],"names":[],"mappings":";;;;AAAA,6BAA6B;AAC7B,sCAAmC;AACnC,6BAA6B;AAC7B,4BAA6B;AAE7B,kEAAwK;AACxK,kEAA4D;AAC5D,sEAAoE;AACpE,gDAA6C;AAC7C,iFAA4E;AAE5E,wDAA6D;AAO7D,MAAa,iBAAiB;IAE5B;kEAC8D;IACvD,MAAM,CAAC,QAAQ,CAAI,KAAQ,EAAE,OAA8B;QAChE,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,KAAK,IAAI,MAAM,IAAI,OAAO,EAAE;YAC1B,QAAQ,GAAG,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,CAAC,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C;IAEvM,uCAAuC;IACvC,MAAM,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,4GAA4G,EAAE,CAAC;IACtL,IAAI,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,kHAAkH,EAAE,CAAC;IAC5L,WAAW,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,sGAAsG,EAAE,CAAC;IAClL,eAAe,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,ycAAyc,EAAE,CAAC;CAClhB,CAAA;AAEM,mBAAI,GAAG,EACb,CAAA"}
@@ -8,7 +8,7 @@ import { IBetterLogger } from "@codiac.io/codiac-common";
8
8
  import { AtLeast } from '@codiac.io/codiac-common/contracts';
9
9
  import { CommandBaseEnterprise } from '../../command-base-enterprise';
10
10
  import { RootMap } from '../../apis/codiac-api/contracts';
11
- import { AssetReplicaContext, K8sContainerContext } from '../../relay/contracts/contracts';
11
+ import { AssetReplicaContext, K8sContainerContext } from '../../relay/contracts';
12
12
  import { LogOptions } from '../../apis/codiac-relay/contracts';
13
13
  import { ConfigUiUtils, SpecialConfigTypes } from "../../uilogic/config-ui-utils";
14
14
  /** The value provided as input that indicates
@@ -0,0 +1,43 @@
1
+ import { EnvironmentRoot, RootMap } from '../../../apis/codiac-api/contracts';
2
+ import { CommandBaseExec } from '../../../command-base-exec';
3
+ import { AtLeast } from '@codiac.io/codiac-common/contracts';
4
+ import { InteractionModes } from '../../../uilogic/config-ui-utils';
5
+ export type FlatEnviro = {
6
+ name: string;
7
+ sequence?: number | undefined;
8
+ enterprise: string;
9
+ clusters: {
10
+ name: string;
11
+ provider: string;
12
+ locationName: string;
13
+ }[];
14
+ };
15
+ export type IEnviroClusterPair = {
16
+ enterprise: string;
17
+ environmentName: string;
18
+ environment: EnvironmentRoot;
19
+ cluster: string;
20
+ };
21
+ export default class EnvironmentClusterAttach extends CommandBaseExec<IEnviroClusterPair> {
22
+ static description: string;
23
+ static aliases: string[];
24
+ static flags: {
25
+ enterprise: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
26
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
27
+ cluster: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
28
+ silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
29
+ echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
30
+ "to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
31
+ "take-defaults": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
32
+ };
33
+ static args: {};
34
+ captureArgs(enterpriseCode: string): Promise<[AtLeast<IEnviroClusterPair, 'enterprise'>, InteractionModes | undefined, boolean]>;
35
+ buildCandidate_silently(partial: AtLeast<IEnviroClusterPair, 'enterprise'>, rootMap: RootMap): Promise<IEnviroClusterPair | undefined>;
36
+ buildCandidate_interactively(partial: AtLeast<IEnviroClusterPair, 'enterprise'>, rootMap: RootMap, takeDefaults: boolean): Promise<IEnviroClusterPair | undefined>;
37
+ buildCommandString(candidate: IEnviroClusterPair, cmd: string[]): string[];
38
+ executeTask(candidate: IEnviroClusterPair): Promise<void>;
39
+ private buildEnviroListForText;
40
+ private buildEnviroClusterDesc;
41
+ private buildEnviroTree;
42
+ private FlattenEnviros;
43
+ }
@@ -0,0 +1,214 @@
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 command_base_exec_1 = require("../../../command-base-exec");
7
+ const config_ui_utils_1 = require("../../../uilogic/config-ui-utils");
8
+ class EnvironmentClusterAttach extends command_base_exec_1.CommandBaseExec {
9
+ captureArgs(enterpriseCode) {
10
+ var _a, _b, _c;
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ const { args, flags } = yield this.parse(EnvironmentClusterAttach);
13
+ let partial = {
14
+ enterprise: (_a = flags.enterprise) !== null && _a !== void 0 ? _a : enterpriseCode
15
+ };
16
+ if (flags.environment)
17
+ partial.environmentName = flags.environment;
18
+ if (flags.cluster)
19
+ partial.cluster = flags.cluster;
20
+ // ---------------------------------------------------------------
21
+ // TODO: move everything from here down into the base class
22
+ // ---------------------------------------------------------------
23
+ const interactionMode = (this.pipedInput) ? config_ui_utils_1.InteractionModes.silent : (_c = (_b = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? config_ui_utils_1.InteractionModes.echo : undefined)) !== null && _b !== void 0 ? _b : (flags["to-script"] ? config_ui_utils_1.InteractionModes.toscript : undefined)) !== null && _c !== void 0 ? _c : (flags.silent ? config_ui_utils_1.InteractionModes.silent : undefined);
24
+ const takeDefaults = flags['take-defaults'];
25
+ return [partial, interactionMode, takeDefaults];
26
+ });
27
+ }
28
+ buildCandidate_silently(partial, rootMap) {
29
+ var _a;
30
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
+ if (partial.environmentName == undefined || _.isEmpty(partial.environmentName))
32
+ throw new Error("Missing environment");
33
+ if (partial.cluster == undefined || _.isEmpty(partial.cluster))
34
+ throw new Error("Missing cluster");
35
+ let ent = rootMap.enterprises.find(e => e.name == partial.enterprise);
36
+ if (!ent)
37
+ throw new Error("Enterprise not found."); // <-- todo: move this up to the base class and pass in the enterprise object.
38
+ let env = ent.environments.find(e => e.name == partial.environmentName);
39
+ if (env == undefined)
40
+ throw new Error("Environment not found.");
41
+ partial.environment = env;
42
+ let existing = rootMap.clusters.find(c => c.name == partial.cluster);
43
+ if (existing == undefined)
44
+ throw new Error("Cluster not found.");
45
+ let attached = (_a = env.clusters) === null || _a === void 0 ? void 0 : _a.find(c => c.name == partial.cluster);
46
+ if (attached != undefined) {
47
+ this._ui.userMessage("Cluster is already attached to the given environment. No work to do.");
48
+ this.exit(0);
49
+ return;
50
+ }
51
+ let candidate = {
52
+ enterprise: partial.enterprise,
53
+ environmentName: partial.environmentName,
54
+ environment: partial.environment,
55
+ cluster: partial.cluster
56
+ };
57
+ return candidate;
58
+ });
59
+ }
60
+ buildCandidate_interactively(partial, rootMap, takeDefaults) {
61
+ var _a, _b, _c, _d;
62
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
63
+ // Validate
64
+ partial = this.rootMapUtils.validateEnviro(partial, rootMap);
65
+ partial = this.rootMapUtils.validateCluster(partial, rootMap);
66
+ if (partial.cluster && partial.environment) {
67
+ let attached = (_a = partial.environment.clusters) === null || _a === void 0 ? void 0 : _a.find(c => c.name == partial.cluster);
68
+ if (attached != undefined) {
69
+ this._ui.userMessage("Cluster is already attached to the given environment. No work to do.");
70
+ this.exit(0);
71
+ return;
72
+ }
73
+ }
74
+ // Need to select environment and/or cluster
75
+ if (partial.cluster == undefined || partial.environment == undefined || partial.environmentName == undefined) {
76
+ // SELECT ENVIRO
77
+ if (partial.environment == undefined || partial.environmentName == undefined) {
78
+ partial.environment = yield this.rootMapUtils.promptForEnviro(rootMap, partial.enterprise, partial.environmentName);
79
+ partial.environmentName = partial.environment.name;
80
+ }
81
+ // SELECT CLUSTER
82
+ if (partial.cluster && partial.environment) {
83
+ let attached = (_b = partial.environment.clusters) === null || _b === void 0 ? void 0 : _b.find(c => c.name == partial.cluster);
84
+ if (attached != undefined) {
85
+ this._ui.userMessage("Cluster is already attached to the selected environment. No work to do.");
86
+ this.exit(0);
87
+ return;
88
+ }
89
+ }
90
+ if (partial.cluster == undefined) {
91
+ let alreadies = (_d = (_c = partial.environment.clusters) === null || _c === void 0 ? void 0 : _c.map(c => c.name)) !== null && _d !== void 0 ? _d : [];
92
+ let availables = rootMap.clusters.filter(c => !alreadies.includes(c.name));
93
+ let choices = availables.map(c => ({ name: c.name, value: c.name }));
94
+ partial.cluster = (yield this._ui.promptSelect("cluster", "Attach Cluster: ", choices, false, false));
95
+ }
96
+ }
97
+ let candidate = {
98
+ enterprise: partial.enterprise,
99
+ environmentName: partial.environmentName,
100
+ environment: partial.environment,
101
+ cluster: partial.cluster
102
+ };
103
+ return candidate;
104
+ });
105
+ }
106
+ buildCommandString(candidate, cmd) {
107
+ cmd.push("--enterprise", candidate.enterprise);
108
+ cmd.push("--environment", candidate.environmentName);
109
+ cmd.push("--cluster", candidate.cluster);
110
+ cmd.push("--silent");
111
+ return cmd;
112
+ }
113
+ executeTask(candidate) {
114
+ var _a, _b;
115
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
116
+ let result = yield this._codiacApi.Call.EnvironmentClusterAttach({ environmentId: candidate.environment.id, cluster: candidate.cluster });
117
+ if (result.error)
118
+ throw result.error;
119
+ if (result.success) {
120
+ this._ui.userMessage(this._styler.colorGood("Success! ").concat((_a = result.message) !== null && _a !== void 0 ? _a : "Attached cluster to environment."));
121
+ }
122
+ else {
123
+ this._ui.userMessage((_b = result.message) !== null && _b !== void 0 ? _b : "Operation failed without error (Check log for details).");
124
+ }
125
+ });
126
+ }
127
+ buildEnviroListForText(flatList) {
128
+ try {
129
+ let listForText = flatList.map(env => {
130
+ let clusterDesc = this.buildEnviroClusterDesc(env.clusters);
131
+ return `${env.enterprise}/${this._styler.hilite(env.name)}${this._styler.dim(clusterDesc)}`;
132
+ });
133
+ return listForText;
134
+ }
135
+ catch (err) {
136
+ throw err;
137
+ }
138
+ }
139
+ buildEnviroClusterDesc(clusters) {
140
+ try {
141
+ let clusterDesc = "";
142
+ if (clusters.length > 0) {
143
+ if (clusters.length === 1) {
144
+ // Only 1, show provider and location
145
+ clusterDesc = ` ${clusters[0].name} (${clusters[0].provider}, ${clusters[0].locationName})`;
146
+ }
147
+ else {
148
+ // Many, list providers of clusters
149
+ let byProvider = _.groupBy(clusters, c => c.provider);
150
+ let delim = "";
151
+ for (let provider in byProvider) {
152
+ let qty = byProvider[provider].length;
153
+ clusterDesc = clusterDesc.concat(delim, `${qty} ${provider}`);
154
+ delim = ", ";
155
+ }
156
+ if (clusterDesc == "")
157
+ clusterDesc = ` (${clusterDesc})`;
158
+ }
159
+ }
160
+ return clusterDesc;
161
+ }
162
+ catch (err) {
163
+ throw err;
164
+ }
165
+ }
166
+ buildEnviroTree(rootMap) {
167
+ var _a;
168
+ let tree = [];
169
+ for (let ent of rootMap.enterprises) {
170
+ let entBranch = { text: `${ent.name} enterprise:` };
171
+ for (let env of _.sortBy(ent.environments, e => e.sequence, e => e.name)) {
172
+ let clusterDesc = this.buildEnviroClusterDesc((_a = env.clusters) !== null && _a !== void 0 ? _a : []);
173
+ let envBranch = {
174
+ text: `${this._styler.hilite(env.name)}${this._styler.dim(clusterDesc)} `
175
+ };
176
+ if (entBranch.children === undefined)
177
+ entBranch.children = [];
178
+ entBranch.children.push(envBranch);
179
+ }
180
+ tree.push(entBranch);
181
+ }
182
+ return tree;
183
+ }
184
+ FlattenEnviros(rootMap) {
185
+ var _a;
186
+ let flattened = [];
187
+ for (let ent of rootMap.enterprises) {
188
+ for (let env of _.sortBy(ent.environments, e => e.sequence, e => e.name)) {
189
+ flattened.push({
190
+ name: env.name,
191
+ sequence: env.sequence,
192
+ enterprise: ent.name,
193
+ clusters: (_a = env.clusters) !== null && _a !== void 0 ? _a : []
194
+ });
195
+ }
196
+ }
197
+ return flattened;
198
+ }
199
+ }
200
+ exports.default = EnvironmentClusterAttach;
201
+ EnvironmentClusterAttach.description = 'Includes the given cluster within the given environment. DOES NOT modify any infrastructure; only creates an association within Codiac.';
202
+ EnvironmentClusterAttach.aliases = ["enviro:cluster:attach"];
203
+ EnvironmentClusterAttach.flags = {
204
+ enterprise: core_1.Flags.string({ char: 'e', description: 'The name of the enterprise in which the environment resides. NOTE: You can leave this blank if there is only one.' }),
205
+ environment: core_1.Flags.string({ char: 'n', required: false, description: 'Name of the environment being modified.' }),
206
+ cluster: core_1.Flags.string({ char: 'c', required: false, description: 'Name of the cluster.' }),
207
+ // TODO: Move these into the base class
208
+ 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.' }),
209
+ 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.' }),
210
+ "to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Toscript interaction mode; renders the equivalent non-interactive cli command WITHOUT any execution.' }),
211
+ "take-defaults": core_1.Flags.boolean({ exclusive: ["silent"], description: "Setting this to true prevents prompting for confirmation on parameters that were passed in or were automatically set to default values (Irrelevant in --silent mode). This behavior does NOT apply to scenarios that the command needs to override invalid user input; such cases will always prompt for confirmation. eg: when no argument was provided for file or type, and only one exists, the system will render the autoselected file unless this flag is set." })
212
+ };
213
+ EnvironmentClusterAttach.args = {};
214
+ //# sourceMappingURL=attach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach.js","sourceRoot":"","sources":["../../../../src/commands/environment/cluster/attach.ts"],"names":[],"mappings":";;;AAAA,sCAA4C;AAI5C,4BAA6B;AAG7B,kEAA6D;AAE7D,sEAAoE;AAapE,MAAqB,wBAAyB,SAAQ,mCAAmC;IAmB1E,WAAW,CAAC,cAAsB;;;YAC7C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAEnE,IAAI,OAAO,GAA8C;gBACvD,UAAU,EAAE,MAAA,KAAK,CAAC,UAAU,mCAAI,cAAc;aAC/C,CAAC;YAEF,IAAI,KAAK,CAAC,WAAW;gBAAE,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC;YACnE,IAAI,KAAK,CAAC,OAAO;gBAAE,OAAO,CAAC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AACxJ,gCAAO,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAEpC,8BAAK,GAAG;IACb,UAAU,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,mHAAmH,EAAE,CAAC;IACzK,WAAW,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;IACjH,OAAO,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IAE1F,uCAAuC;IACvC,MAAM,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,4GAA4G,EAAE,CAAC;IACtL,IAAI,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,kHAAkH,EAAE,CAAC;IAC5L,WAAW,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,sGAAsG,EAAE,CAAC;IAClL,eAAe,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,ycAAyc,EAAE,CAAC;CAClhB,CAAA;AAEM,6BAAI,GAAG,EAAE,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { RootMap } from '../../../apis/codiac-api/contracts';
2
+ import { CommandBaseExec } from '../../../command-base-exec';
3
+ import { AtLeast } from '@codiac.io/codiac-common/contracts';
4
+ import { InteractionModes } from '../../../uilogic/config-ui-utils';
5
+ import { IEnviroClusterPair } from '../../../uilogic/rootmap-ui-utils';
6
+ export type FlatEnviro = {
7
+ name: string;
8
+ sequence?: number | undefined;
9
+ enterprise: string;
10
+ clusters: {
11
+ name: string;
12
+ provider: string;
13
+ locationName: string;
14
+ }[];
15
+ };
16
+ export default class EnvironmentClusterDetach extends CommandBaseExec<IEnviroClusterPair> {
17
+ static description: string;
18
+ static aliases: string[];
19
+ static flags: {
20
+ enterprise: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
21
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
22
+ cluster: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
23
+ silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
24
+ echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
25
+ "to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
26
+ "take-defaults": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
27
+ };
28
+ static args: {};
29
+ captureArgs(enterpriseCode: string): Promise<[AtLeast<IEnviroClusterPair, 'enterprise'>, InteractionModes | undefined, boolean]>;
30
+ buildCandidate_silently(partial: AtLeast<IEnviroClusterPair, 'enterprise'>, rootMap: RootMap): Promise<IEnviroClusterPair | undefined>;
31
+ buildCandidate_interactively(partial: AtLeast<IEnviroClusterPair, 'enterprise'>, rootMap: RootMap, takeDefaults: boolean): Promise<IEnviroClusterPair | undefined>;
32
+ buildCommandString(candidate: IEnviroClusterPair, cmd: string[]): string[];
33
+ executeTask(candidate: IEnviroClusterPair): Promise<void>;
34
+ private buildEnviroListForText;
35
+ private buildEnviroClusterDesc;
36
+ private buildEnviroTree;
37
+ private FlattenEnviros;
38
+ }