@codiac.io/codiac-cli 1.3.62 → 1.3.64
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 +24 -0
- package/dist/apis/codiac-api/gen/contracts.js +16 -1
- package/dist/apis/codiac-api/gen/contracts.js.map +1 -1
- package/dist/apis/codiac-relay/gen/contracts.d.ts +2 -0
- package/dist/apis/codiac-relay/gen/contracts.js.map +1 -1
- package/dist/cli-common/built-in-cli-user-input.js +2 -2
- package/dist/cli-common/built-in-cli-user-input.js.map +1 -1
- package/dist/cli-common/prompt-select-fuzzy.d.ts +3 -6
- package/dist/cli-common/prompt-select-fuzzy.js.map +1 -1
- package/dist/codiac-constants.d.ts +4 -0
- package/dist/codiac-constants.js +5 -0
- package/dist/codiac-constants.js.map +1 -1
- package/dist/commands/asset/create.d.ts +4 -7
- package/dist/commands/asset/create.js +39 -258
- package/dist/commands/asset/create.js.map +1 -1
- package/dist/commands/asset/edit.d.ts +31 -0
- package/dist/commands/asset/edit.js +131 -0
- package/dist/commands/asset/edit.js.map +1 -0
- package/dist/commands/asset/entrypoint/delete.d.ts +42 -0
- package/dist/commands/asset/entrypoint/delete.js +312 -0
- package/dist/commands/asset/entrypoint/delete.js.map +1 -0
- package/dist/commands/asset/entrypoint/set.d.ts +45 -0
- package/dist/commands/asset/entrypoint/set.js +338 -0
- package/dist/commands/asset/entrypoint/set.js.map +1 -0
- package/dist/commands/asset/list.d.ts +1 -0
- package/dist/commands/asset/list.js +20 -0
- package/dist/commands/asset/list.js.map +1 -1
- package/dist/commands/host/delete.js +2 -1
- package/dist/commands/host/delete.js.map +1 -1
- package/dist/commands/host/map.d.ts +1 -0
- package/dist/commands/host/map.js +18 -4
- package/dist/commands/host/map.js.map +1 -1
- package/dist/commands/noc/cluster/create.d.ts +32 -11
- package/dist/commands/noc/cluster/create.js +182 -119
- package/dist/commands/noc/cluster/create.js.map +1 -1
- package/dist/commands/noc/cluster/deinit.d.ts +1 -3
- package/dist/commands/noc/cluster/deinit.js +1 -1
- package/dist/commands/noc/cluster/deinit.js.map +1 -1
- package/dist/ops/i-entry-validator.d.ts +1 -1
- package/dist/relay/relay-container.js +1 -1
- package/dist/uilogic/cloud-resource-configurators/asset-configurator.d.ts +47 -0
- package/dist/uilogic/cloud-resource-configurators/asset-configurator.js +394 -0
- package/dist/uilogic/cloud-resource-configurators/asset-configurator.js.map +1 -0
- package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.d.ts +2 -0
- package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.js +58 -3
- package/dist/uilogic/cloud-resource-configurators/aws-resource-configurator.js.map +1 -1
- package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.d.ts +1 -0
- package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.js +34 -3
- package/dist/uilogic/cloud-resource-configurators/azure-resource-configurator.js.map +1 -1
- package/dist/uilogic/config-ui-utils.js +1 -1
- package/dist/uilogic/config-ui-utils.js.map +1 -1
- package/dist/uilogic/image-registry-contextualizer.d.ts +3 -2
- package/dist/uilogic/image-registry-contextualizer.js +6 -4
- package/dist/uilogic/image-registry-contextualizer.js.map +1 -1
- package/dist/uilogic/rootmap-ui-utils.js +2 -0
- package/dist/uilogic/rootmap-ui-utils.js.map +1 -1
- package/dist/uilogic/validators/semver-range-validator.d.ts +17 -0
- package/dist/uilogic/validators/semver-range-validator.js +39 -0
- package/dist/uilogic/validators/semver-range-validator.js.map +1 -0
- package/oclif.manifest.json +408 -69
- package/package.json +3 -3
|
@@ -14,7 +14,7 @@ const cli_tools_1 = require("@codiac.io/cli-tools");
|
|
|
14
14
|
const INTERFACES_CLI_1 = require("../ops/INTERFACES_CLI");
|
|
15
15
|
const Docker = require("dockerode");
|
|
16
16
|
const DEFAULT_IMAGE_NAME = "codiacimages/codiac-relay";
|
|
17
|
-
exports.DEFAULT_IMAGE_TAG = "1.4.
|
|
17
|
+
exports.DEFAULT_IMAGE_TAG = "1.4.38";
|
|
18
18
|
const DEFAULT_CONTAINER_NAME = "codiac-relay";
|
|
19
19
|
const DEFAULT_HEALTH_CHECK_URL = "http://localhost:5799/heartbeat-json"; // /ready-state";
|
|
20
20
|
const DEFAULT_RETRY_TIMOUT_IN_MINUTES = 1;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IBetterLogger } from "@codiac.io/codiac-common";
|
|
2
|
+
import { AtLeast } from "@codiac.io/codiac-common/contracts";
|
|
3
|
+
import { RelayClient as GenRelayClient } from "../../apis/codiac-relay";
|
|
4
|
+
import { Asset, PortMapping } from "../../apis/codiac-api/contracts";
|
|
5
|
+
import { PromptChoice } from "../../cli-common";
|
|
6
|
+
import { IEntryValidator, IOutputStyler, IUserInputProvider, ValidationResult } from "../../ops";
|
|
7
|
+
import { AssetCreateRequest } from "../../commands/asset/create";
|
|
8
|
+
export declare let ports: PromptChoice[];
|
|
9
|
+
export declare class AssetConfigurator {
|
|
10
|
+
private _ui;
|
|
11
|
+
private _styler;
|
|
12
|
+
private genRelayClient;
|
|
13
|
+
private logger;
|
|
14
|
+
constructor(_ui: IUserInputProvider, _styler: IOutputStyler, genRelayClient: GenRelayClient, logger: IBetterLogger);
|
|
15
|
+
isLoaded: boolean;
|
|
16
|
+
/** The largest valid port number. */
|
|
17
|
+
private readonly MAX_PORT_NUMBER;
|
|
18
|
+
/** The value to select from a port number prompt
|
|
19
|
+
* indicating the intention to remove the port number
|
|
20
|
+
* assignment altogether. */
|
|
21
|
+
private readonly REMOVE_PORT_NUMBER;
|
|
22
|
+
load(assets: Asset[]): Promise<void>;
|
|
23
|
+
/** Prompts for port, ingress, ingressInternal, HostName
|
|
24
|
+
*
|
|
25
|
+
* Throws any encountered exceptions. */
|
|
26
|
+
editAsset(partial: AtLeast<AssetCreateRequest, "enterprise">): Promise<AtLeast<AssetCreateRequest, "enterprise" | "code" | "port" | "hasIngress">>;
|
|
27
|
+
promptForAllPortAssignments(existingPorts: number | PortMapping | (number | PortMapping)[] | undefined): Promise<number | PortMapping | (number | PortMapping)[] | undefined>;
|
|
28
|
+
/** Returns undefined if user opts to remove the given port assignment. */
|
|
29
|
+
private promptForPortAssignment;
|
|
30
|
+
private selectPortNumber;
|
|
31
|
+
/** Assembles the options list for port selection.
|
|
32
|
+
* Decorates any options for ports that are already taken by an existing asset.
|
|
33
|
+
*/
|
|
34
|
+
private getPortOptionsList;
|
|
35
|
+
/** @param otherAssets CAN NOT include the current asset. */
|
|
36
|
+
private portIsValid;
|
|
37
|
+
private buildPortDesc;
|
|
38
|
+
/** Parses strings in formats: a) `<number>:<number>` and `<number>:` and `<number>`,
|
|
39
|
+
* eg: `8181` or `8181:80` or `8181:`
|
|
40
|
+
* Throws invalids. */
|
|
41
|
+
toPortMapping(portSpec: string): number | PortMapping;
|
|
42
|
+
toPortString(portDef: number | PortMapping): string;
|
|
43
|
+
}
|
|
44
|
+
export declare class HostNameValidator implements IEntryValidator<string> {
|
|
45
|
+
constructor();
|
|
46
|
+
isValid(candidate: string | undefined): ValidationResult;
|
|
47
|
+
}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HostNameValidator = exports.AssetConfigurator = exports.ports = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const inversify_1 = require("inversify");
|
|
6
|
+
const codiac_common_1 = require("@codiac.io/codiac-common");
|
|
7
|
+
const codiac_relay_1 = require("../../apis/codiac-relay");
|
|
8
|
+
const contracts_1 = require("../../apis/codiac-api/contracts");
|
|
9
|
+
const cli_common_1 = require("../../cli-common");
|
|
10
|
+
const ops_1 = require("../../ops");
|
|
11
|
+
const _ = require("lodash");
|
|
12
|
+
const type_safety_utils_1 = require("../type-safety-utils");
|
|
13
|
+
// Has to be module-scoped bc the autocomplete redefines "this", so we can't use it inside searchPorts().
|
|
14
|
+
exports.ports = [];
|
|
15
|
+
let AssetConfigurator = class AssetConfigurator {
|
|
16
|
+
constructor(_ui, _styler, genRelayClient, logger) {
|
|
17
|
+
this._ui = _ui;
|
|
18
|
+
this._styler = _styler;
|
|
19
|
+
this.genRelayClient = genRelayClient;
|
|
20
|
+
this.logger = logger;
|
|
21
|
+
this.isLoaded = false;
|
|
22
|
+
/** The largest valid port number. */
|
|
23
|
+
this.MAX_PORT_NUMBER = 65535;
|
|
24
|
+
/** The value to select from a port number prompt
|
|
25
|
+
* indicating the intention to remove the port number
|
|
26
|
+
* assignment altogether. */
|
|
27
|
+
this.REMOVE_PORT_NUMBER = -1;
|
|
28
|
+
}
|
|
29
|
+
load(assets) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
let portResult = yield this.genRelayClient.Call.getKnownPortNumbers({});
|
|
33
|
+
if (portResult.error) {
|
|
34
|
+
this.logger.warn(`Error retrieving known port number list: ${(_a = portResult.error.message) !== null && _a !== void 0 ? _a : portResult.message}`);
|
|
35
|
+
}
|
|
36
|
+
exports.ports = this.getPortOptionsList((_b = portResult.output) !== null && _b !== void 0 ? _b : [], assets);
|
|
37
|
+
exports.ports.unshift({ name: this.REMOVE_PORT_NUMBER + " (none / remove)", value: this.REMOVE_PORT_NUMBER.toString() });
|
|
38
|
+
this.isLoaded = true;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** Prompts for port, ingress, ingressInternal, HostName
|
|
42
|
+
*
|
|
43
|
+
* Throws any encountered exceptions. */
|
|
44
|
+
editAsset(partial) {
|
|
45
|
+
var _a, _b, _c, _d;
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
// PORTS
|
|
48
|
+
if (partial.type == contracts_1.AssetTypesEnum.helm) {
|
|
49
|
+
partial.port = 0; // Q: Do we need this placeholder? Better off undefined?
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
partial.port = yield this.promptForAllPortAssignments(partial.port);
|
|
53
|
+
}
|
|
54
|
+
// INGRESS
|
|
55
|
+
if (partial.type == contracts_1.AssetTypesEnum.helm) {
|
|
56
|
+
partial.hasIngress = false;
|
|
57
|
+
delete partial.routedWithoutName;
|
|
58
|
+
delete partial.code;
|
|
59
|
+
}
|
|
60
|
+
else if (partial.kit || partial.hasIngress == undefined /* || confirmed != undefined */) {
|
|
61
|
+
partial.hasIngress = yield this._ui.promptConfirm('hasIngress', 'Accessible from outside the cabinet (aka: has ingress route): ', (_a = partial.hasIngress) !== null && _a !== void 0 ? _a : false);
|
|
62
|
+
if (!partial.hasIngress) {
|
|
63
|
+
delete partial.routedWithoutName;
|
|
64
|
+
delete partial.code;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// INGRESS INTERNAL
|
|
68
|
+
if (partial.type == contracts_1.AssetTypesEnum.helm || !type_safety_utils_1.TypeSafetyUtils.toBoolean(partial.hasIngress)) {
|
|
69
|
+
delete partial.ingressInternal;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
let keep = yield this._ui.promptConfirm("isPrivateKeep", "Usage: ".concat(this._styler.hilite(type_safety_utils_1.TypeSafetyUtils.toBoolean(partial.ingressInternal) ? "private" : "external")), true);
|
|
73
|
+
if (!keep) {
|
|
74
|
+
let choices = [{ name: "External (Public DNS)", value: "false" }, { name: "Private (not available on the internet)", value: "true" }];
|
|
75
|
+
let selected = yield this._ui.promptSelect("isPrivate", "Usage:", choices, false, true);
|
|
76
|
+
partial.ingressInternal = type_safety_utils_1.TypeSafetyUtils.toBoolean(selected);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// HOST NAME
|
|
80
|
+
if (partial.kit || partial.hasIngress == true) {
|
|
81
|
+
let entry = "";
|
|
82
|
+
while (!entry || entry.trim() == "") {
|
|
83
|
+
entry = (yield this._ui.prompt('code', 'Host name on the inbound domain url: ', false, (_b = partial.code) !== null && _b !== void 0 ? _b : (_c = partial.name) === null || _c === void 0 ? void 0 : _c.toLowerCase(), new HostNameValidator()));
|
|
84
|
+
}
|
|
85
|
+
partial.code = entry.toLowerCase().trim();
|
|
86
|
+
partial.routedWithoutName = yield this._ui.promptConfirm('routedWithoutName', 'Will this asset be the base ingress against your DNS. eg: true services yourwebsite.com (as root/naked): ', (_d = partial.routedWithoutName) !== null && _d !== void 0 ? _d : false);
|
|
87
|
+
// TODO: Three can only be one asset with the option selected. Unset the others if they set this.
|
|
88
|
+
}
|
|
89
|
+
if (!partial.code)
|
|
90
|
+
partial.code = partial.name;
|
|
91
|
+
return partial; // cast bc TS wouldnt infer this for us
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
promptForAllPortAssignments(existingPorts) {
|
|
95
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
try {
|
|
97
|
+
let ultimate;
|
|
98
|
+
const existings = [];
|
|
99
|
+
if (existingPorts) {
|
|
100
|
+
if (_.isArray(existingPorts)) {
|
|
101
|
+
existings.push(...existingPorts);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
existings.push(existingPorts);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// CONFIRM/EDIT EACH EXISTING
|
|
108
|
+
let index = 0;
|
|
109
|
+
for (let existing of existings) {
|
|
110
|
+
index++;
|
|
111
|
+
let portDef = yield this.promptForPortAssignment(existing, index);
|
|
112
|
+
// Append to the ultimate
|
|
113
|
+
if (portDef == undefined) {
|
|
114
|
+
this._ui.userMessage("Port removed.");
|
|
115
|
+
index--; // reuse this index for the next port assignment
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
if (ultimate == undefined) {
|
|
119
|
+
ultimate = portDef;
|
|
120
|
+
}
|
|
121
|
+
else if (_.isArray(ultimate)) {
|
|
122
|
+
ultimate.push(portDef);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
ultimate = [ultimate, portDef];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// ADD NEW ONES
|
|
130
|
+
// Automatically start adding when none are defined yet. Otherwise, ask to add more.
|
|
131
|
+
while ((ultimate == undefined || ultimate.length == 0) || (yield this._ui.promptConfirm("onemore", "Assign another port?", false))) {
|
|
132
|
+
index++;
|
|
133
|
+
const thisPort = yield this.promptForPortAssignment(undefined, index);
|
|
134
|
+
if (thisPort == undefined) {
|
|
135
|
+
index--; // re-use on the next port number
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
this._ui.userMessage("Port ".concat(index + ": ", (typeof thisPort == 'number') ? thisPort.toString() : this.buildPortDesc(thisPort)));
|
|
139
|
+
// Append to the ultimate
|
|
140
|
+
if (ultimate == undefined) {
|
|
141
|
+
ultimate = thisPort;
|
|
142
|
+
}
|
|
143
|
+
else if (_.isArray(ultimate)) {
|
|
144
|
+
ultimate.push(thisPort);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
ultimate = [ultimate, thisPort];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return ultimate;
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
throw err;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/** Returns undefined if user opts to remove the given port assignment. */
|
|
159
|
+
promptForPortAssignment(portDef, index) {
|
|
160
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
try {
|
|
162
|
+
let thisPort;
|
|
163
|
+
// 1. Confirm existing portDef
|
|
164
|
+
let keepMapping = false;
|
|
165
|
+
if (portDef != undefined) {
|
|
166
|
+
thisPort = (typeof portDef == 'number') ? { external: portDef } : _.cloneDeep(portDef);
|
|
167
|
+
let desc = this.buildPortDesc(thisPort);
|
|
168
|
+
keepMapping = yield this._ui.promptConfirm("keepMapping", "Port ".concat(index + ": ", desc), true);
|
|
169
|
+
}
|
|
170
|
+
// 2. Declare/Edit
|
|
171
|
+
if (thisPort == undefined || !keepMapping) {
|
|
172
|
+
// SERVICE PORT (EXTERNAL)
|
|
173
|
+
let keepExt = false;
|
|
174
|
+
let promptExt = "Port ".concat(index + ": ", "Service Port (external): ");
|
|
175
|
+
if ((thisPort === null || thisPort === void 0 ? void 0 : thisPort.external) !== undefined) {
|
|
176
|
+
keepExt = yield this._ui.promptConfirm("keepExt", promptExt.concat(this._styler.hilite("" + thisPort.external)), true);
|
|
177
|
+
}
|
|
178
|
+
if (thisPort == undefined)
|
|
179
|
+
thisPort = { external: 0 };
|
|
180
|
+
if (keepExt !== true) {
|
|
181
|
+
thisPort.external = yield this.selectPortNumber(thisPort.external, promptExt);
|
|
182
|
+
}
|
|
183
|
+
// CONTAINER PORT (INTERNAL)
|
|
184
|
+
// TODO: allow for none and swiching to none
|
|
185
|
+
if (thisPort.external == this.REMOVE_PORT_NUMBER) {
|
|
186
|
+
return undefined; // User has opted for removal of this whole port assignment
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
let keepInt = false;
|
|
190
|
+
let promptInt = "Port ".concat(index + ": ", "Container Port (internal): ");
|
|
191
|
+
if (thisPort.internal) {
|
|
192
|
+
keepInt = yield this._ui.promptConfirm("keepInt", promptInt.concat(thisPort.internal.toString()));
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
keepInt = !(yield this._ui.promptConfirm("keepInt", "Port ".concat(index + ": ", "Forwarding?" /* "Forward to a different port on the container?" */), false));
|
|
196
|
+
}
|
|
197
|
+
if (keepInt !== true) {
|
|
198
|
+
thisPort.internal = yield this.selectPortNumber(thisPort.internal, promptInt);
|
|
199
|
+
if (thisPort.internal == this.REMOVE_PORT_NUMBER) { // User selected "NONE"
|
|
200
|
+
delete thisPort.internal;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return ((thisPort.internal != undefined) && (thisPort.internal != thisPort.external)) ? thisPort : thisPort.external;
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
throw err;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
selectPortNumber(defaultPort, prompt) {
|
|
213
|
+
var _a;
|
|
214
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
let portSelector = new cli_common_1.PromptSelectFuzzy(this.logger, this._ui, this._styler);
|
|
216
|
+
let fetcher = (search) => { return new Promise((resolve) => resolve(exports.ports)); };
|
|
217
|
+
let fuzzyOnRemote = false;
|
|
218
|
+
let validator = (candidate) => { return candidate == this.REMOVE_PORT_NUMBER.toString() || this.portIsValid(+(candidate) /*, assets, ports */); };
|
|
219
|
+
let selectedPort = yield portSelector.go('port', prompt !== null && prompt !== void 0 ? prompt : 'Default port number to assign this asset when deploying to a cabinet:', false, (_a = defaultPort === null || defaultPort === void 0 ? void 0 : defaultPort.toString()) !== null && _a !== void 0 ? _a : "", fuzzyOnRemote, fetcher, validator);
|
|
220
|
+
// if (thisPort == undefined) thisPort = { external: 0 };
|
|
221
|
+
let selected = +(selectedPort !== null && selectedPort !== void 0 ? selectedPort : 0);
|
|
222
|
+
return selected;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/** Assembles the options list for port selection.
|
|
226
|
+
* Decorates any options for ports that are already taken by an existing asset.
|
|
227
|
+
*/
|
|
228
|
+
getPortOptionsList(portOptions, assets) {
|
|
229
|
+
let output = [];
|
|
230
|
+
for (let port of portOptions) {
|
|
231
|
+
if (typeof port.port == "number") {
|
|
232
|
+
let option = { value: `${port.port}`, name: `${port.port} ${port.reservedFor} [${port.group}]` };
|
|
233
|
+
let asset = assets.find(a => a.port == port.port);
|
|
234
|
+
if (asset) {
|
|
235
|
+
option.name = option.name.concat(" ", this._styler.colorWarning(`TAKEN!! [by ${asset.name}]`));
|
|
236
|
+
}
|
|
237
|
+
output.push(option);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
for (let portNum = port.port.min; portNum <= port.port.max; portNum++) {
|
|
241
|
+
// ports.push({ value: `${portNum}`, name: `${portNum} ${port.reservedFor} [${port.group}]` })
|
|
242
|
+
let option = { value: `${portNum}`, name: `${portNum} ${port.reservedFor} [${port.group}]` };
|
|
243
|
+
let asset = assets.find(a => a.port == port.port);
|
|
244
|
+
if (asset) {
|
|
245
|
+
option.name = option.name.concat(" ", this._styler.colorWarning(`TAKEN!! [by ${asset.name}]`));
|
|
246
|
+
}
|
|
247
|
+
output.push(option);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Add any asset ports that arent in the standard list.
|
|
252
|
+
for (let asset of assets) {
|
|
253
|
+
if (!output.find(p => p.value == `${asset.port}`)) {
|
|
254
|
+
let option = { value: `${asset.port}`, name: `${asset.port} ` + this._styler.colorWarning(`TAKEN!! [by ${asset.name}]`) };
|
|
255
|
+
output.push(option);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Add any remaining numbers
|
|
259
|
+
let flush = [];
|
|
260
|
+
let port = 0;
|
|
261
|
+
for (var bespoke of output) {
|
|
262
|
+
port++;
|
|
263
|
+
let bport = Number.parseInt(bespoke.value);
|
|
264
|
+
while (port < bport) {
|
|
265
|
+
flush.push({ value: "" + port, name: port + " unreserved" });
|
|
266
|
+
port++;
|
|
267
|
+
}
|
|
268
|
+
flush.push(bespoke);
|
|
269
|
+
if (port > this.MAX_PORT_NUMBER)
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
return flush; // output;
|
|
273
|
+
}
|
|
274
|
+
/** @param otherAssets CAN NOT include the current asset. */
|
|
275
|
+
portIsValid(candidatePort /*, otherAssets: Asset[], allPorts: PromptChoice[] */, allowZero = false) {
|
|
276
|
+
let isValid = false;
|
|
277
|
+
let reason;
|
|
278
|
+
let entry;
|
|
279
|
+
// if (allPorts.find(p => p.value == `${candidatePort}`)) {
|
|
280
|
+
// // Means it was in the list of standard/registered ports
|
|
281
|
+
// entry = +(candidatePort);
|
|
282
|
+
// let owner = otherAssets.find(a => a.port == entry);
|
|
283
|
+
// isValid = (owner == undefined);
|
|
284
|
+
// if (owner) {
|
|
285
|
+
// reason = `Port number [${entry}] is ` + this._styler.colorWarning(`TAKEN!! [by ${owner.name}]`);
|
|
286
|
+
// }
|
|
287
|
+
// } else {
|
|
288
|
+
// Means it was a raw entry, un-matched in the autoselect
|
|
289
|
+
entry = candidatePort;
|
|
290
|
+
if (isNaN(+entry)) {
|
|
291
|
+
isValid = false;
|
|
292
|
+
reason = `[${entry}]: Not a port number.`; //; use TAB to autocomplete your selection.`;
|
|
293
|
+
}
|
|
294
|
+
else if ((allowZero && entry < 0) || (!allowZero && entry <= 0) || entry > 65535) {
|
|
295
|
+
isValid = false;
|
|
296
|
+
reason = `[${entry}]: Port number must be between 1 and 65535`;
|
|
297
|
+
// } else {
|
|
298
|
+
// let owner = otherAssets.find(a => a.port == entry);
|
|
299
|
+
// isValid = (owner == undefined);
|
|
300
|
+
// if (owner) {
|
|
301
|
+
// reason = `Port number [${entry}] is ` + this._styler.colorWarning(`TAKEN!! [by ${owner.name}]`);
|
|
302
|
+
// }
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
isValid = true;
|
|
306
|
+
}
|
|
307
|
+
// }
|
|
308
|
+
return (reason) ? { isValid: isValid, reason: reason } : isValid;
|
|
309
|
+
}
|
|
310
|
+
buildPortDesc(existingPort) {
|
|
311
|
+
let desc;
|
|
312
|
+
if (existingPort.internal == undefined) {
|
|
313
|
+
desc = this._styler.hilite(existingPort.external.toString());
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
desc = "Fwd ".concat(this._styler.hilite(existingPort.external.toString()), "(ext)", " --> ", this._styler.hilite(existingPort.internal.toString()), "(int)");
|
|
317
|
+
}
|
|
318
|
+
return desc;
|
|
319
|
+
}
|
|
320
|
+
/** Parses strings in formats: a) `<number>:<number>` and `<number>:` and `<number>`,
|
|
321
|
+
* eg: `8181` or `8181:80` or `8181:`
|
|
322
|
+
* Throws invalids. */
|
|
323
|
+
toPortMapping(portSpec) {
|
|
324
|
+
var _a, _b, _c;
|
|
325
|
+
let parts = portSpec.split(":");
|
|
326
|
+
if (parts.length == 1) {
|
|
327
|
+
let output = Number.parseInt(parts[0]);
|
|
328
|
+
const valid = this.portIsValid(output);
|
|
329
|
+
if (typeof valid === 'object')
|
|
330
|
+
throw new Error("Invalid port number: ".concat((_a = valid.reason) !== null && _a !== void 0 ? _a : "Must be an integer between 0 and ".concat(this.MAX_PORT_NUMBER.toString())));
|
|
331
|
+
return output;
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
let output = { external: Number.parseInt(parts[0]) };
|
|
335
|
+
output.internal = Number.parseInt(parts[1]);
|
|
336
|
+
const extValid = this.portIsValid(output.external);
|
|
337
|
+
const intValid = this.portIsValid(output.internal);
|
|
338
|
+
if (typeof extValid === 'object')
|
|
339
|
+
throw new Error("Invalid external port number: ".concat((_b = extValid.reason) !== null && _b !== void 0 ? _b : "Must be an integer between 0 and ", this.MAX_PORT_NUMBER.toString()));
|
|
340
|
+
if (typeof intValid === 'object')
|
|
341
|
+
throw new Error("Invalid internal port number: ".concat((_c = intValid.reason) !== null && _c !== void 0 ? _c : "Must be an integer between 0 and ", this.MAX_PORT_NUMBER.toString()));
|
|
342
|
+
return output;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
toPortString(portDef) {
|
|
346
|
+
let output;
|
|
347
|
+
if (typeof portDef == 'number') {
|
|
348
|
+
output = portDef.toString();
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
let parts = [portDef.external];
|
|
352
|
+
if (portDef.internal)
|
|
353
|
+
parts.push(portDef.internal);
|
|
354
|
+
output = parts.join(":");
|
|
355
|
+
}
|
|
356
|
+
return output;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
AssetConfigurator = tslib_1.__decorate([
|
|
360
|
+
(0, inversify_1.injectable)(),
|
|
361
|
+
tslib_1.__param(0, (0, inversify_1.inject)(ops_1.INTERFACES_CLI.IUserInputProvider)),
|
|
362
|
+
tslib_1.__param(1, (0, inversify_1.inject)(ops_1.INTERFACES_CLI.IOutputStyler)),
|
|
363
|
+
tslib_1.__param(2, (0, inversify_1.inject)(codiac_relay_1.RelayClient)),
|
|
364
|
+
tslib_1.__param(3, (0, inversify_1.inject)(codiac_common_1.INTERFACES.IBetterLogger)),
|
|
365
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object, codiac_relay_1.RelayClient, Object])
|
|
366
|
+
], AssetConfigurator);
|
|
367
|
+
exports.AssetConfigurator = AssetConfigurator;
|
|
368
|
+
class HostNameValidator {
|
|
369
|
+
constructor() {
|
|
370
|
+
}
|
|
371
|
+
isValid(candidate) {
|
|
372
|
+
let isValid = false;
|
|
373
|
+
let reason;
|
|
374
|
+
let must = "must be 3- to 50-character string of alphanumerics and hyphens, starting with a letter.";
|
|
375
|
+
if (candidate == undefined || _.isEmpty(candidate)) {
|
|
376
|
+
// throw new Error("Missing ".concat(propertyName));
|
|
377
|
+
reason = must;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
let rxName = /^[a-zA-Z][a-zA-Z0-9-]{2,50}$/;
|
|
381
|
+
if (!rxName.test(candidate)) {
|
|
382
|
+
// throw new Error("Invalid ".concat(propertyName, ": ", must));
|
|
383
|
+
reason = must;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
isValid = true;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return { isValid: isValid, reason: reason };
|
|
390
|
+
}
|
|
391
|
+
;
|
|
392
|
+
}
|
|
393
|
+
exports.HostNameValidator = HostNameValidator;
|
|
394
|
+
//# sourceMappingURL=asset-configurator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-configurator.js","sourceRoot":"","sources":["../../../src/uilogic/cloud-resource-configurators/asset-configurator.ts"],"names":[],"mappings":";;;;AAAA,yCAA+C;AAC/C,4DAAqE;AAGrE,0DAAwE;AACxE,+DAAqF;AACrF,iDAA0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@ -40,10 +40,12 @@ export declare class AwsResourceConfigurator implements IFileStoreConfigurator,
|
|
|
40
40
|
spec: ClusterDef;
|
|
41
41
|
defaults: Partial<ClusterDef>;
|
|
42
42
|
}>;
|
|
43
|
+
private promptForIngressSpec;
|
|
43
44
|
defineClusterCaptureParams(initial: Partial<ClusterDef>, defaults?: Partial<ClusterDef>): Promise<{
|
|
44
45
|
spec: ClusterCaptureDef;
|
|
45
46
|
defaults: Partial<ClusterDef>;
|
|
46
47
|
}>;
|
|
48
|
+
private promptForName;
|
|
47
49
|
private promptForNodeSpec;
|
|
48
50
|
private promptForLocation;
|
|
49
51
|
/** Asks the user whether to keep the default version, and if not presents a select list. */
|
|
@@ -12,6 +12,8 @@ const codiac_relay_1 = require("../../apis/codiac-relay");
|
|
|
12
12
|
const codiac_constants_1 = require("../../codiac-constants");
|
|
13
13
|
const contracts_2 = require("../../relay/contracts");
|
|
14
14
|
const ops_1 = require("../../ops");
|
|
15
|
+
const cli_common_1 = require("../../cli-common");
|
|
16
|
+
const type_safety_utils_1 = require("../type-safety-utils");
|
|
15
17
|
/** Walks the user through the selection of an existing
|
|
16
18
|
* or the declaration of a new image registry.
|
|
17
19
|
*/
|
|
@@ -243,8 +245,7 @@ let AwsResourceConfigurator = class AwsResourceConfigurator {
|
|
|
243
245
|
initial = _.assignWith({}, defaults, initial, assignment);
|
|
244
246
|
}
|
|
245
247
|
}
|
|
246
|
-
|
|
247
|
-
cluster.name = (yield this._ui.prompt("name", "Cluster name: ", true, initial === null || initial === void 0 ? void 0 : initial.name));
|
|
248
|
+
cluster.name = yield this.promptForName(initial === null || initial === void 0 ? void 0 : initial.name);
|
|
248
249
|
cluster.locationName = yield this.promptForLocation(initial === null || initial === void 0 ? void 0 : initial.locationName);
|
|
249
250
|
// TODO: Use the method `getIdentityFrom()` from the Codiac AwsAdapter lib to derive this from the Aws primary creds.
|
|
250
251
|
// cluster.providerSubscription = (await this._ui.prompt("providerSubscription", "Aws Account Id (ten-digit code): ", true, initial?.providerSubscription))!;
|
|
@@ -258,6 +259,7 @@ let AwsResourceConfigurator = class AwsResourceConfigurator {
|
|
|
258
259
|
cluster.startingNodeCount = (yield this._ui.prompt("startingNodeCount", "Qty nodes: ", true, (_e = initial === null || initial === void 0 ? void 0 : initial.startingNodeCount) !== null && _e !== void 0 ? _e : DEFAULT_STARTING_NODE_COUNT));
|
|
259
260
|
// // cluster.nodePools = (await this._ui.prompt("winNodePool", "Add Windows node pool: ", false, false)) ? cluster.nodePools : [];
|
|
260
261
|
cluster.k8sVersion = yield this.promptForK8sVersion(cluster.locationName, initial === null || initial === void 0 ? void 0 : initial.k8sVersion);
|
|
262
|
+
cluster.ingressDef = yield this.promptForIngressSpec(initial.ingressDef);
|
|
261
263
|
let spec = Object.assign({ name: cluster.name, provider: cluster.provider, providerSubscription: cluster.providerSubscription, locationName: cluster.locationName, providerGroup: cluster.providerGroup, nodeCount: cluster.nodeCount, ingressDef: cluster.ingressDef, privateOwner: cluster.privateOwner, nodeSpec: cluster.nodeSpec, startingNodeCount: cluster.startingNodeCount, identitySpec: { type: "", name: "" } }, this.createAuditable());
|
|
262
264
|
spec.k8sVersion = cluster.k8sVersion;
|
|
263
265
|
if (cluster === null || cluster === void 0 ? void 0 : cluster.nodePools)
|
|
@@ -280,11 +282,61 @@ let AwsResourceConfigurator = class AwsResourceConfigurator {
|
|
|
280
282
|
}));
|
|
281
283
|
});
|
|
282
284
|
}
|
|
285
|
+
promptForIngressSpec(current) {
|
|
286
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
287
|
+
// INTERNAL?
|
|
288
|
+
let choices = []; //Object.keys(IngressExposure).map(k => <PromptChoice>{ name: k, value: k });
|
|
289
|
+
choices.push({ value: contracts_1.IngressExposure.external, name: contracts_1.IngressExposure.external.concat(this._styler.dim(" (Accessible from the internet)")) });
|
|
290
|
+
choices.push({ value: contracts_1.IngressExposure.internal, name: contracts_1.IngressExposure.internal.concat(this._styler.dim(" (private, inside a network)")) });
|
|
291
|
+
// choices.push({ value: IngressExposure.none, name: IngressExposure.none.concat(this._styler.dim(" (do not install)")) });
|
|
292
|
+
// default to external
|
|
293
|
+
let access = type_safety_utils_1.TypeSafetyUtils.toBoolean(current === null || current === void 0 ? void 0 : current.internal) ? contracts_1.IngressExposure.internal : contracts_1.IngressExposure.external;
|
|
294
|
+
let keep = false;
|
|
295
|
+
keep = yield this._ui.promptConfirm("internalConfirm", "Ingress: ".concat(this._styler.hilite(access)), true);
|
|
296
|
+
if (!keep) {
|
|
297
|
+
let selected = (yield this._ui.promptSelect("internal", "Ingress: ", choices));
|
|
298
|
+
access = type_safety_utils_1.TypeSafetyUtils.toEnum(contracts_1.IngressExposure, selected); // assertion ok because the list is limited to valid values.
|
|
299
|
+
}
|
|
300
|
+
// Convert to domain
|
|
301
|
+
let output;
|
|
302
|
+
if (access == contracts_1.IngressExposure.internal) {
|
|
303
|
+
output = (current !== null && current !== void 0 ? current : {});
|
|
304
|
+
output.internal = true;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
output = current;
|
|
308
|
+
if (output)
|
|
309
|
+
delete output.internal;
|
|
310
|
+
}
|
|
311
|
+
return output;
|
|
312
|
+
});
|
|
313
|
+
}
|
|
283
314
|
defineClusterCaptureParams(initial, defaults) {
|
|
284
315
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
285
316
|
throw new Error("Cluster capture not yet implemented for AWS.");
|
|
286
317
|
});
|
|
287
318
|
}
|
|
319
|
+
promptForName(current) {
|
|
320
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
321
|
+
let ultimate;
|
|
322
|
+
let keepName = false;
|
|
323
|
+
if (current != undefined && !_.isEmpty(current)) {
|
|
324
|
+
// if (takeDefaults) {
|
|
325
|
+
// this._ui.userMessage("Cluster name: ".concat(this._styler.hilite(cluster.name)));
|
|
326
|
+
// } else {
|
|
327
|
+
keepName = yield this._ui.promptConfirm("nameConfirm", "Cluster name: ".concat(this._styler.hilite(current)), true);
|
|
328
|
+
if (keepName)
|
|
329
|
+
ultimate = current;
|
|
330
|
+
// }
|
|
331
|
+
}
|
|
332
|
+
if (!keepName || ultimate == undefined /* undef check is redundant, but its there for typescript */) {
|
|
333
|
+
do {
|
|
334
|
+
ultimate = (yield this._ui.prompt("name", "Cluster name: ", true, current));
|
|
335
|
+
} while (_.isEmpty(ultimate));
|
|
336
|
+
}
|
|
337
|
+
return ultimate;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
288
340
|
promptForNodeSpec(defaultValue) {
|
|
289
341
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
290
342
|
let output;
|
|
@@ -305,7 +357,10 @@ let AwsResourceConfigurator = class AwsResourceConfigurator {
|
|
|
305
357
|
}
|
|
306
358
|
else {
|
|
307
359
|
let nodeTypeChoices = allNodeTypes.map(x => { return { name: x, value: x }; });
|
|
308
|
-
|
|
360
|
+
// TODO: Fuzzy-search here
|
|
361
|
+
// output = (await this._ui.promptSelect("nodeSpec", "Node type: ", nodeTypeChoices))!;
|
|
362
|
+
let fuzzySelector = new cli_common_1.PromptSelectFuzzy(this.logger, this._ui, this._styler);
|
|
363
|
+
output = (yield fuzzySelector.go("nodeSpec", "Node type: ", false, defaultValue, false, () => tslib_1.__awaiter(this, void 0, void 0, function* () { return nodeTypeChoices; })));
|
|
309
364
|
}
|
|
310
365
|
return output;
|
|
311
366
|
}
|