@opencrvs/toolkit 2.0.0-rc.358eace → 2.0.0-rc.35b1e0f
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 -0
- package/build.sh +3 -3
- package/dist/application-config/index.js +17 -6
- package/dist/cli.js +328 -226
- package/dist/commons/api/router.d.ts +10 -0
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
- package/dist/commons/events/EventConfig.d.ts +2 -0
- package/dist/commons/events/EventIndex.d.ts +25 -0
- package/dist/commons/events/EventMetadata.d.ts +26 -0
- package/dist/commons/events/FieldConfig.d.ts +10 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +39 -0
- package/dist/commons/events/locations.d.ts +1 -0
- package/dist/commons/events/state/index.d.ts +8 -0
- package/dist/commons/events/state/utils.d.ts +9 -0
- package/dist/conditionals/index.js +10 -5
- package/dist/environment/custom-types.d.ts.map +1 -1
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +1 -1
- package/dist/environment/editor-questions.d.ts.map +1 -1
- package/dist/environment/editor-questions.js +6 -4
- package/dist/environment/git.js +5 -5
- package/dist/environment/github.d.ts.map +1 -1
- package/dist/environment/github.js +15 -12
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +2 -1
- package/dist/environment/manage-users.d.ts.map +1 -1
- package/dist/environment/manage-users.js +11 -8
- package/dist/environment/questions-helper.d.ts.map +1 -1
- package/dist/environment/questions-helper.js +5 -5
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +13 -13
- package/dist/environment/setup-environment.js +75 -54
- package/dist/environment/ssh-keygen.d.ts.map +1 -1
- package/dist/environment/ssh-keygen.js +5 -2
- package/dist/environment/swarm-to-k8s.js +16 -15
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +16 -12
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +6 -5
- package/dist/environment/users.d.ts +1 -1
- package/dist/environment/users.d.ts.map +1 -1
- package/dist/environment/users.js +19 -9
- package/dist/environment/utils.d.ts.map +1 -1
- package/dist/environment/utils.js +1 -1
- package/dist/events/index.js +40 -6
- package/dist/migrations/v2.0/index.js +10 -5
- package/dist/notification/index.js +17 -6
- package/dist/scopes/index.d.ts +89 -1
- package/dist/scopes/index.js +10 -5
- package/dist/{environment/templates → templates}/charts-values/dependencies/values.yaml +7 -6
- package/dist/{environment/templates/charts-values/dependencies → templates/charts-values/opencrvs-services}/values.override.yaml +1 -1
- package/dist/{environment/templates → templates}/charts-values/opencrvs-services/values.yaml +8 -6
- package/dist/{environment/templates → templates}/charts-values/traefik/values.override.yaml +1 -1
- package/dist/{environment/templates → templates}/charts-values/traefik/values.yaml +6 -7
- package/dist/{environment/templates → templates}/inventory/production.example.yml +2 -2
- package/opencrvs-toolkit-2.0.0-rc.35b1e0f.tgz +0 -0
- package/package.json +1 -1
- package/opencrvs-toolkit-2.0.0-rc.358eace.tgz +0 -0
- /package/dist/{environment/templates/charts-values/opencrvs-services → templates/charts-values/dependencies}/values.override.yaml +0 -0
- /package/dist/{environment/templates → templates}/inventory/inventory.template.yml +0 -0
- /package/dist/{environment/templates → templates}/inventory/qa.example.yml +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/environment/github.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAaf;AACD,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,OAAO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AcrB"}
|
|
@@ -18,6 +18,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
21
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
25
|
exports.createEnvironmentVariable = createEnvironmentVariable;
|
|
23
26
|
exports.updateEnvironmentVariable = updateEnvironmentVariable;
|
|
@@ -32,7 +35,7 @@ exports.listEnvironmentSecrets = listEnvironmentSecrets;
|
|
|
32
35
|
exports.listRepositorySecrets = listRepositorySecrets;
|
|
33
36
|
exports.listEnvironmentVariables = listEnvironmentVariables;
|
|
34
37
|
exports.listRepositoryVariables = listRepositoryVariables;
|
|
35
|
-
const
|
|
38
|
+
const libsodium_wrappers_1 = __importDefault(require("libsodium-wrappers"));
|
|
36
39
|
const logger_1 = require("./logger");
|
|
37
40
|
function createEnvironmentVariable(octokit, repositoryId, environment, name, value) {
|
|
38
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -125,15 +128,15 @@ function getPublicKey(octokit, environment, ORGANISATION, REPOSITORY_NAME) {
|
|
|
125
128
|
function createEnvironmentSecret(octokit, repositoryId, environment, name, secret, organisationName, repositoryName) {
|
|
126
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
130
|
//Check if libsodium is ready and then proceed.
|
|
128
|
-
yield
|
|
131
|
+
yield libsodium_wrappers_1.default.ready;
|
|
129
132
|
const { key, key_id } = yield getPublicKey(octokit, environment, organisationName, repositoryName);
|
|
130
133
|
// Convert Secret & Base64 key to Uint8Array.
|
|
131
|
-
const binkey =
|
|
132
|
-
const binsec =
|
|
134
|
+
const binkey = libsodium_wrappers_1.default.from_base64(key, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
135
|
+
const binsec = libsodium_wrappers_1.default.from_string(secret);
|
|
133
136
|
//Encrypt the secret using LibSodium
|
|
134
|
-
const encBytes =
|
|
137
|
+
const encBytes = libsodium_wrappers_1.default.crypto_box_seal(binsec, binkey);
|
|
135
138
|
// Convert encrypted Uint8Array to Base64
|
|
136
|
-
const encryptedValue =
|
|
139
|
+
const encryptedValue = libsodium_wrappers_1.default.to_base64(encBytes, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
137
140
|
yield octokit.request(`PUT /repositories/${repositoryId}/environments/${environment}/secrets/${name}`, {
|
|
138
141
|
repository_id: repositoryId,
|
|
139
142
|
environment_name: environment,
|
|
@@ -149,15 +152,15 @@ function createEnvironmentSecret(octokit, repositoryId, environment, name, secre
|
|
|
149
152
|
function createRepositorySecret(octokit, repositoryId, name, secret, organisationName, repositoryName) {
|
|
150
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
154
|
//Check if libsodium is ready and then proceed.
|
|
152
|
-
yield
|
|
155
|
+
yield libsodium_wrappers_1.default.ready;
|
|
153
156
|
const { key, key_id } = yield getRepositoryPublicKey(octokit, organisationName, repositoryName);
|
|
154
157
|
// Convert Secret & Base64 key to Uint8Array.
|
|
155
|
-
const binkey =
|
|
156
|
-
const binsec =
|
|
158
|
+
const binkey = libsodium_wrappers_1.default.from_base64(key, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
159
|
+
const binsec = libsodium_wrappers_1.default.from_string(secret);
|
|
157
160
|
//Encrypt the secret using LibSodium
|
|
158
|
-
const encBytes =
|
|
161
|
+
const encBytes = libsodium_wrappers_1.default.crypto_box_seal(binsec, binkey);
|
|
159
162
|
// Convert encrypted Uint8Array to Base64
|
|
160
|
-
const encryptedValue =
|
|
163
|
+
const encryptedValue = libsodium_wrappers_1.default.to_base64(encBytes, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
161
164
|
yield octokit.request(`PUT /repositories/${repositoryId}/actions/secrets/${name}`, {
|
|
162
165
|
encrypted_value: encryptedValue,
|
|
163
166
|
key_id,
|
|
@@ -172,7 +175,7 @@ function getRepositoryEnvironments(octokit, githubOrganisation, repository) {
|
|
|
172
175
|
var _a;
|
|
173
176
|
const response = yield octokit.request('GET /repos/{githubOrganisation}/{repository}/environments', {
|
|
174
177
|
githubOrganisation,
|
|
175
|
-
repository
|
|
178
|
+
repository
|
|
176
179
|
});
|
|
177
180
|
// Safe access with fallback to empty array if undefined
|
|
178
181
|
const environments = ((_a = response.data.environments) !== null && _a !== void 0 ? _a : []).map((env) => env.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"AAwCA,wBAAsB,kBAAkB,kBAGvC;AAED,wBAAsB,6BAA6B,kBAIlD;AAED,wBAAsB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"AAwCA,wBAAsB,kBAAkB,kBAGvC;AAED,wBAAsB,6BAA6B,kBAIlD;AAED,wBAAsB,mBAAmB,kBAIxC;AAED,wBAAsB,wBAAwB,kBAG7C"}
|
|
@@ -59,7 +59,8 @@ function runEnvironmentUpdateWorkflows() {
|
|
|
59
59
|
function runEnvironmentUsers() {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
61
|
validateRepositoryStructure();
|
|
62
|
-
yield import('./users.js');
|
|
62
|
+
const { manageEnvironmentUsers } = yield import('./users.js');
|
|
63
|
+
yield manageEnvironmentUsers();
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
function runEnvironmentSwarmToK8s() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-users.d.ts","sourceRoot":"","sources":["../../src/environment/manage-users.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manage-users.d.ts","sourceRoot":"","sources":["../../src/environment/manage-users.ts"],"names":[],"mappings":"AAkCA,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC3B,IAAI,EAAE,OAAO,GAAG,UAAU,CAAA;CAC3B;AAkWD;;GAEG;AACH,wBAAsB,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAqIxE"}
|
|
@@ -44,6 +44,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.manageUsers = manageUsers;
|
|
46
46
|
const os = __importStar(require("os"));
|
|
47
|
+
/* eslint-disable no-console */
|
|
47
48
|
const fs = __importStar(require("fs"));
|
|
48
49
|
const path = __importStar(require("path"));
|
|
49
50
|
function inquirerPrompt(name, options) {
|
|
@@ -163,7 +164,7 @@ function askToAddCurrentUser(existingUsers) {
|
|
|
163
164
|
const currentUsername = getCurrentUsername();
|
|
164
165
|
const currentKeys = getCurrentUserSSHKeys();
|
|
165
166
|
// Check if user already exists
|
|
166
|
-
if (existingUsers.find(u => u.name === currentUsername)) {
|
|
167
|
+
if (existingUsers.find((u) => u.name === currentUsername)) {
|
|
167
168
|
(0, logger_1.info)(`ℹ️ User "${currentUsername}" already exists in inventory.`);
|
|
168
169
|
return null;
|
|
169
170
|
}
|
|
@@ -199,7 +200,7 @@ function addNewUser(existingUsers) {
|
|
|
199
200
|
if (!value.trim()) {
|
|
200
201
|
return 'Username required';
|
|
201
202
|
}
|
|
202
|
-
if (existingUsers.find(u => u.name === value.trim())) {
|
|
203
|
+
if (existingUsers.find((u) => u.name === value.trim())) {
|
|
203
204
|
return `User "${value}" already exists`;
|
|
204
205
|
}
|
|
205
206
|
if (!/^[a-z_][a-z0-9_-]*[$]?$/.test(value.trim())) {
|
|
@@ -221,7 +222,7 @@ function addNewUser(existingUsers) {
|
|
|
221
222
|
}
|
|
222
223
|
const role = yield selectRole();
|
|
223
224
|
// New users always active
|
|
224
|
-
const state =
|
|
225
|
+
const state = 'present';
|
|
225
226
|
return {
|
|
226
227
|
name: name.trim(),
|
|
227
228
|
ssh_keys,
|
|
@@ -378,7 +379,9 @@ function editUser(user) {
|
|
|
378
379
|
*/
|
|
379
380
|
function manageUsers(inventoryPath) {
|
|
380
381
|
return __awaiter(this, void 0, void 0, function* () {
|
|
381
|
-
let users = fs.existsSync(inventoryPath)
|
|
382
|
+
let users = fs.existsSync(inventoryPath)
|
|
383
|
+
? parseInventoryFile(inventoryPath)
|
|
384
|
+
: [];
|
|
382
385
|
if (users.length > 0) {
|
|
383
386
|
displayUserSummary(users);
|
|
384
387
|
}
|
|
@@ -418,12 +421,12 @@ function manageUsers(inventoryPath) {
|
|
|
418
421
|
}
|
|
419
422
|
const userToEdit = yield select({
|
|
420
423
|
message: 'Select user to edit:',
|
|
421
|
-
choices: users.map(u => ({
|
|
424
|
+
choices: users.map((u) => ({
|
|
422
425
|
name: `${u.name} (${u.role}, ${u.state})`,
|
|
423
426
|
value: u.name
|
|
424
427
|
}))
|
|
425
428
|
});
|
|
426
|
-
const userIndex = users.findIndex(u => u.name === userToEdit);
|
|
429
|
+
const userIndex = users.findIndex((u) => u.name === userToEdit);
|
|
427
430
|
if (userIndex !== -1) {
|
|
428
431
|
users[userIndex] = yield editUser(users[userIndex]);
|
|
429
432
|
console.log(`✅ User "${userToEdit}" updated.\n`);
|
|
@@ -436,7 +439,7 @@ function manageUsers(inventoryPath) {
|
|
|
436
439
|
}
|
|
437
440
|
const usersToRemove = yield checkbox({
|
|
438
441
|
message: 'Select user(s) to remove:',
|
|
439
|
-
choices: users.map(u => ({
|
|
442
|
+
choices: users.map((u) => ({
|
|
440
443
|
name: `${u.name} (${u.role}, ${u.state})`,
|
|
441
444
|
value: u.name
|
|
442
445
|
}))
|
|
@@ -447,7 +450,7 @@ function manageUsers(inventoryPath) {
|
|
|
447
450
|
default: false
|
|
448
451
|
});
|
|
449
452
|
if (confirmRemove) {
|
|
450
|
-
users = users.filter(u => !usersToRemove.includes(u.name));
|
|
453
|
+
users = users.filter((u) => !usersToRemove.includes(u.name));
|
|
451
454
|
console.log(`✅ Removed ${usersToRemove.length} user(s).\n`);
|
|
452
455
|
}
|
|
453
456
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions-helper.d.ts","sourceRoot":"","sources":["../../src/environment/questions-helper.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"questions-helper.d.ts","sourceRoot":"","sources":["../../src/environment/questions-helper.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAYhC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,UASnE;AAED,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACnD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAkCjB"}
|
|
@@ -45,7 +45,7 @@ function getIndexFromChoices(choices, value) {
|
|
|
45
45
|
}
|
|
46
46
|
function selectWithCustom(config) {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const { message, choices, initial = undefined, customLabel = 'Other...', customInputMessage = 'Enter custom value:'
|
|
48
|
+
const { message, choices, initial = undefined, customLabel = 'Other...', customInputMessage = 'Enter custom value:' } = config;
|
|
49
49
|
const CUSTOM = '__custom__';
|
|
50
50
|
const selected = yield select({
|
|
51
51
|
message,
|
|
@@ -53,15 +53,15 @@ function selectWithCustom(config) {
|
|
|
53
53
|
...choices,
|
|
54
54
|
{
|
|
55
55
|
value: CUSTOM,
|
|
56
|
-
name: customLabel
|
|
57
|
-
}
|
|
56
|
+
name: customLabel
|
|
57
|
+
}
|
|
58
58
|
],
|
|
59
|
-
default: initial
|
|
59
|
+
default: initial
|
|
60
60
|
});
|
|
61
61
|
if (selected === CUSTOM) {
|
|
62
62
|
const customValue = yield input({
|
|
63
63
|
message: customInputMessage,
|
|
64
|
-
validate: (value) => value.trim().length > 0 ? true : 'Value cannot be empty'
|
|
64
|
+
validate: (value) => value.trim().length > 0 ? true : 'Value cannot be empty'
|
|
65
65
|
});
|
|
66
66
|
return customValue;
|
|
67
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.ts"],"names":[],"mappings":"AA+BA,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBnD;AAED,eAAO,MAAM,kBAAkB;;;;;;sBAlCN,MAAM,GAAG,MAAM;;;GA4EvC,CAAA;AAED,eAAO,MAAM,eAAe;;;;sBA9EH,MAAM,GAAG,MAAM;;;GA+FvC,CAAA;AACD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;sBAhGR,MAAM,GAAG,MAAM;;;;IA+HvC,CAAA;AACD,eAAO,MAAM,mBAAmB;;;;sBAhIP,MAAM,GAAG,MAAM;;;;;GA2IvC,CAAA;AAED,eAAO,MAAM,gBAAgB;;;;;;;;GAW5B,CAAA;AAED,eAAO,MAAM,uBAAuB;;;;;sBA1JX,MAAM,GAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;IAmMvC,CAAA;AAED,eAAO,MAAM,sBAAsB;;;;;sBArMV,MAAM,GAAG,MAAM;;;;GA0NvC,CAAA;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;sBA5NH,MAAM,GAAG,MAAM;;;;;;;;;;;;;;sBAAf,MAAM,GAAG,MAAM;;;;IAqQvC,CAAA;AAED,eAAO,MAAM,aAAa;;;;;sBAvQD,MAAM,GAAG,MAAM;;;;GAoRvC,CAAA;AAED,eAAO,MAAM,8BAA8B;;;;;sBAtRlB,MAAM,GAAG,MAAM;;;;GA2SvC,CAAA;AAED,eAAO,MAAM,cAAc;;;;;sBA7SF,MAAM,GAAG,MAAM;;;;;;;;;;;;;;sBAAf,MAAM,GAAG,MAAM;;;;IA+XvC,CAAA;AAED,eAAO,MAAM,eAAe;;;;;sBAjYH,MAAM,GAAG,MAAM;;;;GA4YvC,CAAA;AAED,eAAO,MAAM,sBAAsB;;;;;;;;GAoBlC,CAAA"}
|
|
@@ -98,7 +98,7 @@ exports.githubQuestions = [
|
|
|
98
98
|
validate: notEmpty,
|
|
99
99
|
initial: process.env.GITHUB_REPOSITORY || (0, git_1.getRepoInfo)().repository,
|
|
100
100
|
scope: 'REPOSITORY'
|
|
101
|
-
}
|
|
101
|
+
}
|
|
102
102
|
];
|
|
103
103
|
exports.githubOtherQuestions = [
|
|
104
104
|
{
|
|
@@ -129,7 +129,7 @@ exports.githubOtherQuestions = [
|
|
|
129
129
|
valueLabel: 'APPROVAL_REQUIRED',
|
|
130
130
|
initial: process.env.APPROVAL_REQUIRED,
|
|
131
131
|
scope: 'ENVIRONMENT'
|
|
132
|
-
}
|
|
132
|
+
}
|
|
133
133
|
];
|
|
134
134
|
exports.githubTokenQuestion = [
|
|
135
135
|
{
|
|
@@ -182,8 +182,8 @@ exports.infrastructureQuestions = [
|
|
|
182
182
|
valueType: 'VARIABLE',
|
|
183
183
|
validate: validateCIDRs,
|
|
184
184
|
valueLabel: 'KUBE_API_ALLOWED_CIDRS',
|
|
185
|
-
initial: process.env.KUBE_API_ALLOWED_CIDRS ||
|
|
186
|
-
scope: 'ENVIRONMENT'
|
|
185
|
+
initial: process.env.KUBE_API_ALLOWED_CIDRS || '',
|
|
186
|
+
scope: 'ENVIRONMENT'
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
name: 'kubeWorkerNodes',
|
|
@@ -193,8 +193,8 @@ exports.infrastructureQuestions = [
|
|
|
193
193
|
// validate: notEmpty,
|
|
194
194
|
valueLabel: 'KUBE_WORKER_NODES',
|
|
195
195
|
initial: process.env.KUBE_WORKER_NODES || '',
|
|
196
|
-
scope: 'ENVIRONMENT'
|
|
197
|
-
}
|
|
196
|
+
scope: 'ENVIRONMENT'
|
|
197
|
+
}
|
|
198
198
|
];
|
|
199
199
|
exports.staticSSLCertQuestions = [
|
|
200
200
|
{
|
|
@@ -216,7 +216,7 @@ exports.staticSSLCertQuestions = [
|
|
|
216
216
|
valueLabel: 'SSL_KEY',
|
|
217
217
|
initial: process.env.SSL_KEY,
|
|
218
218
|
scope: 'ENVIRONMENT'
|
|
219
|
-
}
|
|
219
|
+
}
|
|
220
220
|
];
|
|
221
221
|
exports.backupQuestions = [
|
|
222
222
|
{
|
|
@@ -227,7 +227,7 @@ exports.backupQuestions = [
|
|
|
227
227
|
// validate: notEmpty,
|
|
228
228
|
valueLabel: 'BACKUP_HOST',
|
|
229
229
|
initial: process.env.BACKUP_HOST || '',
|
|
230
|
-
scope: 'ENVIRONMENT'
|
|
230
|
+
scope: 'ENVIRONMENT'
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
233
|
name: 'backupUser',
|
|
@@ -237,7 +237,7 @@ exports.backupQuestions = [
|
|
|
237
237
|
validate: notEmpty,
|
|
238
238
|
valueLabel: 'BACKUP_SERVER_USER',
|
|
239
239
|
initial: process.env.BACKUP_SERVER_USER || 'backup',
|
|
240
|
-
scope: 'ENVIRONMENT'
|
|
240
|
+
scope: 'ENVIRONMENT'
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
name: 'backupType',
|
|
@@ -257,8 +257,8 @@ exports.backupQuestions = [
|
|
|
257
257
|
validate: notEmpty,
|
|
258
258
|
valueLabel: 'BACKUP_ENVIRONMENT_MODE',
|
|
259
259
|
initial: process.env.BACKUP_ENVIRONMENT_MODE,
|
|
260
|
-
scope: 'ENVIRONMENT'
|
|
261
|
-
}
|
|
260
|
+
scope: 'ENVIRONMENT'
|
|
261
|
+
}
|
|
262
262
|
];
|
|
263
263
|
exports.diskQuestions = [
|
|
264
264
|
{
|
|
@@ -271,8 +271,8 @@ exports.diskQuestions = [
|
|
|
271
271
|
validate: notEmpty,
|
|
272
272
|
valueLabel: 'DISK_SPACE',
|
|
273
273
|
initial: process.env.DISK_SPACE || '200g',
|
|
274
|
-
scope: 'ENVIRONMENT'
|
|
275
|
-
}
|
|
274
|
+
scope: 'ENVIRONMENT'
|
|
275
|
+
}
|
|
276
276
|
];
|
|
277
277
|
exports.databaseAndMonitoringQuestions = [
|
|
278
278
|
{
|
|
@@ -60,13 +60,7 @@ const editor_questions_1 = require("./editor-questions");
|
|
|
60
60
|
const questions_helper_1 = require("./questions-helper");
|
|
61
61
|
const manage_users_1 = require("./manage-users");
|
|
62
62
|
function questionToPrompt(_a) {
|
|
63
|
-
var {
|
|
64
|
-
// eslint-disable-next-line no-unused-vars
|
|
65
|
-
valueType,
|
|
66
|
-
// eslint-disable-next-line no-unused-vars
|
|
67
|
-
valueLabel,
|
|
68
|
-
// eslint-disable-next-line no-unused-vars
|
|
69
|
-
scope } = _a, promptOptions = __rest(_a, ["valueType", "valueLabel", "scope"]);
|
|
63
|
+
var { valueType, valueLabel, scope } = _a, promptOptions = __rest(_a, ["valueType", "valueLabel", "scope"]);
|
|
70
64
|
return promptOptions;
|
|
71
65
|
}
|
|
72
66
|
const ALL_QUESTIONS = [];
|
|
@@ -83,24 +77,29 @@ function getAnswers(existingValues) {
|
|
|
83
77
|
});
|
|
84
78
|
return questionsThatAreSecretsOrVariables.map(([key, value]) => {
|
|
85
79
|
const existingQuestion = ALL_QUESTIONS.find((question) => question.name === key);
|
|
86
|
-
|
|
80
|
+
if (!(existingQuestion === null || existingQuestion === void 0 ? void 0 : existingQuestion.valueLabel) ||
|
|
81
|
+
(existingQuestion.valueType !== 'SECRET' &&
|
|
82
|
+
existingQuestion.valueType !== 'VARIABLE')) {
|
|
83
|
+
throw new Error(`No secret or variable question found for ${key}`);
|
|
84
|
+
}
|
|
85
|
+
const { valueLabel, valueType, scope } = existingQuestion;
|
|
87
86
|
if (valueType === 'SECRET') {
|
|
88
|
-
const existingSecret = (0, utils_1.findExistingValue)(
|
|
87
|
+
const existingSecret = (0, utils_1.findExistingValue)(valueLabel, 'SECRET', scope, existingValues);
|
|
89
88
|
return {
|
|
90
89
|
type: valueType,
|
|
91
|
-
name:
|
|
90
|
+
name: valueLabel,
|
|
92
91
|
value: value.toString(),
|
|
93
92
|
didExist: existingSecret,
|
|
94
|
-
scope
|
|
93
|
+
scope
|
|
95
94
|
};
|
|
96
95
|
}
|
|
97
|
-
const existingVariable = (0, utils_1.findExistingValue)(
|
|
96
|
+
const existingVariable = (0, utils_1.findExistingValue)(valueLabel, valueType, scope, existingValues);
|
|
98
97
|
return {
|
|
99
98
|
type: valueType,
|
|
100
|
-
name:
|
|
101
|
-
didExist: (0, utils_1.findExistingValue)(
|
|
99
|
+
name: valueLabel,
|
|
100
|
+
didExist: (0, utils_1.findExistingValue)(valueLabel, valueType, scope, existingValues),
|
|
102
101
|
value: value.toString() || (existingVariable === null || existingVariable === void 0 ? void 0 : existingVariable.value) || '',
|
|
103
|
-
scope
|
|
102
|
+
scope
|
|
104
103
|
};
|
|
105
104
|
});
|
|
106
105
|
});
|
|
@@ -118,7 +117,8 @@ function promptAndStoreAnswer(environment, questions, existingValues) {
|
|
|
118
117
|
if (existingVariable) {
|
|
119
118
|
let initial_value = existingVariable.value;
|
|
120
119
|
// Get correct initial value for select questions
|
|
121
|
-
if (questionWithVariableLabel.type === 'select' &&
|
|
120
|
+
if (questionWithVariableLabel.type === 'select' &&
|
|
121
|
+
Array.isArray(questionWithVariableLabel.choices)) {
|
|
122
122
|
initial_value = (0, questions_helper_1.getIndexFromChoices)(questionWithVariableLabel.choices, existingVariable.value);
|
|
123
123
|
}
|
|
124
124
|
return [
|
|
@@ -185,8 +185,8 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
185
185
|
auth: githubToken
|
|
186
186
|
});
|
|
187
187
|
(0, logger_1.log)(kleur_1.default.green('\nSuccessfully logged in to Github\n'));
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
const existingEnvironments = yield (0, github_1.getRepositoryEnvironments)(octokit, githubOrganisation, githubRepository);
|
|
189
|
+
const defaultChoices = [
|
|
190
190
|
{ name: 'Development', value: 'development' },
|
|
191
191
|
{ name: 'Quality assurance (no PII data)', value: 'qa' },
|
|
192
192
|
{
|
|
@@ -196,7 +196,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
196
196
|
{
|
|
197
197
|
name: 'Production (hosts PII data, requires frequent backups)',
|
|
198
198
|
value: 'production'
|
|
199
|
-
}
|
|
199
|
+
}
|
|
200
200
|
];
|
|
201
201
|
// Add only environments that are not already present
|
|
202
202
|
const choices = [
|
|
@@ -223,9 +223,15 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
223
223
|
environment_type = yield select({
|
|
224
224
|
message: 'Purpose for the environment?',
|
|
225
225
|
choices: [
|
|
226
|
-
{
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
{
|
|
227
|
+
name: 'Development/Quality assurance/Testing (no PII data)',
|
|
228
|
+
value: 'non-production'
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'Staging/Production (hosts PII data, requires frequent backups)',
|
|
232
|
+
value: 'production'
|
|
233
|
+
}
|
|
234
|
+
]
|
|
229
235
|
});
|
|
230
236
|
}
|
|
231
237
|
const environment_exists = existingEnvironments
|
|
@@ -255,7 +261,9 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
255
261
|
(0, logger_1.log)('\nEnvironment with the name', environment, 'already exists in Github.', '\nFound', existingEnvironmentVariables.length, 'existing variables and', existingEnvironmentSecrets.length, 'secrets');
|
|
256
262
|
}
|
|
257
263
|
if (environment_type === 'production') {
|
|
258
|
-
(0, logger_1.log)('\n', kleur_1.default
|
|
264
|
+
(0, logger_1.log)('\n', kleur_1.default
|
|
265
|
+
.yellow()
|
|
266
|
+
.bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
|
|
259
267
|
yield promptAndStoreAnswer(environment, questions_1.githubOtherQuestions, existingValues);
|
|
260
268
|
}
|
|
261
269
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Docker Hub'));
|
|
@@ -263,7 +271,8 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
263
271
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
|
|
264
272
|
const infrastructure = yield promptAndStoreAnswer(environment, questions_1.infrastructureQuestions, existingValues);
|
|
265
273
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes
|
|
266
|
-
? infrastructure.kubeWorkerNodes.split(',').map((ip) => ip.trim())
|
|
274
|
+
? infrastructure.kubeWorkerNodes.split(',').map((ip) => ip.trim())
|
|
275
|
+
: [];
|
|
267
276
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('SSH Users'), '\n');
|
|
268
277
|
const users = yield (0, manage_users_1.manageUsers)(`infrastructure/server-setup/inventory/${environment}.yml`);
|
|
269
278
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Traefik SSL Certificate'), '\n');
|
|
@@ -276,13 +285,13 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
276
285
|
message: 'Choose option to configure Traefik SSL Certificate',
|
|
277
286
|
choices: [
|
|
278
287
|
{ title: "Let's Encrypt certificate", value: 'lets_encrypt' },
|
|
279
|
-
{ title:
|
|
280
|
-
{ title:
|
|
288
|
+
{ title: 'Static SSL certificate', value: 'static_ssl' },
|
|
289
|
+
{ title: 'Custom configuration', value: 'custom' }
|
|
281
290
|
],
|
|
282
291
|
initial: sslCertExists ? 1 : 0
|
|
283
292
|
}
|
|
284
293
|
])).traefikConfOption;
|
|
285
|
-
if (traefikConfOption ===
|
|
294
|
+
if (traefikConfOption === 'static_ssl') {
|
|
286
295
|
ssl_answers = yield (0, editor_questions_1.askQuestionWithEditor)(questions_1.staticSSLCertQuestions, existingEnvironmentSecrets);
|
|
287
296
|
}
|
|
288
297
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Storage'), '\n');
|
|
@@ -306,21 +315,27 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
306
315
|
}
|
|
307
316
|
else {
|
|
308
317
|
if (!enableEncryption && !encryption_key_defined && environment_exists) {
|
|
309
|
-
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default
|
|
318
|
+
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default
|
|
319
|
+
.bold()
|
|
320
|
+
.grey(`Environment ${environment} is already configured, skipping disk encryption question`));
|
|
310
321
|
}
|
|
311
322
|
const DISK_SPACE = (0, utils_1.findExistingValue)('DISK_SPACE', 'VARIABLE', 'ENVIRONMENT', existingValues);
|
|
312
323
|
if (!DISK_SPACE) {
|
|
313
324
|
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().grey('All available disk space at /data will be used'));
|
|
314
325
|
}
|
|
315
326
|
else {
|
|
316
|
-
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default
|
|
327
|
+
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default
|
|
328
|
+
.bold()
|
|
329
|
+
.yellow('Variable DISK_SPACE is read-only, allocated space:'), DISK_SPACE === null || DISK_SPACE === void 0 ? void 0 : DISK_SPACE.value);
|
|
317
330
|
}
|
|
318
331
|
}
|
|
319
332
|
// Backup and restore configuration
|
|
320
333
|
let backupHost = ((_a = (0, utils_1.findExistingValue)('BACKUP_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _a === void 0 ? void 0 : _a.value) || '';
|
|
321
334
|
let backupType = '';
|
|
322
335
|
let restoreEnvironmentName = (_b = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _b === void 0 ? void 0 : _b.value;
|
|
323
|
-
let restoreType = ((_c = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _c === void 0 ? void 0 : _c.value) ||
|
|
336
|
+
let restoreType = ((_c = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _c === void 0 ? void 0 : _c.value) ||
|
|
337
|
+
process.env.RESTORE_ENVIRONMENT_MODE ||
|
|
338
|
+
'dump';
|
|
324
339
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Backup'));
|
|
325
340
|
let configureBackup = backupHost ? true : false;
|
|
326
341
|
// Ask question only if backup and restore are not configured
|
|
@@ -333,15 +348,17 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
333
348
|
let backupHostPrivateKey = '';
|
|
334
349
|
let backupHostPublicKey = '';
|
|
335
350
|
if (configureBackup) {
|
|
336
|
-
const backupAnswers =
|
|
337
|
-
|
|
351
|
+
const backupAnswers = yield promptAndStoreAnswer(environment, questions_1.backupQuestions, existingValues);
|
|
352
|
+
const backupHostPrivateKeyExists = (0, utils_1.findExistingValue)('BACKUP_HOST_PRIVATE_KEY', 'SECRET', 'ENVIRONMENT', existingValues);
|
|
338
353
|
backupType = backupAnswers.backupType;
|
|
339
354
|
backupHost = backupAnswers.backupHost || backupHost;
|
|
340
355
|
if (!backupHostPrivateKeyExists) {
|
|
341
356
|
const { publicKey, privateKey } = (0, ssh_keygen_1.generateSSHKeyPair)();
|
|
342
357
|
backupHostPublicKey = publicKey;
|
|
343
358
|
backupHostPrivateKey = privateKey;
|
|
344
|
-
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default
|
|
359
|
+
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default
|
|
360
|
+
.bold()
|
|
361
|
+
.yellow(`Generated new SSH key pair for backup host: ${backupHost}`));
|
|
345
362
|
}
|
|
346
363
|
}
|
|
347
364
|
else {
|
|
@@ -356,16 +373,17 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
356
373
|
});
|
|
357
374
|
}
|
|
358
375
|
if (configureRestore) {
|
|
359
|
-
const env_list_filtered = existingEnvironments.filter(env => env !== environment);
|
|
376
|
+
const env_list_filtered = existingEnvironments.filter((env) => env !== environment);
|
|
360
377
|
restoreEnvironmentName = yield (0, questions_helper_1.selectWithCustom)({
|
|
361
378
|
message: 'What is the name of your environment to restore?',
|
|
362
|
-
choices: env_list_filtered.map(env => ({
|
|
379
|
+
choices: env_list_filtered.map((env) => ({
|
|
363
380
|
name: env,
|
|
364
381
|
value: env
|
|
365
382
|
})),
|
|
366
383
|
initial: restoreEnvironmentName
|
|
367
384
|
});
|
|
368
|
-
restoreType = yield select({
|
|
385
|
+
restoreType = yield select({
|
|
386
|
+
message: `Select ${kleur_1.default.yellow().bold(restoreEnvironmentName)} environment backup mode`,
|
|
369
387
|
choices: [
|
|
370
388
|
{
|
|
371
389
|
name: 'Full dump (daily full database backup)',
|
|
@@ -375,7 +393,8 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
375
393
|
name: 'Differential (weekly full, daily diff backup)',
|
|
376
394
|
value: 'differential'
|
|
377
395
|
}
|
|
378
|
-
]
|
|
396
|
+
]
|
|
397
|
+
});
|
|
379
398
|
}
|
|
380
399
|
else {
|
|
381
400
|
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Restore is disabled'));
|
|
@@ -410,9 +429,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
410
429
|
/*
|
|
411
430
|
* Variables the user doesn't need to set manually
|
|
412
431
|
*/
|
|
413
|
-
const answerOrExisting = (variable, existingValue,
|
|
414
|
-
// eslint-disable-next-line no-unused-vars
|
|
415
|
-
fn) => fn(variable || (existingValue === null || existingValue === void 0 ? void 0 : existingValue.value)) || '';
|
|
432
|
+
const answerOrExisting = (variable, existingValue, fn) => fn(variable || (existingValue === null || existingValue === void 0 ? void 0 : existingValue.value)) || '';
|
|
416
433
|
function findExistingOrDefine(name, type, scope, newValue) {
|
|
417
434
|
return (0, utils_1.findExistingValue)(name, type, scope, existingValues)
|
|
418
435
|
? null
|
|
@@ -425,7 +442,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
425
442
|
didExist: (0, utils_1.findExistingValue)('GH_ENCRYPTION_PASSWORD', 'SECRET', 'REPOSITORY', existingValues),
|
|
426
443
|
value: findExistingOrDefine('GH_ENCRYPTION_PASSWORD', 'SECRET', 'REPOSITORY', (0, utils_1.generateLongPassword)()),
|
|
427
444
|
scope: 'REPOSITORY'
|
|
428
|
-
}
|
|
445
|
+
}
|
|
429
446
|
];
|
|
430
447
|
derivedUpdates.push({
|
|
431
448
|
name: 'NOTIFICATION_TRANSPORT',
|
|
@@ -732,24 +749,28 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
732
749
|
two_fa_enabled: environment !== 'production' ? false : true,
|
|
733
750
|
backup_enabled: configureBackup ? true : false,
|
|
734
751
|
restore_enabled: restoreEnvironmentName ? true : false,
|
|
735
|
-
restore_environment_name: restoreEnvironmentName ||
|
|
752
|
+
restore_environment_name: restoreEnvironmentName || '',
|
|
736
753
|
restore_type: restoreType,
|
|
737
754
|
traefik_mode: traefikConfOption,
|
|
738
755
|
backup_type: backupType
|
|
739
756
|
});
|
|
740
|
-
let addon_message = kubeWorkerNodes.length > 0 || configureBackup
|
|
741
|
-
|
|
757
|
+
let addon_message = kubeWorkerNodes.length > 0 || configureBackup
|
|
758
|
+
? '--------------------------------------------------------------------------------------------\n' +
|
|
742
759
|
`\n➡️ ${kleur_1.default.bold().yellow('COPY the SSH public key from the master VM to your clipboard')}\n` +
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
760
|
+
'--------------------------------------------------------------------------------------------\n'
|
|
761
|
+
: '';
|
|
762
|
+
addon_message +=
|
|
763
|
+
kubeWorkerNodes.length > 0
|
|
764
|
+
? `➡️ ${kleur_1.default.bold().yellow('Run following command on Kubernetes worker VM to create provision user and setup SSH key:')}\n` +
|
|
765
|
+
'\n' +
|
|
766
|
+
'curl -sfL https://raw.githubusercontent.com/opencrvs/infrastructure/refs/heads/develop/scripts/bootstrap/opencrvs-bootstrap.sh -o opencrvs-bootstrap.sh && \\ \n' +
|
|
767
|
+
`bash opencrvs-bootstrap.sh --ssh-public-key "${kleur_1.default.bold('[PUT PROVISION USER PUBLIC KEY FROM MASTER NODE]')}"\n`
|
|
768
|
+
: '';
|
|
769
|
+
addon_message += configureBackup
|
|
770
|
+
? `\n➡️ ${kleur_1.default.bold().yellow('Run following command on backup server to create provision user and setup SSH key:')}\n` +
|
|
771
|
+
'curl -sfL https://raw.githubusercontent.com/opencrvs/infrastructure/refs/heads/develop/scripts/bootstrap/opencrvs-bootstrap.sh -o opencrvs-bootstrap.sh && \\ \n' +
|
|
772
|
+
`bash opencrvs-bootstrap.sh --ssh-public-key "${kleur_1.default.bold('[PUT PROVISION USER PUBLIC KEY FROM MASTER NODE]')}"`
|
|
773
|
+
: '';
|
|
753
774
|
(0, logger_1.log)(`
|
|
754
775
|
${kleur_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')}
|
|
755
776
|
Follow the steps below to complete the setup of your environment:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-keygen.d.ts","sourceRoot":"","sources":["../../src/environment/ssh-keygen.ts"],"names":[],"mappings":"AAaA,wBAAgB,kBAAkB,IAAI;
|
|
1
|
+
{"version":3,"file":"ssh-keygen.d.ts","sourceRoot":"","sources":["../../src/environment/ssh-keygen.ts"],"names":[],"mappings":"AAaA,wBAAgB,kBAAkB,IAAI;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB,CAMA"}
|
|
@@ -13,6 +13,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.generateSSHKeyPair = generateSSHKeyPair;
|
|
14
14
|
const ssh2_1 = require("ssh2");
|
|
15
15
|
function generateSSHKeyPair() {
|
|
16
|
-
|
|
17
|
-
return {
|
|
16
|
+
const keys = ssh2_1.utils.generateKeyPairSync('ed25519');
|
|
17
|
+
return {
|
|
18
|
+
publicKey: keys.public.toString(),
|
|
19
|
+
privateKey: keys.private.toString()
|
|
20
|
+
};
|
|
18
21
|
}
|