@opencrvs/toolkit 2.1.0-rc.0ec4a9a → 2.1.0-rc.12673aa
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 +3 -12
- package/build.sh +9 -1
- package/create-countryconfig/index.js +412 -59
- package/create-countryconfig/node_modules/.bin/degit +21 -0
- package/create-countryconfig/package.json +4 -1
- package/dist/application-config/index.js +340 -275
- package/dist/authentication/index.d.ts +67 -0
- package/dist/authentication/index.d.ts.map +1 -0
- package/dist/authentication/index.js +750 -0
- package/dist/cli.js +1918 -282
- package/dist/commons/api/router.d.ts +691 -79
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +16 -5
- package/dist/commons/events/ActionDocument.d.ts +5 -11
- package/dist/commons/events/ActionInput.d.ts +4 -4
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -0
- package/dist/commons/events/AuditLog.d.ts +147 -0
- package/dist/commons/events/EventConfig.d.ts +3 -0
- package/dist/commons/events/EventDocument.d.ts +470 -2
- package/dist/commons/events/EventIndex.d.ts +3 -26
- package/dist/commons/events/EventMetadata.d.ts +1 -11
- package/dist/commons/events/EventStatus.d.ts +19 -0
- package/dist/commons/events/FieldConfig.d.ts +89 -53
- package/dist/commons/events/FieldTypeMapping.d.ts +27 -27
- package/dist/commons/events/FieldValue.d.ts +2 -2
- package/dist/commons/events/Flag.d.ts +42 -0
- package/dist/commons/events/PlainDate.d.ts +8 -0
- package/dist/commons/events/SummaryConfig.d.ts +249 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
- package/dist/commons/events/event.d.ts +12 -0
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/locationPayloads.d.ts +95 -0
- package/dist/commons/events/locations.d.ts +169 -29
- package/dist/commons/events/mocks.test.utils.d.ts +30 -2
- package/dist/commons/events/test.utils.d.ts +25 -4
- package/dist/commons/events/utils.d.ts +13 -2
- package/dist/commons/notification/UserNotifications.d.ts +28 -13
- package/dist/commons/notification/dispatch.d.ts +10 -0
- package/dist/commons/notification/index.d.ts +1 -0
- package/dist/conditionals/index.js +328 -58
- package/dist/csv.d.ts +25 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +120 -0
- package/dist/environment/index.d.ts +1 -0
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +10 -0
- package/dist/environment/logger.d.ts +15 -3
- package/dist/environment/logger.d.ts.map +1 -1
- package/dist/environment/manage-users.js +1 -1
- package/dist/environment/paths.d.ts +7 -0
- package/dist/environment/paths.d.ts.map +1 -0
- package/dist/environment/paths.js +72 -0
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +20 -14
- package/dist/environment/setup-environment.js +43 -28
- package/dist/environment/templates.d.ts +0 -1
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +5 -9
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +21 -5
- package/dist/environment/upgrade.d.ts +2 -0
- package/dist/environment/upgrade.d.ts.map +1 -0
- package/dist/environment/upgrade.js +82 -0
- package/dist/environment/users.js +11 -13
- package/dist/environment/utils.d.ts +0 -12
- package/dist/environment/utils.d.ts.map +1 -1
- package/dist/environment/utils.js +1 -28
- package/dist/events/index.js +7537 -7058
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
- package/dist/migrations/v2.1/add-translations.d.ts +9 -0
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-translations.js +213 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
- package/dist/migrations/v2.1/enable-telemetry.js +438 -0
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +1058 -0
- package/dist/notification/index.js +1825 -1423
- package/dist/scopes/index.d.ts +327 -32
- package/dist/scopes/index.js +329 -58
- package/dist/telemetry/index.d.ts +45 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +39 -0
- package/dist/templates/charts-values/dependencies/values.yaml +2 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
- package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
- package/dist/templates/charts-values/traefik/values.yaml +23 -9
- package/dist/templates/inventory/inventory.template.yml +1 -3
- package/dist/translations/check.d.ts +21 -0
- package/dist/translations/check.d.ts.map +1 -0
- package/dist/translations/check.js +132 -0
- package/dist/verify/endpoints.d.ts +2 -0
- package/dist/verify/endpoints.d.ts.map +1 -0
- package/dist/verify/endpoints.js +345 -0
- package/opencrvs-toolkit-2.1.0-rc.12673aa.tgz +0 -0
- package/package.json +12 -6
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/dist/templates/inventory/production.example.yml +0 -77
- package/dist/templates/inventory/qa.example.yml +0 -48
- package/opencrvs-toolkit-2.1.0-rc.0ec4a9a.tgz +0 -0
- package/tsconfig.tsbuildinfo +0 -1
package/dist/csv.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.parseCsvLine = parseCsvLine;
|
|
14
|
+
exports.toCsvLine = toCsvLine;
|
|
15
|
+
exports.idOf = idOf;
|
|
16
|
+
exports.readCsvFile = readCsvFile;
|
|
17
|
+
exports.writeCsvFile = writeCsvFile;
|
|
18
|
+
exports.addRows = addRows;
|
|
19
|
+
/**
|
|
20
|
+
* Just enough CSV for the translation files codemods edit. They are read and
|
|
21
|
+
* written a line at a time rather than through a parser, so that adding two
|
|
22
|
+
* rows to a file of sixteen hundred produces a diff of two lines instead of a
|
|
23
|
+
* re-quoted rewrite of the whole thing.
|
|
24
|
+
*
|
|
25
|
+
* Rows spanning multiple lines are not supported, and none of the translation
|
|
26
|
+
* files contain any.
|
|
27
|
+
*/
|
|
28
|
+
const fs_1 = require("fs");
|
|
29
|
+
function parseCsvLine(line) {
|
|
30
|
+
const values = [];
|
|
31
|
+
let value = '';
|
|
32
|
+
let quoted = false;
|
|
33
|
+
for (let index = 0; index < line.length; index++) {
|
|
34
|
+
const character = line[index];
|
|
35
|
+
if (quoted) {
|
|
36
|
+
if (character !== '"') {
|
|
37
|
+
value += character;
|
|
38
|
+
}
|
|
39
|
+
else if (line[index + 1] === '"') {
|
|
40
|
+
value += '"';
|
|
41
|
+
index++;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
quoted = false;
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (character === '"') {
|
|
49
|
+
quoted = true;
|
|
50
|
+
}
|
|
51
|
+
else if (character === ',') {
|
|
52
|
+
values.push(value);
|
|
53
|
+
value = '';
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
value += character;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
values.push(value);
|
|
60
|
+
return values;
|
|
61
|
+
}
|
|
62
|
+
function toCsvLine(values) {
|
|
63
|
+
return values
|
|
64
|
+
.map((value) => /["\n,]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value)
|
|
65
|
+
.join(',');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The id of a row, which is its first column. Translation ids never contain a
|
|
69
|
+
* comma or a quote, so this does not need the parser.
|
|
70
|
+
*/
|
|
71
|
+
function idOf(line) {
|
|
72
|
+
const comma = line.indexOf(',');
|
|
73
|
+
// No comma: `slice(0, -1)` would eat the last character.
|
|
74
|
+
return comma === -1 ? line : line.slice(0, comma);
|
|
75
|
+
}
|
|
76
|
+
function readCsvFile(path) {
|
|
77
|
+
if (!(0, fs_1.existsSync)(path)) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const contents = (0, fs_1.readFileSync)(path, 'utf8');
|
|
81
|
+
const newline = contents.includes('\r\n') ? '\r\n' : '\n';
|
|
82
|
+
const trailingNewline = /\r?\n$/.test(contents);
|
|
83
|
+
const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
|
|
84
|
+
// Trailing blank line leaves an empty entry. It sorts before every id, so
|
|
85
|
+
// the file reads as unsorted.
|
|
86
|
+
const body = lines.slice(1).filter((line) => line !== '');
|
|
87
|
+
return { header: lines[0], body, newline, trailingNewline };
|
|
88
|
+
}
|
|
89
|
+
function writeCsvFile(path, file) {
|
|
90
|
+
(0, fs_1.writeFileSync)(path, [file.header, ...file.body].join(file.newline) +
|
|
91
|
+
(file.trailingNewline ? file.newline : ''));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Adds the rows the file does not already have an id for, in place. Rows go in
|
|
95
|
+
* sorted position when the file is sorted by id, and at the end when it is not,
|
|
96
|
+
* so a country config that keeps its own order keeps it.
|
|
97
|
+
*
|
|
98
|
+
* Returns the ids that were added.
|
|
99
|
+
*/
|
|
100
|
+
function addRows(file, rows) {
|
|
101
|
+
const isSorted = file.body.every((line, index) => index === 0 || idOf(file.body[index - 1]) <= idOf(line));
|
|
102
|
+
const added = [];
|
|
103
|
+
for (const row of rows) {
|
|
104
|
+
const id = idOf(row);
|
|
105
|
+
if (file.body.some((line) => idOf(line) === id)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const insertAt = isSorted
|
|
109
|
+
? file.body.findIndex((line) => idOf(line) > id)
|
|
110
|
+
: -1;
|
|
111
|
+
if (insertAt === -1) {
|
|
112
|
+
file.body.push(row);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
file.body.splice(insertAt, 0, row);
|
|
116
|
+
}
|
|
117
|
+
added.push(id);
|
|
118
|
+
}
|
|
119
|
+
return added;
|
|
120
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function runEnvironmentInit(): Promise<void>;
|
|
2
|
+
export declare function runEnvironmentUpgrade(): Promise<void>;
|
|
2
3
|
export declare function runEnvironmentUpdateWorkflows(): Promise<void>;
|
|
3
4
|
export declare function runEnvironmentUsers(): Promise<void>;
|
|
4
5
|
export declare function runEnvironmentSwarmToK8s(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"AAyCA,wBAAsB,kBAAkB,kBAIvC;AAED,wBAAsB,qBAAqB,kBAI1C;AAED,wBAAsB,6BAA6B,kBAIlD;AAED,wBAAsB,mBAAmB,kBAIxC;AAED,wBAAsB,wBAAwB,kBAG7C"}
|
|
@@ -20,11 +20,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.runEnvironmentInit = runEnvironmentInit;
|
|
23
|
+
exports.runEnvironmentUpgrade = runEnvironmentUpgrade;
|
|
23
24
|
exports.runEnvironmentUpdateWorkflows = runEnvironmentUpdateWorkflows;
|
|
24
25
|
exports.runEnvironmentUsers = runEnvironmentUsers;
|
|
25
26
|
exports.runEnvironmentSwarmToK8s = runEnvironmentSwarmToK8s;
|
|
26
27
|
const fs_1 = require("fs");
|
|
27
28
|
const path_1 = require("path");
|
|
29
|
+
const paths_1 = require("./paths");
|
|
28
30
|
const REQUIRED_REPOSITORY_DIRECTORIES = [
|
|
29
31
|
'.github/workflows',
|
|
30
32
|
'environments',
|
|
@@ -46,9 +48,17 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
46
48
|
function runEnvironmentInit() {
|
|
47
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
50
|
validateRepositoryStructure();
|
|
51
|
+
(0, paths_1.assertNoOldInventoryLayout)();
|
|
49
52
|
yield import('./setup-environment.js');
|
|
50
53
|
});
|
|
51
54
|
}
|
|
55
|
+
function runEnvironmentUpgrade() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
validateRepositoryStructure();
|
|
58
|
+
const { upgradeEnvironmentLayout } = yield import('./upgrade.js');
|
|
59
|
+
yield upgradeEnvironmentLayout();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
52
62
|
function runEnvironmentUpdateWorkflows() {
|
|
53
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
64
|
validateRepositoryStructure();
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
export declare const log:
|
|
2
|
-
|
|
1
|
+
export declare const log: {
|
|
2
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
3
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
4
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
5
|
+
};
|
|
6
|
+
export declare const warn: {
|
|
7
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
8
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
9
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
10
|
+
};
|
|
3
11
|
export declare const success: (...args: any[]) => void;
|
|
4
|
-
export declare const info:
|
|
12
|
+
export declare const info: {
|
|
13
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
14
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
15
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
16
|
+
};
|
|
5
17
|
export declare const error: (...args: any[]) => void;
|
|
6
18
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG;;;;CAAc,CAAA;AAC9B,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,OAAO,YAAa,GAAG,EAAE,SACI,CAAA;AAC1C,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,KAAK,YAAa,GAAG,EAAE,SAA2C,CAAA"}
|
|
@@ -95,7 +95,7 @@ function updateInventoryFile(filePath, users) {
|
|
|
95
95
|
function parseInventoryFile(filePath) {
|
|
96
96
|
try {
|
|
97
97
|
const data = (0, utils_1.readYamlFile)(filePath);
|
|
98
|
-
return (0, templates_1.
|
|
98
|
+
return (0, templates_1.extractAndModifyUsers)(data);
|
|
99
99
|
}
|
|
100
100
|
catch (_a) {
|
|
101
101
|
return [];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const OLD_INVENTORY_DIR: string;
|
|
2
|
+
export declare const INVENTORY_FILE_NAME = "inventory.yml";
|
|
3
|
+
export declare function getEnvironmentInventoryPath(environment: string): string;
|
|
4
|
+
export declare function findOldInventoryFiles(): string[];
|
|
5
|
+
export declare function getEnvironmentNameFromOldInventoryPath(filePath: string): string;
|
|
6
|
+
export declare function assertNoOldInventoryLayout(): void;
|
|
7
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/environment/paths.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,iBAAiB,QAI7B,CAAA;AAED,eAAO,MAAM,mBAAmB,kBAAkB,CAAA;AAElD,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,UAE9D;AAED,wBAAgB,qBAAqB,aAEpC;AAED,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,MAAM,UAEtE;AAED,wBAAgB,0BAA0B,SAWzC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.INVENTORY_FILE_NAME = exports.OLD_INVENTORY_DIR = void 0;
|
|
47
|
+
exports.getEnvironmentInventoryPath = getEnvironmentInventoryPath;
|
|
48
|
+
exports.findOldInventoryFiles = findOldInventoryFiles;
|
|
49
|
+
exports.getEnvironmentNameFromOldInventoryPath = getEnvironmentNameFromOldInventoryPath;
|
|
50
|
+
exports.assertNoOldInventoryLayout = assertNoOldInventoryLayout;
|
|
51
|
+
const path_1 = require("path");
|
|
52
|
+
const glob = __importStar(require("glob"));
|
|
53
|
+
exports.OLD_INVENTORY_DIR = (0, path_1.join)('infrastructure', 'server-setup', 'inventory');
|
|
54
|
+
exports.INVENTORY_FILE_NAME = 'inventory.yml';
|
|
55
|
+
function getEnvironmentInventoryPath(environment) {
|
|
56
|
+
return (0, path_1.join)('environments', environment, exports.INVENTORY_FILE_NAME);
|
|
57
|
+
}
|
|
58
|
+
function findOldInventoryFiles() {
|
|
59
|
+
return glob.sync((0, path_1.join)(exports.OLD_INVENTORY_DIR, '*.yml')).sort();
|
|
60
|
+
}
|
|
61
|
+
function getEnvironmentNameFromOldInventoryPath(filePath) {
|
|
62
|
+
return (0, path_1.basename)(filePath, '.yml');
|
|
63
|
+
}
|
|
64
|
+
function assertNoOldInventoryLayout() {
|
|
65
|
+
if (findOldInventoryFiles().length === 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
throw new Error([
|
|
69
|
+
`Old inventory layout detected at ${exports.OLD_INVENTORY_DIR}.`,
|
|
70
|
+
'Please run `yarn environment:upgrade` before running `yarn environment:init`.'
|
|
71
|
+
].join(' '));
|
|
72
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,QAAQ,UAAW,MAAM,GAAG,MAAM,kCAC4B,CAAA;AAepE,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBnD;AAED,eAAO,MAAM,kBAAkB;;UAGrB,MAAM;;eAED,QAAQ;;;;WAIZ,YAAY;GAiCtB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;;;WAIL,YAAY;GAUtB,CAAA;AACD,eAAO,MAAM,oBAAoB;;UAGvB,MAAM;;;eAGD,UAAU;;WAEd,YAAY;;;;;UAIb,QAAQ;;;;;;eAaH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AACD,eAAO,MAAM,mBAAmB;;UAGtB,MAAM;;;;eAID,QAAQ;WACZ,YAAY;;GAGtB,CAAA;AAED,eAAO,MAAM,gBAAgB;;UAGnB,MAAM;;eAGD,UAAU;;;WAGd,YAAY;GAEtB,CAAA;AAED,eAAO,MAAM,uBAAuB;;UAG1B,MAAM;;eAED,UAAU;;;;WAId,aAAa;;;;UAId,MAAM;;eAED,UAAU;;;
|
|
1
|
+
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,QAAQ,UAAW,MAAM,GAAG,MAAM,kCAC4B,CAAA;AAepE,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBnD;AAED,eAAO,MAAM,kBAAkB;;UAGrB,MAAM;;eAED,QAAQ;;;;WAIZ,YAAY;GAiCtB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;;;WAIL,YAAY;GAUtB,CAAA;AACD,eAAO,MAAM,oBAAoB;;UAGvB,MAAM;;;eAGD,UAAU;;WAEd,YAAY;;;;;UAIb,QAAQ;;;;;;eAaH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AACD,eAAO,MAAM,mBAAmB;;UAGtB,MAAM;;;;eAID,QAAQ;WACZ,YAAY;;GAGtB,CAAA;AAED,eAAO,MAAM,gBAAgB;;UAGnB,MAAM;;eAGD,UAAU;;;WAGd,YAAY;GAEtB,CAAA;AAED,eAAO,MAAM,uBAAuB;;UAG1B,MAAM;;eAED,UAAU;;;;WAId,aAAa;;;;UAId,MAAM;;eAED,UAAU;;;WAGd,aAAa;;;UAsBd,MAAM;;eAED,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;;UAGzB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,eAAe;;;;UAGlB,MAAM;;eAED,UAAU;;;WAGd,aAAa;;;;UAId,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAId,QAAQ;;;;;;eAYH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AAED,eAAO,MAAM,aAAa;;UAGhB,MAAM;;eAID,UAAU;;;;WAId,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,8BAA8B;;UAGjC,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,cAAc;;;UAGjB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAkCd,QAAQ;;;;;;eAYH,QAAQ;;;;WAIZ,aAAa;IAuBvB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;eAEpB,QAAQ;;UAEb,MAAM;;;WAIL,aAAa;;GAYvB,CAAA"}
|
|
@@ -166,11 +166,28 @@ exports.infrastructureQuestions = [
|
|
|
166
166
|
scope: 'ENVIRONMENT'
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
|
-
name: '
|
|
169
|
+
name: 'kubeMasterNode',
|
|
170
170
|
type: 'text',
|
|
171
|
-
message: `Kubernetes
|
|
171
|
+
message: `Kubernetes master node hostnames or IP (default: auto-detect)`,
|
|
172
|
+
valueType: 'VARIABLE',
|
|
173
|
+
valueLabel: 'KUBE_MASTER_NODE',
|
|
174
|
+
initial: process.env.KUBE_MASTER_NODE,
|
|
175
|
+
scope: 'ENVIRONMENT'
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'kubeWorkerNodes',
|
|
179
|
+
type: 'text',
|
|
180
|
+
message: `Kubernetes worker node hostnames or IPs (comma-separated, default: no worker nodes)`,
|
|
181
|
+
valueType: 'VARIABLE',
|
|
182
|
+
valueLabel: 'KUBE_WORKER_NODES',
|
|
183
|
+
initial: process.env.KUBE_WORKER_NODES || '',
|
|
184
|
+
scope: 'ENVIRONMENT'
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'kubeApiHost',
|
|
188
|
+
type: 'text',
|
|
189
|
+
message: `Kubernetes API endpoint IP (default: KUBE_MASTER_NODE)`,
|
|
172
190
|
valueType: 'VARIABLE',
|
|
173
|
-
// validate: notEmpty,
|
|
174
191
|
valueLabel: 'KUBE_API_HOST',
|
|
175
192
|
initial: process.env.KUBE_API_HOST,
|
|
176
193
|
scope: 'ENVIRONMENT'
|
|
@@ -185,16 +202,6 @@ exports.infrastructureQuestions = [
|
|
|
185
202
|
initial: process.env.KUBE_API_ALLOWED_CIDRS || '',
|
|
186
203
|
scope: 'ENVIRONMENT'
|
|
187
204
|
},
|
|
188
|
-
{
|
|
189
|
-
name: 'kubeWorkerNodes',
|
|
190
|
-
type: 'text',
|
|
191
|
-
message: `Kubernetes worker node hostnames or IPs (comma-separated, default: no worker nodes)`,
|
|
192
|
-
valueType: 'VARIABLE',
|
|
193
|
-
// validate: notEmpty,
|
|
194
|
-
valueLabel: 'KUBE_WORKER_NODES',
|
|
195
|
-
initial: process.env.KUBE_WORKER_NODES || '',
|
|
196
|
-
scope: 'ENVIRONMENT'
|
|
197
|
-
}
|
|
198
205
|
];
|
|
199
206
|
exports.staticSSLCertQuestions = [
|
|
200
207
|
{
|
|
@@ -224,7 +231,6 @@ exports.backupQuestions = [
|
|
|
224
231
|
type: 'text',
|
|
225
232
|
message: `Please enter backup server host/IP address, (default: no backup):`,
|
|
226
233
|
valueType: 'VARIABLE',
|
|
227
|
-
// validate: notEmpty,
|
|
228
234
|
valueLabel: 'BACKUP_HOST',
|
|
229
235
|
initial: process.env.BACKUP_HOST || '',
|
|
230
236
|
scope: 'ENVIRONMENT'
|
|
@@ -34,7 +34,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const core_1 = require("@octokit/core");
|
|
37
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
38
37
|
const kleur_1 = __importDefault(require("kleur"));
|
|
39
38
|
const prompts_1 = __importDefault(require("prompts"));
|
|
40
39
|
function confirm(options) {
|
|
@@ -49,6 +48,12 @@ function select(options) {
|
|
|
49
48
|
return inquirer.select(options);
|
|
50
49
|
});
|
|
51
50
|
}
|
|
51
|
+
function input(options) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const inquirer = yield import('@inquirer/prompts');
|
|
54
|
+
return inquirer.input(options);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
52
57
|
const github_1 = require("./github");
|
|
53
58
|
const derived_variables_1 = require("./derived-variables");
|
|
54
59
|
const utils_1 = require("./utils");
|
|
@@ -59,6 +64,7 @@ const questions_1 = require("./questions");
|
|
|
59
64
|
const editor_questions_1 = require("./editor-questions");
|
|
60
65
|
const questions_helper_1 = require("./questions-helper");
|
|
61
66
|
const manage_users_1 = require("./manage-users");
|
|
67
|
+
const paths_1 = require("./paths");
|
|
62
68
|
function questionToPrompt(_a) {
|
|
63
69
|
var { valueType, valueLabel, scope } = _a, promptOptions = __rest(_a, ["valueType", "valueLabel", "scope"]);
|
|
64
70
|
return promptOptions;
|
|
@@ -104,7 +110,7 @@ function getAnswers(existingValues) {
|
|
|
104
110
|
});
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
|
-
function promptAndStoreAnswer(
|
|
113
|
+
function promptAndStoreAnswer(questions, existingValues) {
|
|
108
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
115
|
(0, logger_1.log)('');
|
|
110
116
|
const processedQuestions = questions.flatMap((question) => {
|
|
@@ -157,7 +163,6 @@ function promptAndStoreAnswer(environment, questions, existingValues) {
|
|
|
157
163
|
}
|
|
158
164
|
});
|
|
159
165
|
ALL_ANSWERS.push(result);
|
|
160
|
-
(0, utils_1.storeSecrets)(environment, getAnswers(existingValues));
|
|
161
166
|
const existingValuesForQuestions = questions
|
|
162
167
|
// Only variables can have previous values we can use
|
|
163
168
|
.filter((question) => question.valueType === 'VARIABLE')
|
|
@@ -170,14 +175,14 @@ function promptAndStoreAnswer(environment, questions, existingValues) {
|
|
|
170
175
|
}
|
|
171
176
|
ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOtherQuestions, ...questions_1.dockerhubQuestions, ...questions_1.diskQuestions, ...questions_1.infrastructureQuestions, ...questions_1.backupQuestions, ...questions_1.countryQuestions, ...questions_1.databaseAndMonitoringQuestions, ...questions_1.emailQuestions, ...questions_1.sentryQuestions, ...derived_variables_1.derivedVariables, ...questions_1.metabaseAdminQuestions);
|
|
172
177
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
-
var _a, _b, _c;
|
|
178
|
+
var _a, _b, _c, _d;
|
|
174
179
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Github'), '\n');
|
|
175
180
|
const { githubOrganisation, githubRepository } = yield (0, prompts_1.default)(questions_1.githubQuestions.map(questionToPrompt), {
|
|
176
181
|
onCancel: () => {
|
|
177
182
|
process.exit(1);
|
|
178
183
|
}
|
|
179
184
|
});
|
|
180
|
-
const { githubToken } = yield promptAndStoreAnswer(
|
|
185
|
+
const { githubToken } = yield promptAndStoreAnswer(questions_1.githubTokenQuestion, []);
|
|
181
186
|
const octokit = new core_1.Octokit({
|
|
182
187
|
auth: githubToken
|
|
183
188
|
});
|
|
@@ -237,10 +242,6 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
237
242
|
if (!environment) {
|
|
238
243
|
process.exit(1);
|
|
239
244
|
}
|
|
240
|
-
// Read users .env file based on the environment name they gave above, e.g. .env.production
|
|
241
|
-
dotenv_1.default.config({
|
|
242
|
-
path: `${process.cwd()}/.env.${environment}`
|
|
243
|
-
});
|
|
244
245
|
yield (0, github_1.createEnvironment)(octokit, environment, githubOrganisation, githubRepository);
|
|
245
246
|
const repositoryId = yield (0, github_1.getRepositoryId)(octokit, githubOrganisation, githubRepository);
|
|
246
247
|
const existingRepositorySecrets = yield (0, github_1.listRepositorySecrets)(octokit, githubOrganisation, githubRepository);
|
|
@@ -261,17 +262,17 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
261
262
|
(0, logger_1.log)('\n', kleur_1.default
|
|
262
263
|
.yellow()
|
|
263
264
|
.bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
|
|
264
|
-
yield promptAndStoreAnswer(
|
|
265
|
+
yield promptAndStoreAnswer(questions_1.githubOtherQuestions, existingValues);
|
|
265
266
|
}
|
|
266
267
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Docker Hub'));
|
|
267
|
-
yield promptAndStoreAnswer(
|
|
268
|
+
yield promptAndStoreAnswer(questions_1.dockerhubQuestions, existingValues);
|
|
268
269
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
|
|
269
|
-
const infrastructure = yield promptAndStoreAnswer(
|
|
270
|
+
const infrastructure = yield promptAndStoreAnswer(questions_1.infrastructureQuestions, existingValues);
|
|
270
271
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes
|
|
271
272
|
? infrastructure.kubeWorkerNodes.split(',').map((ip) => ip.trim())
|
|
272
273
|
: [];
|
|
273
274
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('SSH Users'), '\n');
|
|
274
|
-
const users = yield (0, manage_users_1.manageUsers)(
|
|
275
|
+
const users = yield (0, manage_users_1.manageUsers)((0, paths_1.getEnvironmentInventoryPath)(environment));
|
|
275
276
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Traefik SSL Certificate'), '\n');
|
|
276
277
|
const sslCertExists = (0, utils_1.findExistingValue)('SSL_CRT', 'SECRET', 'ENVIRONMENT', existingValues);
|
|
277
278
|
let ssl_answers = [];
|
|
@@ -308,7 +309,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
308
309
|
}
|
|
309
310
|
if (enableEncryption && !encryption_key_defined && !environment_exists) {
|
|
310
311
|
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow(' Disk encryption is enabled'));
|
|
311
|
-
yield promptAndStoreAnswer(
|
|
312
|
+
yield promptAndStoreAnswer(questions_1.diskQuestions, existingValues);
|
|
312
313
|
}
|
|
313
314
|
else {
|
|
314
315
|
if (!enableEncryption && !encryption_key_defined && environment_exists) {
|
|
@@ -330,7 +331,8 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
330
331
|
let backupHost = ((_a = (0, utils_1.findExistingValue)('BACKUP_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _a === void 0 ? void 0 : _a.value) || '';
|
|
331
332
|
let backupType = '';
|
|
332
333
|
let restoreEnvironmentName = (_b = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _b === void 0 ? void 0 : _b.value;
|
|
333
|
-
let
|
|
334
|
+
let restoreHost = ((_c = (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _c === void 0 ? void 0 : _c.value) || '';
|
|
335
|
+
let restoreType = ((_d = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _d === void 0 ? void 0 : _d.value) ||
|
|
334
336
|
process.env.RESTORE_ENVIRONMENT_MODE ||
|
|
335
337
|
'dump';
|
|
336
338
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Backup'));
|
|
@@ -345,7 +347,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
345
347
|
let backupHostPrivateKey = '';
|
|
346
348
|
let backupHostPublicKey = '';
|
|
347
349
|
if (configureBackup) {
|
|
348
|
-
const backupAnswers = yield promptAndStoreAnswer(
|
|
350
|
+
const backupAnswers = yield promptAndStoreAnswer(questions_1.backupQuestions, existingValues);
|
|
349
351
|
const backupHostPrivateKeyExists = (0, utils_1.findExistingValue)('BACKUP_HOST_PRIVATE_KEY', 'SECRET', 'ENVIRONMENT', existingValues);
|
|
350
352
|
backupType = backupAnswers.backupType;
|
|
351
353
|
backupHost = backupAnswers.backupHost || backupHost;
|
|
@@ -392,16 +394,20 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
392
394
|
}
|
|
393
395
|
]
|
|
394
396
|
});
|
|
397
|
+
restoreHost = yield input({
|
|
398
|
+
message: 'What is the host/IP address of the restore backup server?',
|
|
399
|
+
default: restoreHost
|
|
400
|
+
});
|
|
395
401
|
}
|
|
396
402
|
else {
|
|
397
403
|
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Restore is disabled'));
|
|
398
404
|
}
|
|
399
405
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Monitoring'));
|
|
400
|
-
yield promptAndStoreAnswer(
|
|
406
|
+
yield promptAndStoreAnswer(questions_1.databaseAndMonitoringQuestions, existingValues);
|
|
401
407
|
const sentryDSNExists = (0, utils_1.findExistingValue)('SENTRY_DSN', 'SECRET', 'ENVIRONMENT', existingValues);
|
|
402
408
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Sentry'));
|
|
403
409
|
if (sentryDSNExists) {
|
|
404
|
-
yield promptAndStoreAnswer(
|
|
410
|
+
yield promptAndStoreAnswer(questions_1.sentryQuestions, existingValues);
|
|
405
411
|
}
|
|
406
412
|
else {
|
|
407
413
|
const { useSentry } = yield (0, prompts_1.default)([
|
|
@@ -413,13 +419,13 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
413
419
|
}
|
|
414
420
|
]);
|
|
415
421
|
if (useSentry) {
|
|
416
|
-
yield promptAndStoreAnswer(
|
|
422
|
+
yield promptAndStoreAnswer(questions_1.sentryQuestions, existingValues);
|
|
417
423
|
}
|
|
418
424
|
}
|
|
419
425
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('METABASE ADMIN'));
|
|
420
|
-
yield promptAndStoreAnswer(
|
|
426
|
+
yield promptAndStoreAnswer(questions_1.metabaseAdminQuestions, existingValues);
|
|
421
427
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('SMTP'));
|
|
422
|
-
yield promptAndStoreAnswer(
|
|
428
|
+
yield promptAndStoreAnswer(questions_1.emailQuestions, existingValues);
|
|
423
429
|
const allAnswers = ALL_ANSWERS.reduce((acc, answer) => {
|
|
424
430
|
return Object.assign(Object.assign({}, acc), answer);
|
|
425
431
|
});
|
|
@@ -556,6 +562,13 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
556
562
|
value: answerOrExisting(restoreEnvironmentName, (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
|
|
557
563
|
didExist: (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues),
|
|
558
564
|
scope: 'ENVIRONMENT'
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
type: 'VARIABLE',
|
|
568
|
+
name: 'RESTORE_HOST',
|
|
569
|
+
value: answerOrExisting(restoreHost, (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
|
|
570
|
+
didExist: (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues),
|
|
571
|
+
scope: 'ENVIRONMENT'
|
|
559
572
|
}
|
|
560
573
|
];
|
|
561
574
|
if (enableEncryption) {
|
|
@@ -590,7 +603,6 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
590
603
|
// Only update values that changed
|
|
591
604
|
(variable.type !== 'VARIABLE' ||
|
|
592
605
|
variable.value !== ((_a = variable.didExist) === null || _a === void 0 ? void 0 : _a.value)); });
|
|
593
|
-
(0, utils_1.storeSecrets)(environment, updates);
|
|
594
606
|
/*
|
|
595
607
|
* List out all updates to the variables and confirm with the user
|
|
596
608
|
*/
|
|
@@ -716,7 +728,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
716
728
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Running configuration files updates'));
|
|
717
729
|
(0, templates_1.generateInventory)(environment, {
|
|
718
730
|
kube_worker_nodes: kubeWorkerNodes,
|
|
719
|
-
kube_api_host: infrastructure.
|
|
731
|
+
kube_api_host: infrastructure.kubeApiHost || '',
|
|
720
732
|
backup_host: backupHost || '',
|
|
721
733
|
users: users
|
|
722
734
|
});
|
|
@@ -727,12 +739,14 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
727
739
|
// Hardcode like this blocks us from being generic:
|
|
728
740
|
// https://github.com/opencrvs/opencrvs-core/issues/11171
|
|
729
741
|
two_fa_enabled: environment !== 'production' ? false : true,
|
|
730
|
-
|
|
742
|
+
traefik_mode: traefikConfOption,
|
|
731
743
|
restore_enabled: restoreEnvironmentName ? true : false,
|
|
732
744
|
restore_environment_name: restoreEnvironmentName || '',
|
|
733
745
|
restore_type: restoreType,
|
|
734
|
-
|
|
735
|
-
|
|
746
|
+
restore_host: restoreHost || '',
|
|
747
|
+
backup_enabled: configureBackup ? true : false,
|
|
748
|
+
backup_type: backupType,
|
|
749
|
+
backup_host: backupHost || ''
|
|
736
750
|
});
|
|
737
751
|
let addon_message = kubeWorkerNodes.length > 0 || configureBackup
|
|
738
752
|
? '--------------------------------------------------------------------------------------------\n' +
|
|
@@ -769,6 +783,7 @@ ${addon_message}
|
|
|
769
783
|
${kleur_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')}
|
|
770
784
|
${kleur_1.default.yellow('Please KINDLY read hints above')}
|
|
771
785
|
`);
|
|
772
|
-
(0, logger_1.log)('\nAll variables
|
|
773
|
-
|
|
786
|
+
(0, logger_1.log)('\nAll secrets and variables were printed above.', kleur_1.default
|
|
787
|
+
.bold()
|
|
788
|
+
.yellow('Store them in a password manager — they are not saved to disk.'));
|
|
774
789
|
}))();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AA0BA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAepD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsBzE"}
|
|
@@ -24,7 +24,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.getUsers = getUsers;
|
|
28
27
|
exports.extractAndModifyUsers = extractAndModifyUsers;
|
|
29
28
|
exports.dockerManagerFirst = dockerManagerFirst;
|
|
30
29
|
exports.extractBackupNode = extractBackupNode;
|
|
@@ -34,18 +33,12 @@ exports.generateInventory = generateInventory;
|
|
|
34
33
|
const fs_1 = __importDefault(require("fs"));
|
|
35
34
|
const path_1 = __importDefault(require("path"));
|
|
36
35
|
const logger_1 = require("./logger");
|
|
36
|
+
const paths_1 = require("./paths");
|
|
37
37
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
38
38
|
// Register a helper to increment numbers
|
|
39
39
|
handlebars_1.default.registerHelper('data_label_idx', function (value) {
|
|
40
40
|
return parseInt(value) + 2;
|
|
41
41
|
});
|
|
42
|
-
function getUsers(data) {
|
|
43
|
-
var _a, _b;
|
|
44
|
-
if (!((_b = (_a = data === null || data === void 0 ? void 0 : data.all) === null || _a === void 0 ? void 0 : _a.vars) === null || _b === void 0 ? void 0 : _b.users)) {
|
|
45
|
-
return { users: [] };
|
|
46
|
-
}
|
|
47
|
-
return data.all.vars.users;
|
|
48
|
-
}
|
|
49
42
|
// START: TEMPORAL SECTION FOR TRANSITION FROM DOCKER SWARM TO K8s
|
|
50
43
|
// Extract users from the old inventory
|
|
51
44
|
// Docker swarm format to new
|
|
@@ -55,6 +48,9 @@ function extractAndModifyUsers(data) {
|
|
|
55
48
|
return { users: [] };
|
|
56
49
|
}
|
|
57
50
|
const users = data.all.vars.users.map((user) => {
|
|
51
|
+
if (user.role) {
|
|
52
|
+
return user;
|
|
53
|
+
}
|
|
58
54
|
const { sudoer } = user, rest = __rest(user, ["sudoer"]);
|
|
59
55
|
return Object.assign(Object.assign({}, rest), { role: sudoer ? 'admin' : 'operator' });
|
|
60
56
|
});
|
|
@@ -149,7 +145,7 @@ function copyChartsValues(env, values) {
|
|
|
149
145
|
function generateInventory(env, values) {
|
|
150
146
|
// Template and output paths
|
|
151
147
|
const templatePath = path_1.default.join(__dirname, 'templates', 'inventory', 'inventory.template.yml');
|
|
152
|
-
const outputPath = path_1.default.
|
|
148
|
+
const outputPath = path_1.default.resolve(process.cwd(), (0, paths_1.getEnvironmentInventoryPath)(env));
|
|
153
149
|
const templateFile = fs_1.default.readFileSync(templatePath, 'utf-8');
|
|
154
150
|
const template = handlebars_1.default.compile(templateFile);
|
|
155
151
|
values['single_node'] =
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-workflows.d.ts","sourceRoot":"","sources":["../../src/environment/update-workflows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update-workflows.d.ts","sourceRoot":"","sources":["../../src/environment/update-workflows.ts"],"names":[],"mappings":"AAmIA,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAgDhE"}
|