@codiac.io/codiac-cli 1.3.67 → 1.3.69

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 (272) hide show
  1. package/README.md +1 -1
  2. package/dist/apis/api-plus-local/api-client-plus-local.d.ts +12 -4
  3. package/dist/apis/api-plus-local/api-client-plus-local.js +121 -92
  4. package/dist/apis/api-plus-local/api-client-plus-local.js.map +1 -1
  5. package/dist/apis/api-plus-local/asset-where-entity-merger.d.ts +4 -2
  6. package/dist/apis/api-plus-local/asset-where-entity-merger.js +17 -8
  7. package/dist/apis/api-plus-local/asset-where-entity-merger.js.map +1 -1
  8. package/dist/apis/api-plus-local/enterprise-state-entity-merger.d.ts +3 -2
  9. package/dist/apis/api-plus-local/enterprise-state-entity-merger.js +13 -2
  10. package/dist/apis/api-plus-local/enterprise-state-entity-merger.js.map +1 -1
  11. package/dist/apis/api-plus-local/root-map-entity-merger.d.ts +7 -3
  12. package/dist/apis/api-plus-local/root-map-entity-merger.js +19 -8
  13. package/dist/apis/api-plus-local/root-map-entity-merger.js.map +1 -1
  14. package/dist/apis/codiac-api/gen/contracts.d.ts +38 -4
  15. package/dist/apis/codiac-api/gen/contracts.js +2 -0
  16. package/dist/apis/codiac-api/gen/contracts.js.map +1 -1
  17. package/dist/apis/codiac-relay/common/api-user-creds.d.ts +2 -2
  18. package/dist/apis/codiac-relay/common/api-user-creds.js +2 -1
  19. package/dist/apis/codiac-relay/common/api-user-creds.js.map +1 -1
  20. package/dist/apis/codiac-relay/gen/client.d.ts +5 -1
  21. package/dist/apis/codiac-relay/gen/client.js +16 -0
  22. package/dist/apis/codiac-relay/gen/client.js.map +1 -1
  23. package/dist/apis/codiac-relay/gen/contracts.d.ts +129 -2
  24. package/dist/apis/codiac-relay/gen/contracts.js +12 -1
  25. package/dist/apis/codiac-relay/gen/contracts.js.map +1 -1
  26. package/dist/apis/nats/nats-client.d.ts +1 -0
  27. package/dist/apis/nats/nats-client.js +8 -4
  28. package/dist/apis/nats/nats-client.js.map +1 -1
  29. package/dist/cli-common/argument-manager.d.ts +1 -1
  30. package/dist/cli-common/command-base.d.ts +6 -4
  31. package/dist/cli-common/command-base.js +32 -22
  32. package/dist/cli-common/command-base.js.map +1 -1
  33. package/dist/codiac-constants.d.ts +2 -0
  34. package/dist/codiac-constants.js +2 -0
  35. package/dist/codiac-constants.js.map +1 -1
  36. package/dist/command-base-enterprise.d.ts +2 -1
  37. package/dist/command-base-enterprise.js +10 -7
  38. package/dist/command-base-enterprise.js.map +1 -1
  39. package/dist/command-base-tenantless.d.ts +2 -1
  40. package/dist/command-base-tenantless.js +12 -10
  41. package/dist/command-base-tenantless.js.map +1 -1
  42. package/dist/commands/asset/create.d.ts +2 -8
  43. package/dist/commands/asset/create.js +24 -4
  44. package/dist/commands/asset/create.js.map +1 -1
  45. package/dist/commands/asset/deploy.d.ts +8 -4
  46. package/dist/commands/asset/deploy.js +58 -29
  47. package/dist/commands/asset/deploy.js.map +1 -1
  48. package/dist/commands/asset/entrypoint/delete.js +3 -3
  49. package/dist/commands/asset/entrypoint/delete.js.map +1 -1
  50. package/dist/commands/asset/entrypoint/set.js +3 -3
  51. package/dist/commands/asset/entrypoint/set.js.map +1 -1
  52. package/dist/commands/asset/list.d.ts +2 -0
  53. package/dist/commands/asset/list.js +4 -0
  54. package/dist/commands/asset/list.js.map +1 -1
  55. package/dist/commands/asset/view.d.ts +4 -4
  56. package/dist/commands/asset/view.js +3 -2
  57. package/dist/commands/asset/view.js.map +1 -1
  58. package/dist/commands/cabinet/create.d.ts +2 -1
  59. package/dist/commands/cabinet/create.js +15 -2
  60. package/dist/commands/cabinet/create.js.map +1 -1
  61. package/dist/commands/cabinet/obliterate.d.ts +3 -1
  62. package/dist/commands/cabinet/obliterate.js +6 -2
  63. package/dist/commands/cabinet/obliterate.js.map +1 -1
  64. package/dist/commands/cluster/start.d.ts +37 -0
  65. package/dist/commands/cluster/start.js +191 -0
  66. package/dist/commands/cluster/start.js.map +1 -0
  67. package/dist/commands/cluster/stop.d.ts +36 -0
  68. package/dist/commands/cluster/stop.js +190 -0
  69. package/dist/commands/cluster/stop.js.map +1 -0
  70. package/dist/commands/config/add.d.ts +3 -2
  71. package/dist/commands/config/add.js +8 -25
  72. package/dist/commands/config/add.js.map +1 -1
  73. package/dist/commands/config/delete.js +7 -4
  74. package/dist/commands/config/delete.js.map +1 -1
  75. package/dist/commands/config/settings/get.js +7 -4
  76. package/dist/commands/config/settings/get.js.map +1 -1
  77. package/dist/commands/config/view.d.ts +0 -1
  78. package/dist/commands/config/view.js +5 -39
  79. package/dist/commands/config/view.js.map +1 -1
  80. package/dist/commands/environment/cluster/attach.js +15 -4
  81. package/dist/commands/environment/cluster/attach.js.map +1 -1
  82. package/dist/commands/environment/cluster/detach.js +6 -1
  83. package/dist/commands/environment/cluster/detach.js.map +1 -1
  84. package/dist/commands/environment/create.d.ts +1 -0
  85. package/dist/commands/environment/create.js +22 -3
  86. package/dist/commands/environment/create.js.map +1 -1
  87. package/dist/commands/environment/list.d.ts +3 -0
  88. package/dist/commands/environment/list.js +20 -7
  89. package/dist/commands/environment/list.js.map +1 -1
  90. package/dist/commands/filestore/capture.js.map +1 -1
  91. package/dist/commands/imageRegistry/capture.js +4 -0
  92. package/dist/commands/imageRegistry/capture.js.map +1 -1
  93. package/dist/commands/imageRegistry/list.d.ts +29 -0
  94. package/dist/commands/imageRegistry/list.js +108 -0
  95. package/dist/commands/imageRegistry/list.js.map +1 -0
  96. package/dist/commands/init.js +4 -4
  97. package/dist/commands/init.js.map +1 -1
  98. package/dist/commands/noc/cluster/capture.d.ts +0 -2
  99. package/dist/commands/noc/cluster/capture.js +2 -9
  100. package/dist/commands/noc/cluster/capture.js.map +1 -1
  101. package/dist/commands/noc/cluster/create.d.ts +20 -0
  102. package/dist/commands/noc/cluster/create.js +244 -17
  103. package/dist/commands/noc/cluster/create.js.map +1 -1
  104. package/dist/commands/noc/cluster/destroy.d.ts +4 -0
  105. package/dist/commands/noc/cluster/destroy.js +38 -9
  106. package/dist/commands/noc/cluster/destroy.js.map +1 -1
  107. package/dist/commands/noc/cluster/forget.d.ts +2 -1
  108. package/dist/commands/noc/cluster/forget.js +20 -3
  109. package/dist/commands/noc/cluster/forget.js.map +1 -1
  110. package/dist/commands/noc/cluster/list.js +6 -2
  111. package/dist/commands/noc/cluster/list.js.map +1 -1
  112. package/dist/message-contracts/terminal-command-request.d.ts +66 -0
  113. package/dist/message-contracts/terminal-command-request.js +13 -0
  114. package/dist/message-contracts/terminal-command-request.js.map +1 -0
  115. package/dist/ops/LocalOps.d.ts +1 -1
  116. package/dist/ops/LocalOps.js +4 -4
  117. package/dist/ops/LocalOps.js.map +1 -1
  118. package/dist/ops/entities/cli-config.d.ts +2 -1
  119. package/dist/ops/entities/cli-config.js +3 -2
  120. package/dist/ops/entities/cli-config.js.map +1 -1
  121. package/dist/ops/index.d.ts +0 -3
  122. package/dist/ops/index.js +3 -3
  123. package/dist/ops/index.js.map +1 -1
  124. package/dist/ops/k8s/k8s-utils.js.map +1 -1
  125. package/dist/ops/scaffolding/base-scaffolding.d.ts +1 -1
  126. package/dist/ops/scaffolding/base-scaffolding.js +2 -1
  127. package/dist/ops/scaffolding/base-scaffolding.js.map +1 -1
  128. package/dist/ops/scaffolding/codiac-api-scaffolding.js.map +1 -1
  129. package/dist/ops/scaffolding/typescript-scaffolding.d.ts +2 -1
  130. package/dist/ops/scaffolding/typescript-scaffolding.js +2 -1
  131. package/dist/ops/scaffolding/typescript-scaffolding.js.map +1 -1
  132. package/dist/ops/terminal-command-runner/local-command-runner.d.ts +41 -0
  133. package/dist/ops/terminal-command-runner/local-command-runner.js +146 -0
  134. package/dist/ops/terminal-command-runner/local-command-runner.js.map +1 -0
  135. package/dist/ops/terminal-utils.d.ts +56 -0
  136. package/dist/ops/terminal-utils.js +721 -0
  137. package/dist/ops/terminal-utils.js.map +1 -0
  138. package/dist/relay/relay-container.js +4 -1
  139. package/dist/relay/relay-container.js.map +1 -1
  140. package/dist/relay/wsclient/relay-websocket-client.d.ts +3 -0
  141. package/dist/relay/wsclient/relay-websocket-client.js +9 -0
  142. package/dist/relay/wsclient/relay-websocket-client.js.map +1 -1
  143. package/dist/sdk/codiac-sdk-for-cli.d.ts +29 -0
  144. package/dist/sdk/codiac-sdk-for-cli.js +83 -0
  145. package/dist/sdk/codiac-sdk-for-cli.js.map +1 -0
  146. package/dist/sdk/i-cluster-configurator.js.map +1 -0
  147. package/dist/sdk/i-file-store-configurator.js.map +1 -0
  148. package/dist/{uilogic → sdk}/i-login-configurator.d.ts +10 -3
  149. package/dist/sdk/i-login-configurator.js.map +1 -0
  150. package/dist/sdk/i-registry-configurator.js.map +1 -0
  151. package/dist/sdk/i-secret-store-configurator.js.map +1 -0
  152. package/dist/sdk/index.d.ts +7 -0
  153. package/dist/sdk/index.js +11 -0
  154. package/dist/sdk/index.js.map +1 -0
  155. package/dist/sdk-adapters/artifact-hub/artifact-hub-cli-adapter.d.ts +6 -0
  156. package/dist/sdk-adapters/artifact-hub/artifact-hub-cli-adapter.js +16 -0
  157. package/dist/sdk-adapters/artifact-hub/artifact-hub-cli-adapter.js.map +1 -0
  158. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/artifact-hub}/helm-resource-configurator.d.ts +4 -4
  159. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/artifact-hub}/helm-resource-configurator.js +5 -1
  160. package/dist/sdk-adapters/artifact-hub/helm-resource-configurator.js.map +1 -0
  161. package/dist/sdk-adapters/artifact-hub/index.d.ts +2 -0
  162. package/dist/sdk-adapters/artifact-hub/index.js +6 -0
  163. package/dist/sdk-adapters/artifact-hub/index.js.map +1 -0
  164. package/dist/sdk-adapters/aws/aws-cli-adapter.d.ts +6 -0
  165. package/dist/sdk-adapters/aws/aws-cli-adapter.js +20 -0
  166. package/dist/sdk-adapters/aws/aws-cli-adapter.js.map +1 -0
  167. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/aws}/aws-resource-configurator.d.ts +4 -7
  168. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/aws}/aws-resource-configurator.js +8 -2
  169. package/dist/sdk-adapters/aws/aws-resource-configurator.js.map +1 -0
  170. package/dist/sdk-adapters/aws/index.d.ts +2 -0
  171. package/dist/sdk-adapters/aws/index.js +6 -0
  172. package/dist/sdk-adapters/aws/index.js.map +1 -0
  173. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/azure}/az-interactive-login-configurator.d.ts +6 -7
  174. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/azure}/az-interactive-login-configurator.js +7 -8
  175. package/dist/sdk-adapters/azure/az-interactive-login-configurator.js.map +1 -0
  176. package/dist/sdk-adapters/azure/azure-cli-adapter.d.ts +6 -0
  177. package/dist/sdk-adapters/azure/azure-cli-adapter.js +20 -0
  178. package/dist/sdk-adapters/azure/azure-cli-adapter.js.map +1 -0
  179. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/azure}/azure-resource-configurator.d.ts +2 -11
  180. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/azure}/azure-resource-configurator.js +13 -27
  181. package/dist/sdk-adapters/azure/azure-resource-configurator.js.map +1 -0
  182. package/dist/sdk-adapters/azure/index.d.ts +3 -0
  183. package/dist/sdk-adapters/azure/index.js +7 -0
  184. package/dist/sdk-adapters/azure/index.js.map +1 -0
  185. package/dist/sdk-adapters/docker-hub/docker-hub-cli-adapter.d.ts +6 -0
  186. package/dist/sdk-adapters/docker-hub/docker-hub-cli-adapter.js +16 -0
  187. package/dist/sdk-adapters/docker-hub/docker-hub-cli-adapter.js.map +1 -0
  188. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/docker-hub}/docker-hub-resource-configurator.d.ts +4 -4
  189. package/dist/{uilogic/cloud-resource-configurators → sdk-adapters/docker-hub}/docker-hub-resource-configurator.js +7 -1
  190. package/dist/sdk-adapters/docker-hub/docker-hub-resource-configurator.js.map +1 -0
  191. package/dist/sdk-adapters/docker-hub/index.d.ts +2 -0
  192. package/dist/sdk-adapters/docker-hub/index.js +6 -0
  193. package/dist/sdk-adapters/docker-hub/index.js.map +1 -0
  194. package/dist/sdk-adapters/local-machine/index.js +4 -0
  195. package/dist/sdk-adapters/local-machine/index.js.map +1 -0
  196. package/dist/sdk-adapters/local-machine/local-machine-cli-adapter.js +14 -0
  197. package/dist/sdk-adapters/local-machine/local-machine-cli-adapter.js.map +1 -0
  198. package/dist/sdk-adapters/local-machine/local-machine-login-configurator.d.ts +17 -0
  199. package/dist/sdk-adapters/local-machine/local-machine-login-configurator.js +66 -0
  200. package/dist/sdk-adapters/local-machine/local-machine-login-configurator.js.map +1 -0
  201. package/dist/sdk-adapters/local-machine/local-machine-resource-configurator.d.ts +20 -0
  202. package/dist/sdk-adapters/local-machine/local-machine-resource-configurator.js +121 -0
  203. package/dist/sdk-adapters/local-machine/local-machine-resource-configurator.js.map +1 -0
  204. package/dist/sdk-adapters/shared/resource-configurator-base.d.ts +30 -0
  205. package/dist/sdk-adapters/shared/resource-configurator-base.js +124 -0
  206. package/dist/sdk-adapters/shared/resource-configurator-base.js.map +1 -0
  207. package/dist/uilogic/build-configurator.d.ts +2 -1
  208. package/dist/uilogic/build-configurator.js.map +1 -1
  209. package/dist/uilogic/cloud-provider-contextualizer.d.ts +4 -4
  210. package/dist/uilogic/cloud-provider-contextualizer.js +24 -9
  211. package/dist/uilogic/cloud-provider-contextualizer.js.map +1 -1
  212. package/dist/uilogic/cloud-resource-configurator-factory.d.ts +6 -10
  213. package/dist/uilogic/cloud-resource-configurator-factory.js +31 -19
  214. package/dist/uilogic/cloud-resource-configurator-factory.js.map +1 -1
  215. package/dist/uilogic/cloud-resource-configurators/asset-configurator.d.ts +8 -1
  216. package/dist/uilogic/cloud-resource-configurators/asset-configurator.js.map +1 -1
  217. package/dist/uilogic/cloud-resource-configurators/unsupported-resource-configurator.d.ts +1 -1
  218. package/dist/uilogic/config-ui-utils.d.ts +19 -14
  219. package/dist/uilogic/config-ui-utils.js +66 -21
  220. package/dist/uilogic/config-ui-utils.js.map +1 -1
  221. package/dist/uilogic/enterprise-contextualizer.d.ts +2 -1
  222. package/dist/uilogic/enterprise-contextualizer.js.map +1 -1
  223. package/dist/uilogic/i-messaging-client.d.ts +1 -0
  224. package/dist/uilogic/image-registry-contextualizer.d.ts +3 -3
  225. package/dist/uilogic/image-registry-contextualizer.js +4 -2
  226. package/dist/uilogic/image-registry-contextualizer.js.map +1 -1
  227. package/dist/uilogic/index.d.ts +0 -4
  228. package/dist/uilogic/index.js +0 -4
  229. package/dist/uilogic/index.js.map +1 -1
  230. package/dist/uilogic/lrp-watcher-predef.js +10 -4
  231. package/dist/uilogic/lrp-watcher-predef.js.map +1 -1
  232. package/dist/uilogic/rootmap-ui-utils.d.ts +2 -0
  233. package/dist/uilogic/rootmap-ui-utils.js +35 -11
  234. package/dist/uilogic/rootmap-ui-utils.js.map +1 -1
  235. package/dist/uilogic/tenant-contextualizer.d.ts +1 -1
  236. package/dist/uilogic/tenant-contextualizer.js.map +1 -1
  237. package/dist/uilogic/type-safety-utils.d.ts +11 -0
  238. package/dist/uilogic/type-safety-utils.js +13 -0
  239. package/dist/uilogic/type-safety-utils.js.map +1 -1
  240. package/dist/uilogic/validators/non-empty-validator.d.ts +7 -0
  241. package/dist/uilogic/validators/non-empty-validator.js +20 -0
  242. package/dist/uilogic/validators/non-empty-validator.js.map +1 -0
  243. package/dist/uilogic/validators/semver-range-validator.d.ts +1 -1
  244. package/dist/uilogic/validators/semver-range-validator.js +2 -2
  245. package/dist/uilogic/validators/semver-range-validator.js.map +1 -1
  246. package/oclif.manifest.json +243 -23
  247. package/package.json +4 -4
  248. package/dist/ops/azure-container-registry-client/azure-container-registry-client.js +0 -148
  249. package/dist/ops/azure-container-registry-client/azure-container-registry-client.js.map +0 -1
  250. package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.js.map +0 -1
  251. package/dist/uilogic/cloud-resource-configurators/az-interactive-login-configurator.js.map +0 -1
  252. package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.js.map +0 -1
  253. package/dist/uilogic/cloud-resource-configurators/azure-types.js +0 -10
  254. package/dist/uilogic/cloud-resource-configurators/azure-types.js.map +0 -1
  255. package/dist/uilogic/cloud-resource-configurators/docker-hub-resource-configurator.js.map +0 -1
  256. package/dist/uilogic/cloud-resource-configurators/helm-resource-configurator.js.map +0 -1
  257. package/dist/uilogic/i-cluster-configurator.js.map +0 -1
  258. package/dist/uilogic/i-file-store-configurator.js.map +0 -1
  259. package/dist/uilogic/i-login-configurator.js.map +0 -1
  260. package/dist/uilogic/i-registry-configurator.js.map +0 -1
  261. package/dist/uilogic/i-secret-store-configurator.js.map +0 -1
  262. /package/dist/{uilogic → sdk}/i-cluster-configurator.d.ts +0 -0
  263. /package/dist/{uilogic → sdk}/i-cluster-configurator.js +0 -0
  264. /package/dist/{uilogic → sdk}/i-file-store-configurator.d.ts +0 -0
  265. /package/dist/{uilogic → sdk}/i-file-store-configurator.js +0 -0
  266. /package/dist/{uilogic → sdk}/i-login-configurator.js +0 -0
  267. /package/dist/{uilogic → sdk}/i-registry-configurator.d.ts +0 -0
  268. /package/dist/{uilogic → sdk}/i-registry-configurator.js +0 -0
  269. /package/dist/{uilogic → sdk}/i-secret-store-configurator.d.ts +0 -0
  270. /package/dist/{uilogic → sdk}/i-secret-store-configurator.js +0 -0
  271. /package/dist/{ops/azure-container-registry-client/azure-container-registry-client.d.ts → sdk-adapters/local-machine/index.d.ts} +0 -0
  272. /package/dist/{uilogic/cloud-resource-configurators/azure-types.d.ts → sdk-adapters/local-machine/local-machine-cli-adapter.d.ts} +0 -0
@@ -0,0 +1,191 @@
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 config_ui_utils_1 = require("../../uilogic/config-ui-utils");
7
+ const command_base_exec_tenant_1 = require("../../command-base-exec-tenant");
8
+ const contracts_1 = require("../../apis/codiac-api/contracts");
9
+ const type_safety_utils_1 = require("../../uilogic/type-safety-utils");
10
+ const terminal_utils_1 = require("../../ops/terminal-utils");
11
+ const local_command_runner_1 = require("../../ops/terminal-command-runner/local-command-runner");
12
+ const clusterProjxn = { pathsIncluded: ["id", "name", "provider", "locationName", "instance", "modified", "modifiedBy"], pathsExcluded: [] };
13
+ class ClusterStart extends command_base_exec_tenant_1.CommandBaseExecTenant {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.adminOnly = true;
17
+ }
18
+ // --------------------------------------------------------------------
19
+ // Lazy-loaded properties
20
+ get termUtils() {
21
+ if (this._termUtils_backer === undefined) {
22
+ this._termUtils_backer = this.ioc.get(terminal_utils_1.TerminalUtils); // new TerminalUtils(this.logger);
23
+ }
24
+ return this._termUtils_backer;
25
+ }
26
+ get localCommandRunner() {
27
+ if (this._localCommandRunner_backer === undefined) {
28
+ this._localCommandRunner_backer = this.ioc.get(local_command_runner_1.LocalCommandRunner); // new LocalCommandRunner(this.msgClient, this.cliEnviro, this.termUtils, this.logger);
29
+ }
30
+ return this._localCommandRunner_backer;
31
+ }
32
+ // --------------------------------------------------------------------
33
+ bootstrap() {
34
+ super.bootstrap();
35
+ this.ioc.bind(terminal_utils_1.TerminalUtils).toDynamicValue(ctx => new terminal_utils_1.TerminalUtils(this.logger));
36
+ this.ioc.bind(local_command_runner_1.LocalCommandRunner).toDynamicValue(ctx => new local_command_runner_1.LocalCommandRunner(this.msgClient, this.cliEnviro, this.termUtils, this.logger));
37
+ }
38
+ captureArgs() {
39
+ var _a, _b;
40
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
+ const { args, flags } = yield this.parse(ClusterStart);
42
+ let partial = {};
43
+ if (args.cluster)
44
+ partial.cluster = args.cluster;
45
+ // ---------------------------------------------------------------
46
+ // TODO: move everything from here down into the base class
47
+ // ---------------------------------------------------------------
48
+ 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);
49
+ const takeDefaults = flags['take-defaults'];
50
+ return [partial, interactionMode, takeDefaults];
51
+ });
52
+ }
53
+ // /** Throws on invalid */
54
+ // private validate(partial: Partial<IAuthRoleDef>): void {
55
+ // if (partial.name == undefined || _.isEmpty(partial.name)) throw new Error("Missing name");
56
+ // let rxName = /^[a-zA-Z][a-zA-Z0-9-]{2,50}$/;
57
+ // if (!rxName.test(partial.name)) throw new Error("Invalid name: must be 3- to 50-character string of alphanumerics and hyphens, starting with a letter.");
58
+ // }
59
+ buildCandidate_silently(partial, rootMap) {
60
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
61
+ if (partial.cluster == undefined || _.isEmpty(partial.cluster))
62
+ throw new Error("Must specify cluster.");
63
+ // Enforce a valid local cluster
64
+ const found = rootMap.clusters.find(c => c.name == partial.cluster);
65
+ if (found == undefined) {
66
+ throw new Error("No cluster found with that name.");
67
+ }
68
+ else if (type_safety_utils_1.TypeSafetyUtils.toBoolean(found === null || found === void 0 ? void 0 : found.thisMachine) != true) {
69
+ throw new Error("This command is only applicable to clusters that exist on this machine.");
70
+ }
71
+ let candidate = {
72
+ cluster: partial.cluster,
73
+ provider: found.provider
74
+ };
75
+ return candidate;
76
+ });
77
+ }
78
+ buildCandidate_interactively(partial, takeDefaults, rootMap) {
79
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
80
+ // Enforce a valid local cluster
81
+ let forceConfirm = false;
82
+ if (partial.cluster) {
83
+ const found = rootMap.clusters.find(c => c.name == partial.cluster);
84
+ if (found == undefined) {
85
+ partial.cluster = undefined;
86
+ forceConfirm = true;
87
+ }
88
+ else if (type_safety_utils_1.TypeSafetyUtils.toBoolean(found === null || found === void 0 ? void 0 : found.thisMachine) != true) {
89
+ partial.cluster = undefined;
90
+ forceConfirm = true;
91
+ }
92
+ }
93
+ let clusters = rootMap.clusters.filter(c => type_safety_utils_1.TypeSafetyUtils.toBoolean(c.thisMachine) == true)
94
+ .map(c => c);
95
+ let selected;
96
+ if (clusters.length == 1 && (takeDefaults == true)) {
97
+ selected = clusters[0];
98
+ }
99
+ else {
100
+ selected = yield this.promptForCluster(clusters, partial.cluster);
101
+ }
102
+ partial.cluster = selected.name;
103
+ partial.provider = selected.provider;
104
+ let candidate = {
105
+ cluster: partial.cluster,
106
+ provider: partial.provider
107
+ };
108
+ return candidate;
109
+ });
110
+ }
111
+ buildCommandString(candidate, cmd) {
112
+ cmd.push("--silent");
113
+ cmd.push(candidate.cluster);
114
+ return cmd;
115
+ }
116
+ executeTask(candidate) {
117
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
118
+ try {
119
+ if (candidate.provider == contracts_1.CloudProviderEnum.localMachine) {
120
+ yield this.msgClient.connect();
121
+ this.localCommandRunner.listen(); // to fire off any local machine terminal commands requested by the relay during the cluster create
122
+ }
123
+ let result = yield this.watcher.triggerAndWatch((socketId) => this.genRelayClient.Call.startCluster({ cluster: candidate.cluster, socketId: socketId }));
124
+ if (result.error) {
125
+ this.logger.error(`Error starting cluster: ${result.message || ""}; ${result.error.message}`, result.error);
126
+ this._ui.userMessage(`Error starting cluster: ${result.message || ""}; ${result.error.message}`);
127
+ }
128
+ else if (!result.success) {
129
+ this.logger.notice(`Cluster start failed without error. ${result.message}`);
130
+ this._ui.userMessage(`Cluster start failed without error. ${result.message}`);
131
+ }
132
+ else {
133
+ const msg = this._styler.colorGood("SUCCESS!").concat(" Started cluster [", this._styler.hilite(candidate.cluster), "].");
134
+ this.logger.notice(msg, result);
135
+ this._ui.userMessage(msg);
136
+ }
137
+ return;
138
+ }
139
+ catch (err) {
140
+ throw err;
141
+ }
142
+ finally {
143
+ if (this.msgClient.isConnected()) {
144
+ yield this.msgClient.disconnect();
145
+ }
146
+ }
147
+ });
148
+ }
149
+ /** Renders a user-friendly cluster description. */
150
+ describe(cluster) {
151
+ return cluster.name.concat(" ", this._styler.dim("(" + cluster.provider + ")"));
152
+ }
153
+ /** Returns the name of the selected cluster.
154
+ */
155
+ promptForCluster(clusters, defaultValue) {
156
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
157
+ let output;
158
+ let keep = false;
159
+ if (defaultValue && clusters.find(c => c.name === defaultValue)) {
160
+ keep = yield this._ui.promptConfirm("clusterNameConfirm", `Local Cluster: [${this._styler.hilite(defaultValue)}]`, true);
161
+ }
162
+ if (keep === true) {
163
+ output = clusters.find(c => c.name === defaultValue);
164
+ }
165
+ else {
166
+ let choices = clusters
167
+ .map(c => { return { name: this.describe(c), value: c.name }; });
168
+ let selectedName = (yield this._ui.promptSelect("clusterName", "Select the local cluster:", choices));
169
+ output = clusters.find(c => c.name === selectedName);
170
+ }
171
+ return output;
172
+ });
173
+ }
174
+ }
175
+ exports.default = ClusterStart;
176
+ ClusterStart.description = 'For local machine clusters only. (Idempotent) Ensures that the specified local machine cluster is running and not inactive. Clusters can consume significant local resources, since they cannot be scaled like they can in the cloud, so this command and `cluster stop` together enable a user to determine which a clusters are actually running or not at any given time.';
177
+ ClusterStart.aliases = [];
178
+ ClusterStart.examples = [
179
+ '<%= config.bin %> cluster start my-fav-cluster'
180
+ ];
181
+ ClusterStart.flags = {
182
+ // TODO: Move these into the base class
183
+ 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.' }),
184
+ 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.' }),
185
+ "to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Toscript interaction mode; renders the equivalent non-interactive cli command WITHOUT any execution.' }),
186
+ "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." })
187
+ };
188
+ ClusterStart.args = {
189
+ cluster: core_1.Args.string({ description: 'Name of the LOCAL cluster in Codiac (Optional: required only if you have more than one cluster for the current organization on this machine). You can use `cod cluster list` to see the names of your codiac clusters.' }),
190
+ };
191
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/cluster/start.ts"],"names":[],"mappings":";;;AAAA,sCAAyC;AACzC,4BAA6B;AAC7B,mEAAiE;AACjE,6EAAuE;AACvE,+DAAyF;AAGzF,uEAAkE;AAClE,6DAAyD;AACzD,iGAA4F;AAO5F,MAAM,aAAa,GAAe,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;AAMzJ,MAAqB,YAAa,SAAQ,gDAAgD;IAA1F;;QAqBY,cAAS,GAAG,IAAI,CAAC;IAoM7B,CAAC;IAhMC,uEAAuE;IACvE,yBAAyB;IAEzB,IAAY,SAAS;QACnB,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE;YACxC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,8BAAa,CAAC,CAAC,CAAC,kCAAkC;SACzF;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAID,IAAY,kBAAkB;QAC5B,IAAI,IAAI,CAAC,0BAA0B,KAAK,SAAS,EAAE;YACjD,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,yCAAkB,CAAC,CAAC,CAAE,wFAAwF;SAC9J;QACD,OAAO,IAAI,CAAC,0BAA0B,CAAC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}
@@ -0,0 +1,36 @@
1
+ import { InteractionModes } from '../../uilogic/config-ui-utils';
2
+ import { CommandBaseExecTenant } from '../../command-base-exec-tenant';
3
+ import { RootMap } from '../../apis/codiac-api/contracts';
4
+ export type IClusterStopRequest = {
5
+ cluster: string;
6
+ };
7
+ export default class ClusterStop extends CommandBaseExecTenant<IClusterStopRequest> {
8
+ static description: string;
9
+ static aliases: never[];
10
+ static examples: string[];
11
+ static flags: {
12
+ silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ "to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ "take-defaults": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
+ };
17
+ static args: {
18
+ cluster: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
19
+ };
20
+ protected adminOnly: boolean;
21
+ private get termUtils();
22
+ private _termUtils_backer;
23
+ private get localCommandRunner();
24
+ private _localCommandRunner_backer;
25
+ protected bootstrap(): void;
26
+ captureArgs(): Promise<[Partial<IClusterStopRequest>, InteractionModes | undefined, boolean]>;
27
+ buildCandidate_silently(partial: Partial<IClusterStopRequest>, rootMap: RootMap): Promise<IClusterStopRequest | undefined>;
28
+ buildCandidate_interactively(partial: Partial<IClusterStopRequest>, takeDefaults: boolean, rootMap: RootMap): Promise<IClusterStopRequest | undefined>;
29
+ buildCommandString(candidate: IClusterStopRequest, cmd: string[]): string[];
30
+ executeTask(candidate: IClusterStopRequest): Promise<void>;
31
+ /** Renders a user-friendly cluster description. */
32
+ private describe;
33
+ /** Returns the name of the selected cluster.
34
+ */
35
+ private promptForCluster;
36
+ }
@@ -0,0 +1,190 @@
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 config_ui_utils_1 = require("../../uilogic/config-ui-utils");
7
+ const command_base_exec_tenant_1 = require("../../command-base-exec-tenant");
8
+ const type_safety_utils_1 = require("../../uilogic/type-safety-utils");
9
+ const local_command_runner_1 = require("../../ops/terminal-command-runner/local-command-runner");
10
+ const terminal_utils_1 = require("../../ops/terminal-utils");
11
+ const clusterProjxn = { pathsIncluded: ["id", "name", "provider", "locationName", "instance", "modified", "modifiedBy"], pathsExcluded: [] };
12
+ class ClusterStop extends command_base_exec_tenant_1.CommandBaseExecTenant {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.adminOnly = true;
16
+ }
17
+ // --------------------------------------------------------------------
18
+ // Lazy-loaded properties
19
+ // protected get k8sUtils(): K8sUtils {
20
+ // if (this._k8sUtils_backer === undefined) {
21
+ // this._k8sUtils_backer = this.ioc.get(K8sUtils);
22
+ // }
23
+ // return this._k8sUtils_backer;
24
+ // }
25
+ // private _k8sUtils_backer: K8sUtils | undefined;
26
+ get termUtils() {
27
+ if (this._termUtils_backer === undefined) {
28
+ this._termUtils_backer = this.ioc.get(terminal_utils_1.TerminalUtils); // new TerminalUtils(this.logger);
29
+ }
30
+ return this._termUtils_backer;
31
+ }
32
+ get localCommandRunner() {
33
+ if (this._localCommandRunner_backer === undefined) {
34
+ this._localCommandRunner_backer = this.ioc.get(local_command_runner_1.LocalCommandRunner); // new LocalCommandRunner(this.msgClient, this.cliEnviro, this.termUtils, this.logger);
35
+ }
36
+ return this._localCommandRunner_backer;
37
+ }
38
+ // --------------------------------------------------------------------
39
+ bootstrap() {
40
+ super.bootstrap();
41
+ this.ioc.bind(terminal_utils_1.TerminalUtils).toDynamicValue(ctx => new terminal_utils_1.TerminalUtils(this.logger));
42
+ this.ioc.bind(local_command_runner_1.LocalCommandRunner).toDynamicValue(ctx => new local_command_runner_1.LocalCommandRunner(this.msgClient, this.cliEnviro, this.termUtils, this.logger));
43
+ }
44
+ captureArgs() {
45
+ var _a, _b;
46
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
47
+ const { args, flags } = yield this.parse(ClusterStop);
48
+ let partial = {};
49
+ if (args.cluster)
50
+ partial.cluster = args.cluster;
51
+ // ---------------------------------------------------------------
52
+ // TODO: move everything from here down into the base class
53
+ // ---------------------------------------------------------------
54
+ 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);
55
+ const takeDefaults = flags['take-defaults'];
56
+ return [partial, interactionMode, takeDefaults];
57
+ });
58
+ }
59
+ // /** Throws on invalid */
60
+ // private validate(partial: Partial<IAuthRoleDef>): void {
61
+ // if (partial.name == undefined || _.isEmpty(partial.name)) throw new Error("Missing name");
62
+ // let rxName = /^[a-zA-Z][a-zA-Z0-9-]{2,50}$/;
63
+ // if (!rxName.test(partial.name)) throw new Error("Invalid name: must be 3- to 50-character string of alphanumerics and hyphens, starting with a letter.");
64
+ // }
65
+ buildCandidate_silently(partial, rootMap) {
66
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
67
+ if (partial.cluster == undefined || _.isEmpty(partial.cluster))
68
+ throw new Error("Must specify cluster.");
69
+ // Enforce a valid local cluster
70
+ const found = rootMap.clusters.find(c => c.name == partial.cluster);
71
+ if (found == undefined) {
72
+ throw new Error("No cluster found with that name.");
73
+ }
74
+ else if (type_safety_utils_1.TypeSafetyUtils.toBoolean(found === null || found === void 0 ? void 0 : found.thisMachine) != true) {
75
+ throw new Error("This command is only applicable to clusters that exist on this machine.");
76
+ }
77
+ let candidate = {
78
+ cluster: partial.cluster
79
+ };
80
+ return candidate;
81
+ });
82
+ }
83
+ buildCandidate_interactively(partial, takeDefaults, rootMap) {
84
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
85
+ // Enforce a valid local cluster
86
+ let forceConfirm = false;
87
+ if (partial.cluster) {
88
+ const found = rootMap.clusters.find(c => c.name == partial.cluster);
89
+ if (found == undefined) {
90
+ partial.cluster = undefined;
91
+ forceConfirm = true;
92
+ }
93
+ else if (type_safety_utils_1.TypeSafetyUtils.toBoolean(found === null || found === void 0 ? void 0 : found.thisMachine) != true) {
94
+ partial.cluster = undefined;
95
+ forceConfirm = true;
96
+ }
97
+ }
98
+ let clusters = rootMap.clusters.filter(c => type_safety_utils_1.TypeSafetyUtils.toBoolean(c.thisMachine) == true)
99
+ .map(c => c);
100
+ let selected;
101
+ if (clusters.length == 1 && (takeDefaults == true)) {
102
+ selected = clusters[0];
103
+ }
104
+ else {
105
+ selected = yield this.promptForCluster(clusters, partial.cluster);
106
+ }
107
+ partial.cluster = selected.name;
108
+ // Prompt for output format
109
+ return yield this.buildCandidate_silently(partial, rootMap);
110
+ });
111
+ }
112
+ buildCommandString(candidate, cmd) {
113
+ cmd.push("--silent");
114
+ cmd.push(candidate.cluster);
115
+ return cmd;
116
+ }
117
+ executeTask(candidate) {
118
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
119
+ try {
120
+ let socketId = yield this.msgClient.connect();
121
+ this.localCommandRunner.listen(); // to fire off any local machine terminal commands requested by the relay during the command
122
+ let result = yield this.watcher.triggerAndWatch((socketId) => this.genRelayClient.Call.stopCluster({ cluster: candidate.cluster, socketId: socketId }));
123
+ if (result.error) {
124
+ this.logger.error(`Error stopping cluster: ${result.message || ""}; ${result.error.message}`, result.error);
125
+ this._ui.userMessage(`Error stopping cluster: ${result.message || ""}; ${result.error.message}`);
126
+ }
127
+ else if (!result.success) {
128
+ this.logger.notice(`Cluster stop failed without error. ${result.message}`);
129
+ this._ui.userMessage(`Cluster stop failed without error. ${result.message}`);
130
+ }
131
+ else {
132
+ const msg = this._styler.colorGood("SUCCESS!").concat(" Stopped cluster [", this._styler.hilite(candidate.cluster), "].");
133
+ this.logger.notice(msg, result);
134
+ this._ui.userMessage(msg);
135
+ }
136
+ }
137
+ catch (err) {
138
+ throw err;
139
+ }
140
+ finally {
141
+ if (this.msgClient.isConnected()) {
142
+ yield this.msgClient.disconnect();
143
+ }
144
+ return;
145
+ }
146
+ });
147
+ }
148
+ /** Renders a user-friendly cluster description. */
149
+ describe(cluster) {
150
+ return cluster.name.concat(" ", this._styler.dim("(" + cluster.provider + ")"));
151
+ }
152
+ /** Returns the name of the selected cluster.
153
+ */
154
+ promptForCluster(clusters, defaultValue) {
155
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
156
+ let output;
157
+ let keep = false;
158
+ if (defaultValue && clusters.find(c => c.name === defaultValue)) {
159
+ keep = yield this._ui.promptConfirm("clusterNameConfirm", `Local Cluster: [${this._styler.hilite(defaultValue)}]`, true);
160
+ }
161
+ if (keep === true) {
162
+ output = clusters.find(c => c.name === defaultValue);
163
+ }
164
+ else {
165
+ let choices = clusters
166
+ .map(c => { return { name: this.describe(c), value: c.name }; });
167
+ let selectedName = (yield this._ui.promptSelect("clusterName", "Select the local cluster:", choices));
168
+ output = clusters.find(c => c.name === selectedName);
169
+ }
170
+ return output;
171
+ });
172
+ }
173
+ }
174
+ exports.default = ClusterStop;
175
+ ClusterStop.description = 'For local machine clusters only. (Idempotent) Ensures that the specified local machine cluster is running and not inactive. Clusters can consume significant local resources, since they cannot be scaled like they can in the cloud, so this command and `cluster stop` together enable a user to determine which a clusters are actually running or not at any given time.';
176
+ ClusterStop.aliases = [];
177
+ ClusterStop.examples = [
178
+ '<%= config.bin %> cluster start my-fav-cluster'
179
+ ];
180
+ ClusterStop.flags = {
181
+ // TODO: Move these into the base class
182
+ 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.' }),
183
+ 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.' }),
184
+ "to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Toscript interaction mode; renders the equivalent non-interactive cli command WITHOUT any execution.' }),
185
+ "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." })
186
+ };
187
+ ClusterStop.args = {
188
+ cluster: core_1.Args.string({ description: 'Name of the LOCAL cluster in Codiac (Optional: required only if you have more than one cluster for the current organization on this machine). You can use `cod cluster list` to see the names of your codiac clusters.' }),
189
+ };
190
+ //# sourceMappingURL=stop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stop.js","sourceRoot":"","sources":["../../../src/commands/cluster/stop.ts"],"names":[],"mappings":";;;AAAA,sCAAyC;AACzC,4BAA6B;AAC7B,mEAAiE;AACjE,6EAAuE;AAIvE,uEAAkE;AAClE,iGAA4F;AAC5F,6DAAyD;AAOzD,MAAM,aAAa,GAAe,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;AAMzJ,MAAqB,WAAY,SAAQ,gDAA0C;IAAnF;;QAqBY,cAAS,GAAG,IAAI,CAAC;IAuM7B,CAAC;IAnMC,uEAAuE;IACvE,yBAAyB;IAEzB,uCAAuC;IACvC,+CAA+C;IAC/C,sDAAsD;IACtD,MAAM;IACN,kCAAkC;IAClC,IAAI;IACJ,kDAAkD;IAGlD,IAAY,SAAS;QACnB,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE;YACxC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,8BAAa,CAAC,CAAC,CAAC,kCAAkC;SACzF;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAID,IAAY,kBAA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,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { Command } from '@oclif/core';
2
2
  import { ScopedSetting } from '../../apis/codiac-api/contracts';
3
3
  import { CommandBaseEnterprise } from '../../command-base-enterprise';
4
- import { ConfigUiUtils, SpecialConfigTypes } from '../../uilogic/config-ui-utils';
4
+ import { ConfigUiUtils } from '../../uilogic/config-ui-utils';
5
+ import { SpecialConfigTypesEnum } from '@codiac.io/codiac-domain';
5
6
  /** The value provided as input that indicates
6
7
  * a user's desire to be prompted with a list from which choose the value(s),
7
8
  * instead of entering them manually or taking a default. */
@@ -24,7 +25,7 @@ export type ScopedValuePedigree = {
24
25
  };
25
26
  type ScopedSettingCandidate = Omit<ScopedSetting, "setting" | "value" | "targetFile"> & {
26
27
  targetFile?: string;
27
- configType?: SpecialConfigTypes;
28
+ configType?: SpecialConfigTypesEnum;
28
29
  settings: {
29
30
  setting: string;
30
31
  value: any;
@@ -153,7 +153,7 @@ class ConfigAdd extends command_base_enterprise_1.CommandBaseEnterprise {
153
153
  partial.enterprise = flags.enterprise;
154
154
  partial.asset = flags.asset;
155
155
  if (flags.type) {
156
- partial.configType = Object.values(config_ui_utils_1.SpecialConfigTypes).find(x => x.toString() == flags.type);
156
+ partial.configType = Object.values(codiac_domain_1.SpecialConfigTypesEnum).find(x => x.toString() == flags.type);
157
157
  if (partial.configType == undefined)
158
158
  delete partial.configType;
159
159
  }
@@ -229,34 +229,17 @@ class ConfigAdd extends command_base_enterprise_1.CommandBaseEnterprise {
229
229
  if (partial.targetFile == undefined && partial.configType == undefined)
230
230
  throw new Error("Invalid input: Must specify the file or type.");
231
231
  if (asset.type == contracts_1.AssetTypesEnum.helm) {
232
- if (partial.configType != config_ui_utils_1.SpecialConfigTypes.helm && partial.targetFile != "[".concat(config_ui_utils_1.SpecialConfigTypes.helm, "]")) {
232
+ if (partial.configType != codiac_domain_1.SpecialConfigTypesEnum.helm && partial.targetFile != "[".concat(codiac_domain_1.SpecialConfigTypesEnum.helm, "]")) {
233
233
  throw new Error("Invalid config type: Helm assets can only set configs of type: helm.");
234
234
  }
235
235
  }
236
- // Validate scope/target
237
- if (partial.scope == undefined || _.isEmpty(partial.scope)) {
238
- throw new Error(`Invalid input: scope required. Please set --enterprise-scope, --enviro, or --cabinet.`);
239
- }
240
- else if (!(Object.keys(contracts_1.ScopeLevel)).includes(partial.scope)) {
241
- throw new Error(`Invalid input: invalid scope level. Please set --enterprise-scope, --enviro, or --cabinet.`);
242
- }
243
- if (partial.scope == contracts_1.ScopeLevel.enterprise) {
244
- // This code should never get reached. Its just here for completeness.
245
- if ((partial.target != undefined || _.isEmpty(partial.target)) && (partial.target != partial.enterprise))
246
- throw new Error(`Invalid input: scope target for enterprise scope should match the enterprise.`);
247
- }
248
- else if (partial.target == undefined || _.isEmpty(partial.target)) {
249
- throw new Error(`Invalid input: missing scope target. Please set --enterprise-scope, --enviro, or --cabinet.`);
250
- }
251
- else if ((0, config_ui_utils_1.findScopeTarget)(rootMap, partial.scope, partial.target) == undefined) {
252
- throw new Error(`Invalid input: the given ${partial.scope} was not found.`);
253
- }
236
+ partial.thisMachine = this.configUtils.validateScope(rootMap, partial.enterprise, partial.scope, partial.target);
254
237
  if (partial.settings == undefined || partial.settings.length == 0)
255
238
  throw new Error(`Invalid input: missing setting name/value.`);
256
239
  // if (partial.setting == undefined || _.isEmpty(partial.setting)) throw new Error(`Invalid input: missing setting name.`)
257
240
  if (partial.settings[0].value == undefined || _.isEmpty(partial.settings[0].value))
258
241
  throw new Error(`Invalid input: missing setting value.`);
259
- let output = Object.assign({ enterprise: partial.enterprise, asset: partial.asset, scope: (_a = partial.scope) !== null && _a !== void 0 ? _a : contracts_1.ScopeLevel.enterprise, target: partial.target, targetFile: (partial.targetFile) ? partial.targetFile : `[${partial.configType}]`, settings: partial.settings,
242
+ let output = Object.assign({ enterprise: partial.enterprise, asset: partial.asset, scope: (_a = partial.scope) !== null && _a !== void 0 ? _a : contracts_1.ScopeLevel.enterprise, target: partial.target, thisMachine: partial.thisMachine, targetFile: (partial.targetFile) ? partial.targetFile : `[${partial.configType}]`, settings: partial.settings,
260
243
  // setting: partial.setting,
261
244
  // value: partial.value,
262
245
  description: partial.description }, this.createAuditable());
@@ -317,11 +300,11 @@ class ConfigAdd extends command_base_enterprise_1.CommandBaseEnterprise {
317
300
  // }
318
301
  // 4. Scope
319
302
  let targetChanged = false;
320
- [partial.scope, partial.target, targetChanged] = yield this.configUtils.validateAndPromptForScope(rootMap, partialConfigDef.enterprise, partial.scope, partial.target, instances, false);
303
+ [partial.scope, partial.target, targetChanged, partial.thisMachine] = yield this.configUtils.validateAndPromptForScope(rootMap, partialConfigDef.enterprise, partial.scope, partial.target, instances, false);
321
304
  partial.scope = partial.scope; // assertion operator is ok here bc we disabled AllowEverywhere in the method above
322
305
  partial.target = partial.target; // assertion operator is ok here bc we disabled AllowEverywhere in the method above
323
306
  // 5. Value
324
- value = yield this.promptForValueAndValidate(partial.configType, { setting: settingName, value: value, scope: partial.scope, target: partial.target, enterprise: partial.enterprise }, instances, rootMap, settingSchema);
307
+ value = yield this.promptForValueAndValidate(partial.configType, { setting: settingName, value: value, scope: partial.scope, target: partial.target, thisMachine: partial.thisMachine, enterprise: partial.enterprise }, instances, rootMap, settingSchema);
325
308
  partial.settings = [{ setting: settingName, value: value }];
326
309
  // 6. Confirm or loop back around to enterprise
327
310
  confirmed = yield this._ui.promptConfirm("confirm", "Apply? ");
@@ -329,7 +312,7 @@ class ConfigAdd extends command_base_enterprise_1.CommandBaseEnterprise {
329
312
  output = Object.assign({
330
313
  // setting: partial.setting,
331
314
  // value: partial.value,
332
- settings: partial.settings, targetFile: partialConfigDef.targetFile, configType: partial.configType, asset: partialConfigDef.asset, enterprise: partialConfigDef.enterprise, scope: partial.scope, target: partial.target, description: partial.description }, this.createAuditable());
315
+ settings: partial.settings, targetFile: partialConfigDef.targetFile, configType: partial.configType, asset: partialConfigDef.asset, enterprise: partialConfigDef.enterprise, scope: partial.scope, target: partial.target, thisMachine: partial.thisMachine, description: partial.description }, this.createAuditable());
333
316
  return output;
334
317
  }
335
318
  catch (err) {
@@ -814,7 +797,7 @@ ConfigAdd.flags = {
814
797
  enterprise: core_1.Flags.string({ char: 'n', description: '(required only when more than one enterprise exists) The name of the enterprise containing the asset.' }),
815
798
  asset: core_1.Flags.string({ char: 'a', description: 'The name of the asset to which the settings belong.' }),
816
799
  file: core_1.Flags.string({ char: 'f', description: 'The path-name to the file to which the settings are written, relative to the root of the Codiac project.' }),
817
- type: 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).' }),
800
+ type: core_1.Flags.string({ char: 't', exclusive: ["file"], options: Object.keys(codiac_domain_1.SpecialConfigTypesEnum), 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).' }),
818
801
  "enterprise-scope": core_1.Flags.boolean({ char: 's', exclusive: ["enviro", "cabinet"], description: 'Filters for settings scoped at the enterprise level.' }),
819
802
  enviro: core_1.Flags.string({ char: 'e', exclusive: ["enterprise-scope", "cabinet"], description: 'The name of the environment to which this value is to apply.' }),
820
803
  cabinet: core_1.Flags.string({ char: 'c', exclusive: ["enterprise-scope", "enviro"], description: 'The name of the cabinet to which this value is to apply.' }),