@opencrvs/toolkit 2.0.0-rc.358eace → 2.0.0-rc.3598fb7
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/ActionConfig.d.ts +7 -0
- 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/commons/events/utils.d.ts +8 -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 +69 -18
- package/dist/migrations/v2.0/index.js +10 -5
- package/dist/notification/index.js +32 -17
- 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.3598fb7.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
package/dist/cli.js
CHANGED
|
@@ -143,19 +143,19 @@ async function getPublicKey(octokit, environment, ORGANISATION, REPOSITORY_NAME)
|
|
|
143
143
|
return res.data;
|
|
144
144
|
}
|
|
145
145
|
async function createEnvironmentSecret(octokit, repositoryId, environment, name, secret, organisationName, repositoryName) {
|
|
146
|
-
await
|
|
146
|
+
await import_libsodium_wrappers.default.ready;
|
|
147
147
|
const { key, key_id } = await getPublicKey(
|
|
148
148
|
octokit,
|
|
149
149
|
environment,
|
|
150
150
|
organisationName,
|
|
151
151
|
repositoryName
|
|
152
152
|
);
|
|
153
|
-
const binkey =
|
|
154
|
-
const binsec =
|
|
155
|
-
const encBytes =
|
|
156
|
-
const encryptedValue =
|
|
153
|
+
const binkey = import_libsodium_wrappers.default.from_base64(key, import_libsodium_wrappers.default.base64_variants.ORIGINAL);
|
|
154
|
+
const binsec = import_libsodium_wrappers.default.from_string(secret);
|
|
155
|
+
const encBytes = import_libsodium_wrappers.default.crypto_box_seal(binsec, binkey);
|
|
156
|
+
const encryptedValue = import_libsodium_wrappers.default.to_base64(
|
|
157
157
|
encBytes,
|
|
158
|
-
|
|
158
|
+
import_libsodium_wrappers.default.base64_variants.ORIGINAL
|
|
159
159
|
);
|
|
160
160
|
await octokit.request(
|
|
161
161
|
`PUT /repositories/${repositoryId}/environments/${environment}/secrets/${name}`,
|
|
@@ -172,18 +172,18 @@ async function createEnvironmentSecret(octokit, repositoryId, environment, name,
|
|
|
172
172
|
);
|
|
173
173
|
}
|
|
174
174
|
async function createRepositorySecret(octokit, repositoryId, name, secret, organisationName, repositoryName) {
|
|
175
|
-
await
|
|
175
|
+
await import_libsodium_wrappers.default.ready;
|
|
176
176
|
const { key, key_id } = await getRepositoryPublicKey(
|
|
177
177
|
octokit,
|
|
178
178
|
organisationName,
|
|
179
179
|
repositoryName
|
|
180
180
|
);
|
|
181
|
-
const binkey =
|
|
182
|
-
const binsec =
|
|
183
|
-
const encBytes =
|
|
184
|
-
const encryptedValue =
|
|
181
|
+
const binkey = import_libsodium_wrappers.default.from_base64(key, import_libsodium_wrappers.default.base64_variants.ORIGINAL);
|
|
182
|
+
const binsec = import_libsodium_wrappers.default.from_string(secret);
|
|
183
|
+
const encBytes = import_libsodium_wrappers.default.crypto_box_seal(binsec, binkey);
|
|
184
|
+
const encryptedValue = import_libsodium_wrappers.default.to_base64(
|
|
185
185
|
encBytes,
|
|
186
|
-
|
|
186
|
+
import_libsodium_wrappers.default.base64_variants.ORIGINAL
|
|
187
187
|
);
|
|
188
188
|
await octokit.request(
|
|
189
189
|
`PUT /repositories/${repositoryId}/actions/secrets/${name}`,
|
|
@@ -197,10 +197,13 @@ async function createRepositorySecret(octokit, repositoryId, name, secret, organ
|
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
async function getRepositoryEnvironments(octokit, githubOrganisation, repository) {
|
|
200
|
-
const response = await octokit.request(
|
|
201
|
-
githubOrganisation,
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
const response = await octokit.request(
|
|
201
|
+
"GET /repos/{githubOrganisation}/{repository}/environments",
|
|
202
|
+
{
|
|
203
|
+
githubOrganisation,
|
|
204
|
+
repository
|
|
205
|
+
}
|
|
206
|
+
);
|
|
204
207
|
const environments = (response.data.environments ?? []).map(
|
|
205
208
|
(env) => env.name
|
|
206
209
|
);
|
|
@@ -273,7 +276,9 @@ async function listEnvironmentVariables(octokit, repositoryId, environmentName)
|
|
|
273
276
|
...variable,
|
|
274
277
|
type: "VARIABLE",
|
|
275
278
|
scope: "ENVIRONMENT"
|
|
276
|
-
})).filter(
|
|
279
|
+
})).filter(
|
|
280
|
+
(variable) => variable.name !== "ACTIONS_RUNNER_DEBUG"
|
|
281
|
+
);
|
|
277
282
|
}
|
|
278
283
|
async function listRepositoryVariables(octokit, owner, repositoryName) {
|
|
279
284
|
const response = await octokit.request(
|
|
@@ -290,12 +295,12 @@ async function listRepositoryVariables(octokit, owner, repositoryName) {
|
|
|
290
295
|
scope: "REPOSITORY"
|
|
291
296
|
}));
|
|
292
297
|
}
|
|
293
|
-
var
|
|
298
|
+
var import_libsodium_wrappers;
|
|
294
299
|
var init_github = __esm({
|
|
295
300
|
"src/environment/github.ts"() {
|
|
296
301
|
"use strict";
|
|
302
|
+
import_libsodium_wrappers = __toESM(require("libsodium-wrappers"));
|
|
297
303
|
init_logger();
|
|
298
|
-
sodium = require("libsodium-wrappers");
|
|
299
304
|
}
|
|
300
305
|
});
|
|
301
306
|
|
|
@@ -543,7 +548,9 @@ function extractAndModifyUsers(data) {
|
|
|
543
548
|
}
|
|
544
549
|
function dockerManagerFirst(data) {
|
|
545
550
|
if (!data?.["docker-manager-first"]?.hosts) {
|
|
546
|
-
throw new Error(
|
|
551
|
+
throw new Error(
|
|
552
|
+
"Invalid YAML structure: missing docker-manager-first.hosts"
|
|
553
|
+
);
|
|
547
554
|
}
|
|
548
555
|
const hosts = data["docker-manager-first"].hosts;
|
|
549
556
|
const dockerManagerFirst2 = Object.values(hosts).filter((host) => host.ansible_host).map((host) => host.ansible_host);
|
|
@@ -571,6 +578,7 @@ function copyChartsValues(env, values) {
|
|
|
571
578
|
import_fs8.default.mkdirSync(destDir, { recursive: true });
|
|
572
579
|
values["lets_encrypt"] = values["traefik_mode"] === "lets_encrypt";
|
|
573
580
|
values["static_ssl"] = values["traefik_mode"] === "static_ssl";
|
|
581
|
+
values["opencrvs_environment"] = env;
|
|
574
582
|
function copyRecursive(src, dest) {
|
|
575
583
|
const stat = import_fs8.default.statSync(src);
|
|
576
584
|
if (stat.isDirectory()) {
|
|
@@ -598,8 +606,19 @@ function copyChartsValues(env, values) {
|
|
|
598
606
|
`);
|
|
599
607
|
}
|
|
600
608
|
function generateInventory(env, values) {
|
|
601
|
-
const templatePath = import_path27.default.join(
|
|
602
|
-
|
|
609
|
+
const templatePath = import_path27.default.join(
|
|
610
|
+
__dirname,
|
|
611
|
+
"templates",
|
|
612
|
+
"inventory",
|
|
613
|
+
"inventory.template.yml"
|
|
614
|
+
);
|
|
615
|
+
const outputPath = import_path27.default.join(
|
|
616
|
+
process.cwd(),
|
|
617
|
+
"infrastructure",
|
|
618
|
+
"server-setup",
|
|
619
|
+
"inventory",
|
|
620
|
+
`${env}.yml`
|
|
621
|
+
);
|
|
603
622
|
const templateFile = import_fs8.default.readFileSync(templatePath, "utf-8");
|
|
604
623
|
const template = import_handlebars.default.compile(templateFile);
|
|
605
624
|
values["single_node"] = values["kube_worker_nodes"].length > 0 || values["backup_host"] ? "false" : "true";
|
|
@@ -626,8 +645,11 @@ var init_templates = __esm({
|
|
|
626
645
|
|
|
627
646
|
// src/environment/ssh-keygen.ts
|
|
628
647
|
function generateSSHKeyPair() {
|
|
629
|
-
|
|
630
|
-
return {
|
|
648
|
+
const keys = import_ssh2.utils.generateKeyPairSync("ed25519");
|
|
649
|
+
return {
|
|
650
|
+
publicKey: keys.public.toString(),
|
|
651
|
+
privateKey: keys.private.toString()
|
|
652
|
+
};
|
|
631
653
|
}
|
|
632
654
|
var import_ssh2;
|
|
633
655
|
var init_ssh_keygen = __esm({
|
|
@@ -1077,7 +1099,7 @@ function editorQuestion(question) {
|
|
|
1077
1099
|
);
|
|
1078
1100
|
}
|
|
1079
1101
|
async function askQuestionWithEditor(questions, existingValues) {
|
|
1080
|
-
|
|
1102
|
+
const answers = [];
|
|
1081
1103
|
for (const question of questions) {
|
|
1082
1104
|
const questionWithVariableLabel = {
|
|
1083
1105
|
...question,
|
|
@@ -1094,18 +1116,22 @@ async function askQuestionWithEditor(questions, existingValues) {
|
|
|
1094
1116
|
);
|
|
1095
1117
|
let updateSecret = true;
|
|
1096
1118
|
if (existingSecret) {
|
|
1097
|
-
updateSecret = (await (0, import_prompts.default)([
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
existingSecret.
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1119
|
+
updateSecret = (await (0, import_prompts.default)([
|
|
1120
|
+
{
|
|
1121
|
+
name: "overWrite",
|
|
1122
|
+
type: "confirm",
|
|
1123
|
+
message: `${import_kleur3.default.yellow(
|
|
1124
|
+
`${existingSecret.scope === "REPOSITORY" ? "Repository secret" : "Secret"} ${import_kleur3.default.cyan(
|
|
1125
|
+
existingSecret.name
|
|
1126
|
+
)} already exists in Github. Do you want to update it?`
|
|
1127
|
+
)}`
|
|
1128
|
+
}
|
|
1129
|
+
])).overWrite;
|
|
1106
1130
|
}
|
|
1107
1131
|
if (!existingSecret || updateSecret === true) {
|
|
1108
|
-
const question_answer = await editorQuestion(
|
|
1132
|
+
const question_answer = await editorQuestion(
|
|
1133
|
+
questionWithVariableLabel.message
|
|
1134
|
+
);
|
|
1109
1135
|
const answer = {
|
|
1110
1136
|
type: "SECRET",
|
|
1111
1137
|
scope: "ENVIRONMENT",
|
|
@@ -1296,7 +1322,9 @@ async function addNewUser(existingUsers) {
|
|
|
1296
1322
|
});
|
|
1297
1323
|
const ssh_keys = keysInput.split("\n").map((key) => key.trim()).filter((key) => key && !key.startsWith("#"));
|
|
1298
1324
|
if (ssh_keys.length === 0) {
|
|
1299
|
-
warn(
|
|
1325
|
+
warn(
|
|
1326
|
+
"\u26A0\uFE0F Warning: No SSH keys provided. User will not be able to login remotely."
|
|
1327
|
+
);
|
|
1300
1328
|
}
|
|
1301
1329
|
const role = await selectRole();
|
|
1302
1330
|
const state = "present";
|
|
@@ -1335,8 +1363,12 @@ async function editUser(user) {
|
|
|
1335
1363
|
console.log("\u2500".repeat(70));
|
|
1336
1364
|
console.log(`\u{1F4DD} Editing user: ${updatedUser.name}`);
|
|
1337
1365
|
console.log("\u2500".repeat(70));
|
|
1338
|
-
console.log(
|
|
1339
|
-
|
|
1366
|
+
console.log(
|
|
1367
|
+
`Current Role: ${updatedUser.role === "admin" ? "\u{1F451} admin" : "\u{1F464} operator"}`
|
|
1368
|
+
);
|
|
1369
|
+
console.log(
|
|
1370
|
+
`Current State: ${updatedUser.state === "present" ? "\u2705 present" : "\u274C absent"}`
|
|
1371
|
+
);
|
|
1340
1372
|
console.log(`Current SSH Keys: ${updatedUser.ssh_keys.length} key(s)`);
|
|
1341
1373
|
if (updatedUser.ssh_keys.length > 0) {
|
|
1342
1374
|
updatedUser.ssh_keys.forEach((key, idx) => {
|
|
@@ -1581,11 +1613,8 @@ async function select3(options) {
|
|
|
1581
1613
|
return inquirer.select(options);
|
|
1582
1614
|
}
|
|
1583
1615
|
function questionToPrompt({
|
|
1584
|
-
// eslint-disable-next-line no-unused-vars
|
|
1585
1616
|
valueType,
|
|
1586
|
-
// eslint-disable-next-line no-unused-vars
|
|
1587
1617
|
valueLabel,
|
|
1588
|
-
// eslint-disable-next-line no-unused-vars
|
|
1589
1618
|
scope,
|
|
1590
1619
|
...promptOptions
|
|
1591
1620
|
}) {
|
|
@@ -1609,39 +1638,42 @@ function getAnswers(existingValues) {
|
|
|
1609
1638
|
const existingQuestion = ALL_QUESTIONS.find(
|
|
1610
1639
|
(question) => question.name === key
|
|
1611
1640
|
);
|
|
1612
|
-
|
|
1641
|
+
if (!existingQuestion?.valueLabel || existingQuestion.valueType !== "SECRET" && existingQuestion.valueType !== "VARIABLE") {
|
|
1642
|
+
throw new Error(`No secret or variable question found for ${key}`);
|
|
1643
|
+
}
|
|
1644
|
+
const { valueLabel, valueType, scope } = existingQuestion;
|
|
1613
1645
|
if (valueType === "SECRET") {
|
|
1614
1646
|
const existingSecret = findExistingValue(
|
|
1615
|
-
|
|
1647
|
+
valueLabel,
|
|
1616
1648
|
"SECRET",
|
|
1617
|
-
|
|
1649
|
+
scope,
|
|
1618
1650
|
existingValues
|
|
1619
1651
|
);
|
|
1620
1652
|
return {
|
|
1621
1653
|
type: valueType,
|
|
1622
|
-
name:
|
|
1654
|
+
name: valueLabel,
|
|
1623
1655
|
value: value.toString(),
|
|
1624
1656
|
didExist: existingSecret,
|
|
1625
|
-
scope
|
|
1657
|
+
scope
|
|
1626
1658
|
};
|
|
1627
1659
|
}
|
|
1628
1660
|
const existingVariable = findExistingValue(
|
|
1629
|
-
|
|
1661
|
+
valueLabel,
|
|
1630
1662
|
valueType,
|
|
1631
|
-
|
|
1663
|
+
scope,
|
|
1632
1664
|
existingValues
|
|
1633
1665
|
);
|
|
1634
1666
|
return {
|
|
1635
1667
|
type: valueType,
|
|
1636
|
-
name:
|
|
1668
|
+
name: valueLabel,
|
|
1637
1669
|
didExist: findExistingValue(
|
|
1638
|
-
|
|
1670
|
+
valueLabel,
|
|
1639
1671
|
valueType,
|
|
1640
|
-
|
|
1672
|
+
scope,
|
|
1641
1673
|
existingValues
|
|
1642
1674
|
),
|
|
1643
1675
|
value: value.toString() || existingVariable?.value || "",
|
|
1644
|
-
scope
|
|
1676
|
+
scope
|
|
1645
1677
|
};
|
|
1646
1678
|
});
|
|
1647
1679
|
});
|
|
@@ -1666,7 +1698,10 @@ async function promptAndStoreAnswer(environment, questions, existingValues) {
|
|
|
1666
1698
|
if (existingVariable) {
|
|
1667
1699
|
let initial_value = existingVariable.value;
|
|
1668
1700
|
if (questionWithVariableLabel.type === "select" && Array.isArray(questionWithVariableLabel.choices)) {
|
|
1669
|
-
initial_value = getIndexFromChoices(
|
|
1701
|
+
initial_value = getIndexFromChoices(
|
|
1702
|
+
questionWithVariableLabel.choices,
|
|
1703
|
+
existingVariable.value
|
|
1704
|
+
);
|
|
1670
1705
|
}
|
|
1671
1706
|
return [
|
|
1672
1707
|
{
|
|
@@ -1787,8 +1822,12 @@ var init_setup_environment = __esm({
|
|
|
1787
1822
|
auth: githubToken
|
|
1788
1823
|
});
|
|
1789
1824
|
log(import_kleur4.default.green("\nSuccessfully logged in to Github\n"));
|
|
1790
|
-
|
|
1791
|
-
|
|
1825
|
+
const existingEnvironments = await getRepositoryEnvironments(
|
|
1826
|
+
octokit,
|
|
1827
|
+
githubOrganisation,
|
|
1828
|
+
githubRepository
|
|
1829
|
+
);
|
|
1830
|
+
const defaultChoices = [
|
|
1792
1831
|
{ name: "Development", value: "development" },
|
|
1793
1832
|
{ name: "Quality assurance (no PII data)", value: "qa" },
|
|
1794
1833
|
{
|
|
@@ -1802,34 +1841,34 @@ var init_setup_environment = __esm({
|
|
|
1802
1841
|
];
|
|
1803
1842
|
const choices = [
|
|
1804
1843
|
...defaultChoices,
|
|
1805
|
-
...existingEnvironments.filter(
|
|
1806
|
-
(env) => !defaultChoices.some((choice) => choice.value === env)
|
|
1807
|
-
).map((env) => ({
|
|
1844
|
+
...existingEnvironments.filter((env) => !defaultChoices.some((choice) => choice.value === env)).map((env) => ({
|
|
1808
1845
|
name: env,
|
|
1809
1846
|
value: env
|
|
1810
1847
|
}))
|
|
1811
1848
|
];
|
|
1812
|
-
const environment = await selectWithCustom(
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
}
|
|
1817
|
-
);
|
|
1849
|
+
const environment = await selectWithCustom({
|
|
1850
|
+
message: "Choose a name and purpose for the environment?",
|
|
1851
|
+
choices
|
|
1852
|
+
});
|
|
1818
1853
|
let environment_type = "non-production";
|
|
1819
1854
|
if (["development", "qa"].includes(environment)) {
|
|
1820
1855
|
environment_type = "non-production";
|
|
1821
1856
|
} else if (["staging", "production"].includes(environment)) {
|
|
1822
1857
|
environment_type = "production";
|
|
1823
1858
|
} else {
|
|
1824
|
-
environment_type = await select3(
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1859
|
+
environment_type = await select3({
|
|
1860
|
+
message: "Purpose for the environment?",
|
|
1861
|
+
choices: [
|
|
1862
|
+
{
|
|
1863
|
+
name: "Development/Quality assurance/Testing (no PII data)",
|
|
1864
|
+
value: "non-production"
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
name: "Staging/Production (hosts PII data, requires frequent backups)",
|
|
1868
|
+
value: "production"
|
|
1869
|
+
}
|
|
1870
|
+
]
|
|
1871
|
+
});
|
|
1833
1872
|
}
|
|
1834
1873
|
const environment_exists = existingEnvironments.map((e) => e.trim()).includes(environment);
|
|
1835
1874
|
if (!environment) {
|
|
@@ -1889,10 +1928,17 @@ var init_setup_environment = __esm({
|
|
|
1889
1928
|
);
|
|
1890
1929
|
}
|
|
1891
1930
|
if (environment_type === "production") {
|
|
1892
|
-
log(
|
|
1893
|
-
"
|
|
1894
|
-
|
|
1895
|
-
|
|
1931
|
+
log(
|
|
1932
|
+
"\n",
|
|
1933
|
+
import_kleur4.default.yellow().bold(
|
|
1934
|
+
"WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n"
|
|
1935
|
+
)
|
|
1936
|
+
);
|
|
1937
|
+
await promptAndStoreAnswer(
|
|
1938
|
+
environment,
|
|
1939
|
+
githubOtherQuestions,
|
|
1940
|
+
existingValues
|
|
1941
|
+
);
|
|
1896
1942
|
}
|
|
1897
1943
|
log("\n", import_kleur4.default.bold().underline("Docker Hub"));
|
|
1898
1944
|
await promptAndStoreAnswer(environment, dockerhubQuestions, existingValues);
|
|
@@ -1904,7 +1950,9 @@ var init_setup_environment = __esm({
|
|
|
1904
1950
|
);
|
|
1905
1951
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes ? infrastructure.kubeWorkerNodes.split(",").map((ip) => ip.trim()) : [];
|
|
1906
1952
|
log("\n", import_kleur4.default.bold().underline("SSH Users"), "\n");
|
|
1907
|
-
const users = await manageUsers(
|
|
1953
|
+
const users = await manageUsers(
|
|
1954
|
+
`infrastructure/server-setup/inventory/${environment}.yml`
|
|
1955
|
+
);
|
|
1908
1956
|
log("\n", import_kleur4.default.bold().underline("Traefik SSL Certificate"), "\n");
|
|
1909
1957
|
const sslCertExists = findExistingValue(
|
|
1910
1958
|
"SSL_CRT",
|
|
@@ -1913,23 +1961,24 @@ var init_setup_environment = __esm({
|
|
|
1913
1961
|
existingValues
|
|
1914
1962
|
);
|
|
1915
1963
|
let ssl_answers = [];
|
|
1916
|
-
const traefikConfOption = (await (0, import_prompts2.default)(
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
]
|
|
1930
|
-
)).traefikConfOption;
|
|
1964
|
+
const traefikConfOption = (await (0, import_prompts2.default)([
|
|
1965
|
+
{
|
|
1966
|
+
name: "traefikConfOption",
|
|
1967
|
+
type: "select",
|
|
1968
|
+
message: "Choose option to configure Traefik SSL Certificate",
|
|
1969
|
+
choices: [
|
|
1970
|
+
{ title: "Let's Encrypt certificate", value: "lets_encrypt" },
|
|
1971
|
+
{ title: "Static SSL certificate", value: "static_ssl" },
|
|
1972
|
+
{ title: "Custom configuration", value: "custom" }
|
|
1973
|
+
],
|
|
1974
|
+
initial: sslCertExists ? 1 : 0
|
|
1975
|
+
}
|
|
1976
|
+
])).traefikConfOption;
|
|
1931
1977
|
if (traefikConfOption === "static_ssl") {
|
|
1932
|
-
ssl_answers = await askQuestionWithEditor(
|
|
1978
|
+
ssl_answers = await askQuestionWithEditor(
|
|
1979
|
+
staticSSLCertQuestions,
|
|
1980
|
+
existingEnvironmentSecrets
|
|
1981
|
+
);
|
|
1933
1982
|
}
|
|
1934
1983
|
log("\n", import_kleur4.default.bold().underline("Storage"), "\n");
|
|
1935
1984
|
let enableEncryption = false;
|
|
@@ -1954,11 +2003,19 @@ var init_setup_environment = __esm({
|
|
|
1954
2003
|
enableEncryption = answers_enable_encryption.enableEncryption;
|
|
1955
2004
|
}
|
|
1956
2005
|
if (enableEncryption && !encryption_key_defined && !environment_exists) {
|
|
1957
|
-
log(
|
|
2006
|
+
log(
|
|
2007
|
+
import_kleur4.default.bold().green("\u2714"),
|
|
2008
|
+
import_kleur4.default.bold().yellow(" Disk encryption is enabled")
|
|
2009
|
+
);
|
|
1958
2010
|
await promptAndStoreAnswer(environment, diskQuestions, existingValues);
|
|
1959
2011
|
} else {
|
|
1960
2012
|
if (!enableEncryption && !encryption_key_defined && environment_exists) {
|
|
1961
|
-
log(
|
|
2013
|
+
log(
|
|
2014
|
+
import_kleur4.default.bold().green("\u2714"),
|
|
2015
|
+
import_kleur4.default.bold().grey(
|
|
2016
|
+
`Environment ${environment} is already configured, skipping disk encryption question`
|
|
2017
|
+
)
|
|
2018
|
+
);
|
|
1962
2019
|
}
|
|
1963
2020
|
const DISK_SPACE = findExistingValue(
|
|
1964
2021
|
"DISK_SPACE",
|
|
@@ -1967,17 +2024,19 @@ var init_setup_environment = __esm({
|
|
|
1967
2024
|
existingValues
|
|
1968
2025
|
);
|
|
1969
2026
|
if (!DISK_SPACE) {
|
|
1970
|
-
log(
|
|
2027
|
+
log(
|
|
2028
|
+
import_kleur4.default.bold().green("\u2714"),
|
|
2029
|
+
import_kleur4.default.bold().grey("All available disk space at /data will be used")
|
|
2030
|
+
);
|
|
1971
2031
|
} else {
|
|
1972
|
-
log(
|
|
2032
|
+
log(
|
|
2033
|
+
import_kleur4.default.bold().green("\u2714"),
|
|
2034
|
+
import_kleur4.default.bold().yellow("Variable DISK_SPACE is read-only, allocated space:"),
|
|
2035
|
+
DISK_SPACE?.value
|
|
2036
|
+
);
|
|
1973
2037
|
}
|
|
1974
2038
|
}
|
|
1975
|
-
let backupHost = findExistingValue(
|
|
1976
|
-
"BACKUP_HOST",
|
|
1977
|
-
"VARIABLE",
|
|
1978
|
-
"ENVIRONMENT",
|
|
1979
|
-
existingValues
|
|
1980
|
-
)?.value || "";
|
|
2039
|
+
let backupHost = findExistingValue("BACKUP_HOST", "VARIABLE", "ENVIRONMENT", existingValues)?.value || "";
|
|
1981
2040
|
let backupType = "";
|
|
1982
2041
|
let restoreEnvironmentName = findExistingValue(
|
|
1983
2042
|
"RESTORE_ENVIRONMENT_NAME",
|
|
@@ -2007,7 +2066,7 @@ var init_setup_environment = __esm({
|
|
|
2007
2066
|
backupQuestions,
|
|
2008
2067
|
existingValues
|
|
2009
2068
|
);
|
|
2010
|
-
|
|
2069
|
+
const backupHostPrivateKeyExists = findExistingValue(
|
|
2011
2070
|
"BACKUP_HOST_PRIVATE_KEY",
|
|
2012
2071
|
"SECRET",
|
|
2013
2072
|
"ENVIRONMENT",
|
|
@@ -2019,7 +2078,10 @@ var init_setup_environment = __esm({
|
|
|
2019
2078
|
const { publicKey, privateKey } = generateSSHKeyPair();
|
|
2020
2079
|
backupHostPublicKey = publicKey;
|
|
2021
2080
|
backupHostPrivateKey = privateKey;
|
|
2022
|
-
log(
|
|
2081
|
+
log(
|
|
2082
|
+
import_kleur4.default.bold().green("\u2714"),
|
|
2083
|
+
import_kleur4.default.bold().yellow(`Generated new SSH key pair for backup host: ${backupHost}`)
|
|
2084
|
+
);
|
|
2023
2085
|
}
|
|
2024
2086
|
} else {
|
|
2025
2087
|
log(import_kleur4.default.bold().green("\u2714"), import_kleur4.default.bold().yellow("Backup is disabled"));
|
|
@@ -2033,32 +2095,30 @@ var init_setup_environment = __esm({
|
|
|
2033
2095
|
});
|
|
2034
2096
|
}
|
|
2035
2097
|
if (configureRestore) {
|
|
2036
|
-
const env_list_filtered = existingEnvironments.filter(
|
|
2037
|
-
|
|
2038
|
-
{
|
|
2039
|
-
message: "What is the name of your environment to restore?",
|
|
2040
|
-
choices: env_list_filtered.map((env) => ({
|
|
2041
|
-
name: env,
|
|
2042
|
-
value: env
|
|
2043
|
-
})),
|
|
2044
|
-
initial: restoreEnvironmentName
|
|
2045
|
-
}
|
|
2046
|
-
);
|
|
2047
|
-
restoreType = await select3(
|
|
2048
|
-
{
|
|
2049
|
-
message: `Select ${import_kleur4.default.yellow().bold(restoreEnvironmentName)} environment backup mode`,
|
|
2050
|
-
choices: [
|
|
2051
|
-
{
|
|
2052
|
-
name: "Full dump (daily full database backup)",
|
|
2053
|
-
value: "dump"
|
|
2054
|
-
},
|
|
2055
|
-
{
|
|
2056
|
-
name: "Differential (weekly full, daily diff backup)",
|
|
2057
|
-
value: "differential"
|
|
2058
|
-
}
|
|
2059
|
-
]
|
|
2060
|
-
}
|
|
2098
|
+
const env_list_filtered = existingEnvironments.filter(
|
|
2099
|
+
(env) => env !== environment
|
|
2061
2100
|
);
|
|
2101
|
+
restoreEnvironmentName = await selectWithCustom({
|
|
2102
|
+
message: "What is the name of your environment to restore?",
|
|
2103
|
+
choices: env_list_filtered.map((env) => ({
|
|
2104
|
+
name: env,
|
|
2105
|
+
value: env
|
|
2106
|
+
})),
|
|
2107
|
+
initial: restoreEnvironmentName
|
|
2108
|
+
});
|
|
2109
|
+
restoreType = await select3({
|
|
2110
|
+
message: `Select ${import_kleur4.default.yellow().bold(restoreEnvironmentName)} environment backup mode`,
|
|
2111
|
+
choices: [
|
|
2112
|
+
{
|
|
2113
|
+
name: "Full dump (daily full database backup)",
|
|
2114
|
+
value: "dump"
|
|
2115
|
+
},
|
|
2116
|
+
{
|
|
2117
|
+
name: "Differential (weekly full, daily diff backup)",
|
|
2118
|
+
value: "differential"
|
|
2119
|
+
}
|
|
2120
|
+
]
|
|
2121
|
+
});
|
|
2062
2122
|
} else {
|
|
2063
2123
|
log(import_kleur4.default.bold().green("\u2714"), import_kleur4.default.bold().yellow("Restore is disabled"));
|
|
2064
2124
|
}
|
|
@@ -2078,16 +2138,14 @@ var init_setup_environment = __esm({
|
|
|
2078
2138
|
if (sentryDSNExists) {
|
|
2079
2139
|
await promptAndStoreAnswer(environment, sentryQuestions, existingValues);
|
|
2080
2140
|
} else {
|
|
2081
|
-
const { useSentry } = await (0, import_prompts2.default)(
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
]
|
|
2090
|
-
);
|
|
2141
|
+
const { useSentry } = await (0, import_prompts2.default)([
|
|
2142
|
+
{
|
|
2143
|
+
name: "useSentry",
|
|
2144
|
+
type: "confirm",
|
|
2145
|
+
message: "Do you want to use Sentry?",
|
|
2146
|
+
initial: Boolean(process.env.SENTRY_DNS)
|
|
2147
|
+
}
|
|
2148
|
+
]);
|
|
2091
2149
|
if (useSentry) {
|
|
2092
2150
|
await promptAndStoreAnswer(environment, sentryQuestions, existingValues);
|
|
2093
2151
|
}
|
|
@@ -2412,12 +2470,16 @@ var init_setup_environment = __esm({
|
|
|
2412
2470
|
{
|
|
2413
2471
|
type: "VARIABLE",
|
|
2414
2472
|
name: "RESTORE_ENVIRONMENT_NAME",
|
|
2415
|
-
value: answerOrExisting(
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2473
|
+
value: answerOrExisting(
|
|
2474
|
+
restoreEnvironmentName,
|
|
2475
|
+
findExistingValue(
|
|
2476
|
+
"RESTORE_ENVIRONMENT_NAME",
|
|
2477
|
+
"VARIABLE",
|
|
2478
|
+
"ENVIRONMENT",
|
|
2479
|
+
existingValues
|
|
2480
|
+
),
|
|
2481
|
+
(val) => val || ""
|
|
2482
|
+
),
|
|
2421
2483
|
didExist: findExistingValue(
|
|
2422
2484
|
"RESTORE_ENVIRONMENT_NAME",
|
|
2423
2485
|
"VARIABLE",
|
|
@@ -2674,32 +2736,26 @@ var init_setup_environment = __esm({
|
|
|
2674
2736
|
)
|
|
2675
2737
|
);
|
|
2676
2738
|
log("\n", import_kleur4.default.bold().underline("Running configuration files updates"));
|
|
2677
|
-
generateInventory(
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
restore_environment_name: restoreEnvironmentName || "",
|
|
2698
|
-
restore_type: restoreType,
|
|
2699
|
-
traefik_mode: traefikConfOption,
|
|
2700
|
-
backup_type: backupType
|
|
2701
|
-
}
|
|
2702
|
-
);
|
|
2739
|
+
generateInventory(environment, {
|
|
2740
|
+
kube_worker_nodes: kubeWorkerNodes,
|
|
2741
|
+
kube_api_host: infrastructure.kubeAPIHost || "",
|
|
2742
|
+
backup_host: backupHost || "",
|
|
2743
|
+
users
|
|
2744
|
+
});
|
|
2745
|
+
copyChartsValues(environment, {
|
|
2746
|
+
env: environment,
|
|
2747
|
+
environment_type,
|
|
2748
|
+
// FIXME: In general that should be environment_type,
|
|
2749
|
+
// Hardcode like this blocks us from being generic:
|
|
2750
|
+
// https://github.com/opencrvs/opencrvs-core/issues/11171
|
|
2751
|
+
two_fa_enabled: environment !== "production" ? false : true,
|
|
2752
|
+
backup_enabled: configureBackup ? true : false,
|
|
2753
|
+
restore_enabled: restoreEnvironmentName ? true : false,
|
|
2754
|
+
restore_environment_name: restoreEnvironmentName || "",
|
|
2755
|
+
restore_type: restoreType,
|
|
2756
|
+
traefik_mode: traefikConfOption,
|
|
2757
|
+
backup_type: backupType
|
|
2758
|
+
});
|
|
2703
2759
|
let addon_message = kubeWorkerNodes.length > 0 || configureBackup ? `--------------------------------------------------------------------------------------------
|
|
2704
2760
|
|
|
2705
2761
|
\u27A1\uFE0F ${import_kleur4.default.bold().yellow("COPY the SSH public key from the master VM to your clipboard")}
|
|
@@ -2747,7 +2803,9 @@ async function extractInfrastructureNames() {
|
|
|
2747
2803
|
const files = glob.sync("infrastructure/server-setup/inventory/*.yml");
|
|
2748
2804
|
const infraEnvironments = files.map((file) => (0, import_path28.basename)(file, ".yml"));
|
|
2749
2805
|
if (infraEnvironments.length === 0) {
|
|
2750
|
-
console.log(
|
|
2806
|
+
console.log(
|
|
2807
|
+
"\u26A0\uFE0F Warning: No environment directories found in infrastructure/server-setup/inventory/"
|
|
2808
|
+
);
|
|
2751
2809
|
return [];
|
|
2752
2810
|
}
|
|
2753
2811
|
log("\u{1F50D} Found infrastructure configurations:", infraEnvironments.join(", "));
|
|
@@ -2760,7 +2818,9 @@ async function extractEnvironmentNames() {
|
|
|
2760
2818
|
return (0, import_fs9.statSync)(fullPath).isDirectory();
|
|
2761
2819
|
});
|
|
2762
2820
|
if (environments.length === 0) {
|
|
2763
|
-
console.log(
|
|
2821
|
+
console.log(
|
|
2822
|
+
"\u26A0\uFE0F Warning: No environment directories found in environments/"
|
|
2823
|
+
);
|
|
2764
2824
|
return [];
|
|
2765
2825
|
}
|
|
2766
2826
|
log("\u{1F50D} Found OpenCRVS configurations:", environments.join(", "));
|
|
@@ -2784,14 +2844,18 @@ async function updateWorkflows(envList, config) {
|
|
|
2784
2844
|
const fileContents = (0, import_fs9.readFileSync)(workflowPath, "utf8");
|
|
2785
2845
|
const workflowData = yaml2.load(fileContents);
|
|
2786
2846
|
if (!workflowData?.on?.workflow_dispatch?.inputs?.environment?.options) {
|
|
2787
|
-
throw new Error(
|
|
2847
|
+
throw new Error(
|
|
2848
|
+
"Workflow does not have the expected structure: on.workflow_dispatch.inputs.environment.options"
|
|
2849
|
+
);
|
|
2788
2850
|
}
|
|
2789
2851
|
const updatedContent = updateOptionsInYaml(fileContents, envList);
|
|
2790
2852
|
(0, import_fs9.writeFileSync)(workflowPath, updatedContent, "utf8");
|
|
2791
2853
|
log(` \u2713 Successfully updated ${workflowPath}`);
|
|
2792
2854
|
} catch (error4) {
|
|
2793
|
-
console.error(
|
|
2794
|
-
|
|
2855
|
+
console.error(
|
|
2856
|
+
`
|
|
2857
|
+
\u26A0\uFE0F Error updating ${workflowPath} with environments: [${envList.join(", ")}]`
|
|
2858
|
+
);
|
|
2795
2859
|
console.error(`\u2717 Failed to update ${workflowPath}:`, error4);
|
|
2796
2860
|
throw error4;
|
|
2797
2861
|
}
|
|
@@ -2854,13 +2918,20 @@ var init_update_workflows = __esm({
|
|
|
2854
2918
|
|
|
2855
2919
|
// src/environment/users.ts
|
|
2856
2920
|
var users_exports = {};
|
|
2921
|
+
__export(users_exports, {
|
|
2922
|
+
manageEnvironmentUsers: () => manageEnvironmentUsers
|
|
2923
|
+
});
|
|
2857
2924
|
async function select4(options) {
|
|
2858
2925
|
const inquirer = await import("@inquirer/prompts");
|
|
2859
2926
|
return inquirer.select(options);
|
|
2860
2927
|
}
|
|
2861
2928
|
async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inventory/") {
|
|
2862
2929
|
if (!fs8.existsSync(dirPath)) {
|
|
2863
|
-
|
|
2930
|
+
warn(`\u26A0\uFE0F No environment configuration directory found at ${dirPath}`);
|
|
2931
|
+
warn(
|
|
2932
|
+
"Hint: If this is a new infrastructure repository, run `opencrvs environment init` first."
|
|
2933
|
+
);
|
|
2934
|
+
return null;
|
|
2864
2935
|
}
|
|
2865
2936
|
const files = fs8.readdirSync(dirPath).filter((file) => {
|
|
2866
2937
|
const filePath = path26.join(dirPath, file);
|
|
@@ -2869,7 +2940,11 @@ async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inve
|
|
|
2869
2940
|
return isFile && (ext === "yml" || ext === "yaml");
|
|
2870
2941
|
}).sort();
|
|
2871
2942
|
if (files.length === 0) {
|
|
2872
|
-
|
|
2943
|
+
warn(`\u26A0\uFE0F No environment configuration files found at ${dirPath}`);
|
|
2944
|
+
warn(
|
|
2945
|
+
"Hint: If this is a new infrastructure repository, run `opencrvs environment init` first."
|
|
2946
|
+
);
|
|
2947
|
+
return null;
|
|
2873
2948
|
}
|
|
2874
2949
|
const choices = files.map((file) => ({
|
|
2875
2950
|
name: path26.basename(file, path26.extname(file)),
|
|
@@ -2881,10 +2956,13 @@ async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inve
|
|
|
2881
2956
|
});
|
|
2882
2957
|
return selectedFile;
|
|
2883
2958
|
}
|
|
2884
|
-
async function
|
|
2959
|
+
async function manageEnvironmentUsers() {
|
|
2885
2960
|
console.log("\n", import_kleur5.default.bold().underline("Manage users"), "\n");
|
|
2886
2961
|
const inventory_file = await selectInventoryFile();
|
|
2887
|
-
|
|
2962
|
+
if (!inventory_file) {
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
await manageUsers(inventory_file);
|
|
2888
2966
|
}
|
|
2889
2967
|
var fs8, path26, import_kleur5;
|
|
2890
2968
|
var init_users = __esm({
|
|
@@ -2894,7 +2972,7 @@ var init_users = __esm({
|
|
|
2894
2972
|
path26 = __toESM(require("path"));
|
|
2895
2973
|
import_kleur5 = __toESM(require("kleur"));
|
|
2896
2974
|
init_manage_users();
|
|
2897
|
-
|
|
2975
|
+
init_logger();
|
|
2898
2976
|
}
|
|
2899
2977
|
});
|
|
2900
2978
|
|
|
@@ -2913,9 +2991,11 @@ var init_swarm_to_k8s = __esm({
|
|
|
2913
2991
|
init_ssh_keygen();
|
|
2914
2992
|
init_github();
|
|
2915
2993
|
(async () => {
|
|
2916
|
-
log(
|
|
2917
|
-
|
|
2918
|
-
|
|
2994
|
+
log(
|
|
2995
|
+
import_kleur6.default.bold(
|
|
2996
|
+
"------------------------------------------------\nOpenCRVS Infrastructure migration script: \nMigrating Swarm configurations to Kubernetes\n------------------------------------------------\n"
|
|
2997
|
+
)
|
|
2998
|
+
);
|
|
2919
2999
|
const environment_type = process.env.ENVIRONMENT_TYPE || "production";
|
|
2920
3000
|
const environment = process.env.ENVIRONMENT || "";
|
|
2921
3001
|
const githubToken = process.env.INFRA_TOKEN || "";
|
|
@@ -2938,7 +3018,9 @@ var init_swarm_to_k8s = __esm({
|
|
|
2938
3018
|
process.exit(1);
|
|
2939
3019
|
}
|
|
2940
3020
|
if (["backup", "jumpbox"].includes(environment)) {
|
|
2941
|
-
info(
|
|
3021
|
+
info(
|
|
3022
|
+
` > ${environment} environment will not be migrated, see migration notes`
|
|
3023
|
+
);
|
|
2942
3024
|
process.exit(0);
|
|
2943
3025
|
}
|
|
2944
3026
|
log(import_kleur6.default.bold().underline("Migration properties:"));
|
|
@@ -2946,7 +3028,10 @@ var init_swarm_to_k8s = __esm({
|
|
|
2946
3028
|
const old_inventory_path = process.env.OLD_INVENTORY_PATH || "";
|
|
2947
3029
|
if (!old_inventory_path) {
|
|
2948
3030
|
error("\n", "Environment variable OLD_INVENTORY_PATH is not set. Exiting.");
|
|
2949
|
-
log(
|
|
3031
|
+
log(
|
|
3032
|
+
"\n",
|
|
3033
|
+
"Old inventory path is required to read existing Swarm configurations."
|
|
3034
|
+
);
|
|
2950
3035
|
process.exit(1);
|
|
2951
3036
|
}
|
|
2952
3037
|
const ansible_inventory = path27.join(old_inventory_path, environment + ".yml");
|
|
@@ -2959,32 +3044,26 @@ var init_swarm_to_k8s = __esm({
|
|
|
2959
3044
|
log(` \u2713 Worker nodes: ${kube_worker_nodes.join(", ")}`);
|
|
2960
3045
|
const backup_host = extractBackupNode(data);
|
|
2961
3046
|
log(` \u2713 Backup host: ${backup_host}`);
|
|
2962
|
-
generateInventory(
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
restore_environment_name: environment === "staging" ? "production" : "",
|
|
2983
|
-
restore_type: "dump",
|
|
2984
|
-
traefik_mode: "static_ssl",
|
|
2985
|
-
backup_type: "dump"
|
|
2986
|
-
}
|
|
2987
|
-
);
|
|
3047
|
+
generateInventory(environment, {
|
|
3048
|
+
kube_worker_nodes,
|
|
3049
|
+
users,
|
|
3050
|
+
backup_host: environment === "production" ? backup_host : "",
|
|
3051
|
+
kube_api_host: master
|
|
3052
|
+
});
|
|
3053
|
+
copyChartsValues(environment, {
|
|
3054
|
+
env: environment,
|
|
3055
|
+
environment_type,
|
|
3056
|
+
// FIXME: In general that should be environment_type,
|
|
3057
|
+
// Hardcode like this blocks us from being generic:
|
|
3058
|
+
// https://github.com/opencrvs/opencrvs-core/issues/11171
|
|
3059
|
+
two_fa_enabled: environment !== "production" ? false : true,
|
|
3060
|
+
backup_enabled: environment === "production" ? "true" : "false",
|
|
3061
|
+
restore_enabled: environment === "staging" ? "true" : "false",
|
|
3062
|
+
restore_environment_name: environment === "staging" ? "production" : "",
|
|
3063
|
+
restore_type: "dump",
|
|
3064
|
+
traefik_mode: "static_ssl",
|
|
3065
|
+
backup_type: "dump"
|
|
3066
|
+
});
|
|
2988
3067
|
if (environment === "staging") {
|
|
2989
3068
|
const octokit = new import_core2.Octokit({
|
|
2990
3069
|
auth: githubToken
|
|
@@ -3003,14 +3082,21 @@ var init_swarm_to_k8s = __esm({
|
|
|
3003
3082
|
"production"
|
|
3004
3083
|
);
|
|
3005
3084
|
} catch (err) {
|
|
3006
|
-
error(
|
|
3085
|
+
error(
|
|
3086
|
+
`Failed to create variable RESTORE_ENVIRONMENT_NAME for environment ${environment}:`,
|
|
3087
|
+
err
|
|
3088
|
+
);
|
|
3007
3089
|
}
|
|
3008
3090
|
}
|
|
3009
3091
|
if (environment === "production") {
|
|
3010
3092
|
const octokit = new import_core2.Octokit({
|
|
3011
3093
|
auth: githubToken
|
|
3012
3094
|
});
|
|
3013
|
-
console.log(
|
|
3095
|
+
console.log(
|
|
3096
|
+
"Fetching repository ID for:",
|
|
3097
|
+
githubOrganisation,
|
|
3098
|
+
githubRepository
|
|
3099
|
+
);
|
|
3014
3100
|
const repositoryId = await getRepositoryId(
|
|
3015
3101
|
octokit,
|
|
3016
3102
|
githubOrganisation,
|
|
@@ -3040,10 +3126,15 @@ var init_swarm_to_k8s = __esm({
|
|
|
3040
3126
|
);
|
|
3041
3127
|
log(` \u2713 Created secret ${secretName} for environment ${environment}`);
|
|
3042
3128
|
} catch (err) {
|
|
3043
|
-
error(
|
|
3129
|
+
error(
|
|
3130
|
+
`Failed to create secret ${secretName} for environment ${environment}:`,
|
|
3131
|
+
err
|
|
3132
|
+
);
|
|
3044
3133
|
}
|
|
3045
3134
|
}
|
|
3046
|
-
for (const [variableName, variableValue] of Object.entries(
|
|
3135
|
+
for (const [variableName, variableValue] of Object.entries(
|
|
3136
|
+
variablesToCreate
|
|
3137
|
+
)) {
|
|
3047
3138
|
try {
|
|
3048
3139
|
await createEnvironmentVariable(
|
|
3049
3140
|
octokit,
|
|
@@ -3052,9 +3143,14 @@ var init_swarm_to_k8s = __esm({
|
|
|
3052
3143
|
variableName,
|
|
3053
3144
|
variableValue
|
|
3054
3145
|
);
|
|
3055
|
-
log(
|
|
3146
|
+
log(
|
|
3147
|
+
` \u2713 Created variable ${variableName} for environment ${environment}`
|
|
3148
|
+
);
|
|
3056
3149
|
} catch (err) {
|
|
3057
|
-
error(
|
|
3150
|
+
error(
|
|
3151
|
+
`Failed to create variable ${variableName} for environment ${environment}:`,
|
|
3152
|
+
err
|
|
3153
|
+
);
|
|
3058
3154
|
}
|
|
3059
3155
|
}
|
|
3060
3156
|
}
|
|
@@ -5231,11 +5327,13 @@ var scopeOptionsPlaceEvent = z3.object({
|
|
|
5231
5327
|
event: scopeByEvent,
|
|
5232
5328
|
placeOfEvent: JurisdictionFilter.optional()
|
|
5233
5329
|
}).describe("Options applicable to all record scopes.");
|
|
5234
|
-
var
|
|
5330
|
+
var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
|
|
5331
|
+
notifiedIn: JurisdictionFilter.optional(),
|
|
5332
|
+
notifiedBy: UserFilter.optional(),
|
|
5235
5333
|
declaredIn: JurisdictionFilter.optional(),
|
|
5236
5334
|
declaredBy: UserFilter.optional()
|
|
5237
5335
|
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
5238
|
-
var AllRecordScopeOptions =
|
|
5336
|
+
var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
|
|
5239
5337
|
registeredIn: JurisdictionFilter.optional(),
|
|
5240
5338
|
registeredBy: UserFilter.optional()
|
|
5241
5339
|
}).describe(
|
|
@@ -5273,6 +5371,8 @@ var ResolvedScopeOptionsPlaceEvent = z3.object({
|
|
|
5273
5371
|
"Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
|
|
5274
5372
|
);
|
|
5275
5373
|
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
5374
|
+
notifiedIn: UUID.nullish(),
|
|
5375
|
+
notifiedBy: z3.string().optional(),
|
|
5276
5376
|
declaredIn: UUID.nullish(),
|
|
5277
5377
|
declaredBy: z3.string().optional()
|
|
5278
5378
|
}).describe(
|
|
@@ -5318,7 +5418,7 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
5318
5418
|
}),
|
|
5319
5419
|
z3.object({
|
|
5320
5420
|
type: ScopesWithDeclaredOptions,
|
|
5321
|
-
options:
|
|
5421
|
+
options: scopeOptionsDeclaredOrNotified.optional()
|
|
5322
5422
|
}),
|
|
5323
5423
|
z3.object({
|
|
5324
5424
|
type: ScopesWithFullOptions,
|
|
@@ -5439,8 +5539,9 @@ var decodeScope = (encodedScope) => {
|
|
|
5439
5539
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
5440
5540
|
placeOfEvent: JurisdictionFilter.enum.all,
|
|
5441
5541
|
accessLevel: JurisdictionFilter.enum.all,
|
|
5442
|
-
|
|
5443
|
-
declaredIn: JurisdictionFilter.enum.all
|
|
5542
|
+
notifiedIn: JurisdictionFilter.enum.all,
|
|
5543
|
+
declaredIn: JurisdictionFilter.enum.all,
|
|
5544
|
+
registeredIn: JurisdictionFilter.enum.all
|
|
5444
5545
|
};
|
|
5445
5546
|
|
|
5446
5547
|
// ../commons/src/scopes.deprecated.do-not-use.ts
|
|
@@ -8215,7 +8316,8 @@ async function runEnvironmentUpdateWorkflows() {
|
|
|
8215
8316
|
}
|
|
8216
8317
|
async function runEnvironmentUsers() {
|
|
8217
8318
|
validateRepositoryStructure();
|
|
8218
|
-
await Promise.resolve().then(() => (init_users(), users_exports));
|
|
8319
|
+
const { manageEnvironmentUsers: manageEnvironmentUsers2 } = await Promise.resolve().then(() => (init_users(), users_exports));
|
|
8320
|
+
await manageEnvironmentUsers2();
|
|
8219
8321
|
}
|
|
8220
8322
|
async function runEnvironmentSwarmToK8s() {
|
|
8221
8323
|
validateRepositoryStructure();
|