@opencrvs/toolkit 2.2.0-rc.045257f → 2.2.0-rc.19ec10b
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/build.sh +7 -2
- package/dist/application-config/index.js +16 -5
- package/dist/authentication/index.d.ts +1 -1
- package/dist/authentication/index.js +4 -8
- package/dist/cli.js +927 -356
- package/dist/commons/api/router.d.ts +17 -4
- package/dist/commons/application-config/index.d.ts +1 -1
- package/dist/commons/conditionals/conditionals.d.ts +55 -4
- package/dist/commons/conditionals/validate.d.ts +1 -1
- package/dist/commons/events/ActionStatus.d.ts +2 -2
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -0
- package/dist/commons/events/Draft.d.ts +34 -1
- package/dist/commons/events/EventConfig.d.ts +446 -0
- package/dist/commons/events/EventDocument.d.ts +2 -0
- package/dist/commons/events/EventIndex.d.ts +1 -0
- package/dist/commons/events/EventInput.d.ts +1 -0
- package/dist/commons/events/EventMetadata.d.ts +1 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
- package/dist/commons/events/PlainDate.d.ts +5 -0
- package/dist/commons/events/defineConfig.d.ts +7 -2
- package/dist/commons/events/event.d.ts +20 -1
- package/dist/commons/events/field.d.ts +37 -0
- package/dist/commons/events/locations.d.ts +1 -1
- package/dist/commons/events/scopes.d.ts +2 -1
- package/dist/commons/events/state/index.d.ts +1 -0
- package/dist/commons/events/test.utils.d.ts +59 -6
- package/dist/commons/events/utils.d.ts +28 -2
- package/dist/commons/users/Role.d.ts +23 -0
- package/dist/commons/users/User.d.ts +263 -0
- package/dist/commons/users/authentication.d.ts +67 -0
- package/dist/commons/users/index.d.ts +5 -0
- package/dist/commons/users/roleValidations.d.ts +15 -0
- package/dist/commons/users/scopes.d.ts +1402 -0
- package/dist/commons/users/userReferences.d.ts +176 -0
- package/dist/conditionals/index.js +13 -5
- package/dist/environment/custom-types.d.ts +1 -0
- package/dist/environment/custom-types.d.ts.map +1 -1
- package/dist/environment/derived-variables.d.ts +8 -0
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +9 -0
- package/dist/environment/questions.d.ts +42 -9
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +70 -47
- package/dist/environment/registry.d.ts +15 -0
- package/dist/environment/registry.d.ts.map +1 -0
- package/dist/environment/registry.js +112 -0
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +104 -23
- package/dist/events/index.js +1627 -1100
- package/dist/migrations/add-notify-config.d.ts +40 -0
- package/dist/migrations/add-notify-config.d.ts.map +1 -0
- package/dist/migrations/add-notify-config.js +249 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +602 -143
- package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -1
- package/dist/migrations/move-declaration-to-declare-action.js +27 -144
- package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -1
- package/dist/migrations/read-declaration-through-helper.js +3 -61
- package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
- package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
- package/dist/migrations/resolve-versioned-event-config.js +353 -0
- package/dist/migrations/utils.d.ts +61 -0
- package/dist/migrations/utils.d.ts.map +1 -0
- package/dist/migrations/utils.js +218 -0
- package/dist/notification/index.js +707 -119
- package/dist/roles/index.d.ts +2 -0
- package/dist/roles/index.d.ts.map +1 -0
- package/dist/roles/index.js +730 -0
- package/dist/scopes/index.d.ts +0 -10
- package/dist/scopes/index.js +3 -7
- package/dist/templates/charts-values/dependencies/values.yaml +5 -2
- package/dist/templates/charts-values/opencrvs-services/values.yaml +2 -5
- package/dist/verify/endpoints.d.ts +11 -0
- package/dist/verify/endpoints.d.ts.map +1 -1
- package/dist/verify/endpoints.js +21 -27
- package/opencrvs-toolkit-2.2.0-rc.19ec10b.tgz +0 -0
- package/package.json +4 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +3 -5
- package/dist/environment/dockerhub.d.ts +0 -15
- package/dist/environment/dockerhub.d.ts.map +0 -1
- package/dist/environment/dockerhub.js +0 -104
- package/opencrvs-toolkit-2.2.0-rc.045257f.tgz +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.validateRegistryCredentials = validateRegistryCredentials;
|
|
23
|
+
const REQUEST_TIMEOUT_MS = 10000;
|
|
24
|
+
// Docker Hub serves its registry API from registry-1.docker.io, docker.io is the website
|
|
25
|
+
function registryApiHost(registry) {
|
|
26
|
+
const host = registry.trim().toLowerCase();
|
|
27
|
+
return host === 'docker.io' || host === 'index.docker.io'
|
|
28
|
+
? 'registry-1.docker.io'
|
|
29
|
+
: host;
|
|
30
|
+
}
|
|
31
|
+
function request(url, authorization) {
|
|
32
|
+
return fetch(url, {
|
|
33
|
+
headers: authorization ? { Authorization: authorization } : {},
|
|
34
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function failure(registry, step, response) {
|
|
38
|
+
const reason = `${registry} ${step} responded with HTTP ${response.status}`;
|
|
39
|
+
switch (response.status) {
|
|
40
|
+
case 401:
|
|
41
|
+
case 403:
|
|
42
|
+
return {
|
|
43
|
+
status: 'invalid-credentials',
|
|
44
|
+
reason: `${reason}. Check REGISTRY_USERNAME, REGISTRY_TOKEN, REGISTRY_ORGANISATION and REGISTRY_REPOSITORY`
|
|
45
|
+
};
|
|
46
|
+
case 404:
|
|
47
|
+
// The API cannot tell an empty repository from one that does not exist
|
|
48
|
+
return {
|
|
49
|
+
status: 'repository-not-found',
|
|
50
|
+
reason: `${reason}. This is also the answer for an empty repository. Check REGISTRY_ORGANISATION and REGISTRY_REPOSITORY`
|
|
51
|
+
};
|
|
52
|
+
default:
|
|
53
|
+
return { status: 'unreachable', reason };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks, using the OCI Distribution (Docker Registry HTTP API v2) that every
|
|
58
|
+
* registry implements, that the username/token pair is accepted by the registry
|
|
59
|
+
* and that the organisation/repository is visible to that account.
|
|
60
|
+
*
|
|
61
|
+
* Existing GitHub secrets cannot be read back, so when any value is missing
|
|
62
|
+
* (kept from an existing secret) the check is skipped.
|
|
63
|
+
*/
|
|
64
|
+
function validateRegistryCredentials(registry, organisation, repository, username, token) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
var _c, _d;
|
|
68
|
+
if (!registry || !organisation || !repository || !username || !token) {
|
|
69
|
+
return {
|
|
70
|
+
status: 'skipped',
|
|
71
|
+
reason: 'Some values are kept from existing GitHub secrets, which cannot be read back'
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const host = registryApiHost(registry);
|
|
75
|
+
const name = `${organisation}/${repository}`;
|
|
76
|
+
const basic = `Basic ${Buffer.from(`${username}:${token}`).toString('base64')}`;
|
|
77
|
+
try {
|
|
78
|
+
// A registry that wants a token names its token service in the challenge.
|
|
79
|
+
// For any other answer the credentials are sent as they are.
|
|
80
|
+
const challenge = (_c = (yield request(`https://${host}/v2/`, undefined)).headers.get('www-authenticate')) !== null && _c !== void 0 ? _c : '';
|
|
81
|
+
const realm = (_a = challenge.match(/realm="([^"]*)"/i)) === null || _a === void 0 ? void 0 : _a[1];
|
|
82
|
+
const service = (_b = challenge.match(/service="([^"]*)"/i)) === null || _b === void 0 ? void 0 : _b[1];
|
|
83
|
+
let authorization = basic;
|
|
84
|
+
if (/^\s*bearer/i.test(challenge) && realm) {
|
|
85
|
+
const tokenUrl = new URL(realm);
|
|
86
|
+
if (service) {
|
|
87
|
+
tokenUrl.searchParams.set('service', service);
|
|
88
|
+
}
|
|
89
|
+
tokenUrl.searchParams.set('scope', `repository:${name}:pull`);
|
|
90
|
+
const login = yield request(tokenUrl, basic);
|
|
91
|
+
if (!login.ok) {
|
|
92
|
+
return failure(registry, 'login', login);
|
|
93
|
+
}
|
|
94
|
+
const body = (yield login.json());
|
|
95
|
+
authorization = `Bearer ${(_d = body.token) !== null && _d !== void 0 ? _d : body.access_token}`;
|
|
96
|
+
}
|
|
97
|
+
const path = name.split('/').map(encodeURIComponent).join('/');
|
|
98
|
+
const response = yield request(`https://${host}/v2/${path}/tags/list?n=1`, authorization);
|
|
99
|
+
return response.ok
|
|
100
|
+
? { status: 'valid' }
|
|
101
|
+
: failure(registry, `lookup of repository ${name}`, response);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
if (!(err instanceof Error)) {
|
|
105
|
+
return { status: 'unreachable', reason: String(err) };
|
|
106
|
+
}
|
|
107
|
+
// fetch only reports "fetch failed", the real error (e.g. ENOTFOUND) is its cause
|
|
108
|
+
const cause = err.cause instanceof Error ? `: ${err.cause.message}` : '';
|
|
109
|
+
return { status: 'unreachable', reason: `${err.message}${cause}` };
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":"AA8aA,wBAAsB,mBAAmB,kBA0sCxC"}
|
|
@@ -65,11 +65,11 @@ const update_workflows_1 = require("./update-workflows");
|
|
|
65
65
|
const questions_1 = require("./questions");
|
|
66
66
|
const editor_questions_1 = require("./editor-questions");
|
|
67
67
|
const questions_helper_1 = require("./questions-helper");
|
|
68
|
-
const
|
|
68
|
+
const registry_1 = require("./registry");
|
|
69
69
|
const manage_users_1 = require("./manage-users");
|
|
70
70
|
const paths_1 = require("./paths");
|
|
71
71
|
function questionToPrompt(_a) {
|
|
72
|
-
var { valueType, valueLabel, scope } = _a, promptOptions = __rest(_a, ["valueType", "valueLabel", "scope"]);
|
|
72
|
+
var { valueType, valueLabel, legacyValueLabel, scope } = _a, promptOptions = __rest(_a, ["valueType", "valueLabel", "legacyValueLabel", "scope"]);
|
|
73
73
|
return promptOptions;
|
|
74
74
|
}
|
|
75
75
|
const ALL_QUESTIONS = [];
|
|
@@ -113,6 +113,14 @@ function getAnswers(existingValues) {
|
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
|
+
// The value of a variable that exists, as the initial value of its question.
|
|
117
|
+
// A select question takes the index of the choice.
|
|
118
|
+
function getInitialValue(question, variable) {
|
|
119
|
+
if (question.type === 'select' && Array.isArray(question.choices)) {
|
|
120
|
+
return (0, questions_helper_1.getIndexFromChoices)(question.choices, variable.value);
|
|
121
|
+
}
|
|
122
|
+
return variable.value;
|
|
123
|
+
}
|
|
116
124
|
function promptAndStoreAnswer(questions, existingValues) {
|
|
117
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
126
|
(0, logger_1.log)('');
|
|
@@ -123,13 +131,15 @@ function promptAndStoreAnswer(questions, existingValues) {
|
|
|
123
131
|
}
|
|
124
132
|
if (questionWithVariableLabel.valueType === 'VARIABLE') {
|
|
125
133
|
const existingVariable = (0, utils_1.findExistingValue)(questionWithVariableLabel.valueLabel, 'VARIABLE', questionWithVariableLabel.scope, existingValues);
|
|
134
|
+
// Unlike a secret, the value of a variable can be read, so one that only exists
|
|
135
|
+
// under its previous name is the default of the question
|
|
136
|
+
const legacyVariable = !existingVariable && questionWithVariableLabel.legacyValueLabel
|
|
137
|
+
? (0, utils_1.findExistingValue)(questionWithVariableLabel.legacyValueLabel, 'VARIABLE', questionWithVariableLabel.scope, existingValues)
|
|
138
|
+
: undefined;
|
|
139
|
+
if (legacyVariable) {
|
|
140
|
+
return Object.assign(Object.assign({}, questionWithVariableLabel), { message: `${questionWithVariableLabel.message} ${kleur_1.default.gray(`(default taken from ${legacyVariable.name}, the previous name of this variable)`)}`, initial: getInitialValue(questionWithVariableLabel, legacyVariable) });
|
|
141
|
+
}
|
|
126
142
|
if (existingVariable) {
|
|
127
|
-
let initial_value = existingVariable.value;
|
|
128
|
-
// Get correct initial value for select questions
|
|
129
|
-
if (questionWithVariableLabel.type === 'select' &&
|
|
130
|
-
Array.isArray(questionWithVariableLabel.choices)) {
|
|
131
|
-
initial_value = (0, questions_helper_1.getIndexFromChoices)(questionWithVariableLabel.choices, existingVariable.value);
|
|
132
|
-
}
|
|
133
143
|
return [
|
|
134
144
|
{
|
|
135
145
|
name: 'overWrite' + questionWithVariableLabel.name,
|
|
@@ -137,12 +147,30 @@ function promptAndStoreAnswer(questions, existingValues) {
|
|
|
137
147
|
scope: questionWithVariableLabel.scope,
|
|
138
148
|
message: `${kleur_1.default.yellow(`Variable ${kleur_1.default.cyan(existingVariable.name)} already exists in Github. Do you want to update it?`)}`
|
|
139
149
|
},
|
|
140
|
-
Object.assign(Object.assign({}, questionWithVariableLabel), { type: ((prev) => prev ? questionWithVariableLabel.type : null), initial:
|
|
150
|
+
Object.assign(Object.assign({}, questionWithVariableLabel), { type: ((prev) => prev ? questionWithVariableLabel.type : null), initial: getInitialValue(questionWithVariableLabel, existingVariable) })
|
|
141
151
|
];
|
|
142
152
|
}
|
|
143
153
|
}
|
|
144
154
|
if (questionWithVariableLabel.valueType === 'SECRET') {
|
|
145
155
|
const existingSecret = (0, utils_1.findExistingValue)(questionWithVariableLabel.valueLabel, 'SECRET', questionWithVariableLabel.scope, existingValues);
|
|
156
|
+
// The value of a secret that only exists under its previous name can't be read, so
|
|
157
|
+
// it is left to the secrets migration workflow, unless a new value is entered here
|
|
158
|
+
const legacySecret = !existingSecret && questionWithVariableLabel.legacyValueLabel
|
|
159
|
+
? (0, utils_1.findExistingValue)(questionWithVariableLabel.legacyValueLabel, 'SECRET', questionWithVariableLabel.scope, existingValues)
|
|
160
|
+
: undefined;
|
|
161
|
+
if (legacySecret) {
|
|
162
|
+
return [
|
|
163
|
+
{
|
|
164
|
+
name: 'overWrite' + questionWithVariableLabel.name,
|
|
165
|
+
type: 'confirm',
|
|
166
|
+
scope: questionWithVariableLabel.scope,
|
|
167
|
+
message: `${kleur_1.default.yellow(`${legacySecret.scope === 'REPOSITORY'
|
|
168
|
+
? 'Repository secret'
|
|
169
|
+
: 'Secret'} ${kleur_1.default.cyan(legacySecret.name)} already exists in Github under the previous name of ${kleur_1.default.cyan(questionWithVariableLabel.valueLabel)}. The secrets migration workflow copies it. Do you want to enter a new value instead?`)}`
|
|
170
|
+
},
|
|
171
|
+
Object.assign(Object.assign({}, questionWithVariableLabel), { type: ((prev) => prev ? questionWithVariableLabel.type : null) })
|
|
172
|
+
];
|
|
173
|
+
}
|
|
146
174
|
if (existingSecret) {
|
|
147
175
|
return [
|
|
148
176
|
{
|
|
@@ -176,16 +204,39 @@ function promptAndStoreAnswer(questions, existingValues) {
|
|
|
176
204
|
return Object.assign(Object.assign({}, Object.fromEntries(existingValuesForQuestions)), result);
|
|
177
205
|
});
|
|
178
206
|
}
|
|
179
|
-
|
|
207
|
+
/**
|
|
208
|
+
* The value of a secret or variable that is generated rather than asked for, or
|
|
209
|
+
* null when it exists. One that only exists under its previous name counts as
|
|
210
|
+
* existing: the secrets migration workflow copies it, and a generated value
|
|
211
|
+
* would replace the credential that is in use.
|
|
212
|
+
*/
|
|
213
|
+
function defineIfMissing(existingValues, name, type, scope, newValue) {
|
|
214
|
+
var _a;
|
|
215
|
+
if ((0, utils_1.findExistingValue)(name, type, scope, existingValues)) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
const legacyName = (_a = ALL_QUESTIONS.find((question) => question.valueLabel === name &&
|
|
219
|
+
question.valueType === type &&
|
|
220
|
+
question.scope === scope)) === null || _a === void 0 ? void 0 : _a.legacyValueLabel;
|
|
221
|
+
if (legacyName &&
|
|
222
|
+
(0, utils_1.findExistingValue)(legacyName, type, scope, existingValues)) {
|
|
223
|
+
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default
|
|
224
|
+
.bold()
|
|
225
|
+
.yellow(`${legacyName} exists, the secrets migration workflow copies it to ${name}`));
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
return process.env[name] || newValue;
|
|
229
|
+
}
|
|
230
|
+
function promptAndValidateRegistry(existingValues) {
|
|
180
231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
const answers = yield promptAndStoreAnswer(questions_1.
|
|
182
|
-
const result = yield (0,
|
|
232
|
+
const answers = yield promptAndStoreAnswer(questions_1.registryQuestions, existingValues);
|
|
233
|
+
const result = yield (0, registry_1.validateRegistryCredentials)(answers.registryHost, answers.registryOrganisation, answers.registryRepository, answers.registryUsername, answers.registryToken);
|
|
183
234
|
if (result.status === 'valid' || result.status === 'skipped') {
|
|
184
235
|
return;
|
|
185
236
|
}
|
|
186
237
|
(0, logger_1.error)(`\n${result.status}: ${result.reason || 'Generic error'}\n`);
|
|
187
238
|
const continueNotValidated = yield confirm({
|
|
188
|
-
message: '
|
|
239
|
+
message: 'Container registry credentials are not validated. Continue anyway?',
|
|
189
240
|
default: false
|
|
190
241
|
});
|
|
191
242
|
if (!continueNotValidated) {
|
|
@@ -193,7 +244,7 @@ function promptAndValidateDockerhub(existingValues) {
|
|
|
193
244
|
}
|
|
194
245
|
});
|
|
195
246
|
}
|
|
196
|
-
ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOtherQuestions, ...questions_1.
|
|
247
|
+
ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOtherQuestions, ...questions_1.registryQuestions, ...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);
|
|
197
248
|
function runSetupEnvironment() {
|
|
198
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
250
|
var _a, _b, _c, _d;
|
|
@@ -283,7 +334,15 @@ function runSetupEnvironment() {
|
|
|
283
334
|
(0, logger_1.log)('\n', kleur_1.default
|
|
284
335
|
.yellow()
|
|
285
336
|
.bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
|
|
286
|
-
|
|
337
|
+
}
|
|
338
|
+
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Workflow approvals'));
|
|
339
|
+
// The workflows require approval unless APPROVAL_REQUIRED is 'false'
|
|
340
|
+
const { approvalRequired } = yield promptAndStoreAnswer([
|
|
341
|
+
Object.assign(Object.assign({}, questions_1.githubApprovalRequiredQuestion), { initial: (0, questions_helper_1.getIndexFromChoices)(questions_1.githubApprovalRequiredQuestion.choices, process.env.APPROVAL_REQUIRED ||
|
|
342
|
+
(environment_type === 'production' ? 'true' : 'false')) })
|
|
343
|
+
], existingValues);
|
|
344
|
+
if (approvalRequired !== 'false') {
|
|
345
|
+
yield promptAndStoreAnswer([questions_1.githubApproversQuestion], existingValues);
|
|
287
346
|
}
|
|
288
347
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Two-factor authentication (2FA)'));
|
|
289
348
|
const existingTwoFaEnabled = (0, utils_1.findExistingValue)('TWO_FA_ENABLED', 'VARIABLE', 'ENVIRONMENT', existingValues);
|
|
@@ -297,8 +356,8 @@ function runSetupEnvironment() {
|
|
|
297
356
|
if (!two_fa_enabled && ['production', 'staging'].includes(environment_type)) {
|
|
298
357
|
(0, logger_1.warn)('2FA is disabled on a production-like environment. Logins will accept the fixed test code 000000, exposing real citizen data. Only do this if you know what you are doing.');
|
|
299
358
|
}
|
|
300
|
-
(0, logger_1.log)('\n', kleur_1.default.bold().underline('
|
|
301
|
-
yield
|
|
359
|
+
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Container registry'));
|
|
360
|
+
yield promptAndValidateRegistry(existingValues);
|
|
302
361
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
|
|
303
362
|
const infrastructure = yield promptAndStoreAnswer(questions_1.infrastructureQuestions, existingValues);
|
|
304
363
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes
|
|
@@ -360,6 +419,20 @@ function runSetupEnvironment() {
|
|
|
360
419
|
.yellow('Variable DISK_SPACE is read-only, allocated space:'), DISK_SPACE === null || DISK_SPACE === void 0 ? void 0 : DISK_SPACE.value);
|
|
361
420
|
}
|
|
362
421
|
}
|
|
422
|
+
// Where RustFS keeps its data. A new environment starts on RustFS in
|
|
423
|
+
// /data/rustfs. An environment that already exists ran MinIO, so RustFS takes over
|
|
424
|
+
// /data/minio in place. The directory is not renamed, because the running MinIO
|
|
425
|
+
// would lose it before the deployment replaces it. The value is decided once and
|
|
426
|
+
// read back on the next run, otherwise an environment created on RustFS would
|
|
427
|
+
// look like an existing one from then on.
|
|
428
|
+
const existingRustfsHostDataPath = (0, utils_1.findExistingValue)('RUSTFS_HOST_DATA_PATH', 'VARIABLE', 'ENVIRONMENT', existingValues);
|
|
429
|
+
const rustfs_host_data_path = (existingRustfsHostDataPath === null || existingRustfsHostDataPath === void 0 ? void 0 : existingRustfsHostDataPath.value) ||
|
|
430
|
+
(environment_exists ? '/data/minio' : '/data/rustfs');
|
|
431
|
+
// The PVC that RustFS uses follows the same decision. The name `minio` makes RustFS
|
|
432
|
+
// take over the PVC of MinIO, so it does not depend on the storage type.
|
|
433
|
+
const rustfs_pvc_name = rustfs_host_data_path.endsWith('/minio')
|
|
434
|
+
? 'minio'
|
|
435
|
+
: 'rustfs';
|
|
363
436
|
// Backup and restore configuration
|
|
364
437
|
let backupHost = ((_a = (0, utils_1.findExistingValue)('BACKUP_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _a === void 0 ? void 0 : _a.value) || '';
|
|
365
438
|
let backupType = '';
|
|
@@ -478,11 +551,7 @@ function runSetupEnvironment() {
|
|
|
478
551
|
* Variables the user doesn't need to set manually
|
|
479
552
|
*/
|
|
480
553
|
const answerOrExisting = (variable, existingValue, fn) => fn(variable || (existingValue === null || existingValue === void 0 ? void 0 : existingValue.value)) || '';
|
|
481
|
-
|
|
482
|
-
return (0, utils_1.findExistingValue)(name, type, scope, existingValues)
|
|
483
|
-
? null
|
|
484
|
-
: process.env[name] || newValue;
|
|
485
|
-
}
|
|
554
|
+
const findExistingOrDefine = (name, type, scope, newValue) => defineIfMissing(existingValues, name, type, scope, newValue);
|
|
486
555
|
const derivedUpdates = [
|
|
487
556
|
{
|
|
488
557
|
name: 'GH_ENCRYPTION_PASSWORD',
|
|
@@ -516,6 +585,15 @@ function runSetupEnvironment() {
|
|
|
516
585
|
value: monitoring_enabled ? 'true' : 'false',
|
|
517
586
|
scope: 'ENVIRONMENT'
|
|
518
587
|
});
|
|
588
|
+
// Read back on the next run, to keep the volume of MinIO for an environment
|
|
589
|
+
// that migrated
|
|
590
|
+
derivedUpdates.push({
|
|
591
|
+
name: 'RUSTFS_HOST_DATA_PATH',
|
|
592
|
+
type: 'VARIABLE',
|
|
593
|
+
didExist: existingRustfsHostDataPath,
|
|
594
|
+
value: rustfs_host_data_path,
|
|
595
|
+
scope: 'ENVIRONMENT'
|
|
596
|
+
});
|
|
519
597
|
derivedUpdates.push(...ssl_answers);
|
|
520
598
|
if (configureBackup) {
|
|
521
599
|
derivedUpdates.push({
|
|
@@ -681,7 +759,8 @@ function runSetupEnvironment() {
|
|
|
681
759
|
const newVariables = updates.filter((update) => update.type === 'VARIABLE' && !update.didExist);
|
|
682
760
|
const updatedVariables = updates.filter((update) => update.type === 'VARIABLE' && Boolean(update.didExist));
|
|
683
761
|
const unknownVariables = existingValues.filter((value) => {
|
|
684
|
-
return !ALL_QUESTIONS.find((question) => question.valueLabel === value.name
|
|
762
|
+
return !ALL_QUESTIONS.find((question) => (question.valueLabel === value.name ||
|
|
763
|
+
question.legacyValueLabel === value.name) &&
|
|
685
764
|
question.valueType === value.type &&
|
|
686
765
|
question.scope === value.scope);
|
|
687
766
|
});
|
|
@@ -811,6 +890,8 @@ function runSetupEnvironment() {
|
|
|
811
890
|
environment_type: environment_type,
|
|
812
891
|
two_fa_enabled,
|
|
813
892
|
monitoring_enabled,
|
|
893
|
+
rustfs_host_data_path,
|
|
894
|
+
rustfs_pvc_name,
|
|
814
895
|
traefik_mode: traefikConfOption,
|
|
815
896
|
restore_enabled: restoreEnvironmentName ? true : false,
|
|
816
897
|
restore_environment_name: restoreEnvironmentName || '',
|