@opencrvs/toolkit 2.1.2 → 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 +9 -14
- package/create-countryconfig/package.json +1 -1
- package/dist/application-config/index.js +57 -14
- package/dist/authentication/index.d.ts +2 -1
- package/dist/authentication/index.js +34 -14
- package/dist/cli.js +1491 -2020
- package/dist/commons/api/router.d.ts +1564 -248
- package/dist/commons/application-config/index.d.ts +3 -3
- package/dist/commons/conditionals/conditionals.d.ts +58 -7
- package/dist/commons/conditionals/index.d.ts +1 -0
- package/dist/commons/conditionals/validate.d.ts +6 -1
- package/dist/commons/events/ActionConfig.d.ts +146 -20
- package/dist/commons/events/ActionDocument.d.ts +89 -0
- package/dist/commons/events/ActionInput.d.ts +56 -4
- package/dist/commons/events/ActionStatus.d.ts +2 -2
- package/dist/commons/events/ActionType.d.ts +13 -1
- package/dist/commons/events/AdvancedSearchConfig.d.ts +15 -0
- package/dist/commons/events/AuditLog.d.ts +4 -0
- package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
- package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
- package/dist/commons/events/Draft.d.ts +36 -1
- package/dist/commons/events/EventConfig.d.ts +473 -6
- package/dist/commons/events/EventDocument.d.ts +90 -0
- package/dist/commons/events/EventIndex.d.ts +44 -6
- package/dist/commons/events/EventInput.d.ts +1 -0
- package/dist/commons/events/EventMetadata.d.ts +24 -1
- package/dist/commons/events/EventStatus.d.ts +1 -0
- package/dist/commons/events/FieldConfig.d.ts +11 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +17 -17
- package/dist/commons/events/Flag.d.ts +1 -7
- package/dist/commons/events/PlainDate.d.ts +6 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +224 -33
- package/dist/commons/events/defineConfig.d.ts +7 -2
- package/dist/commons/events/event.d.ts +20 -1
- package/dist/commons/events/eventConfigValidation.d.ts +26 -1
- package/dist/commons/events/field.d.ts +37 -0
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/locations.d.ts +1 -1
- package/dist/commons/events/scopes.d.ts +4 -1
- package/dist/commons/events/state/flags.d.ts +1 -1
- package/dist/commons/events/state/index.d.ts +11 -2
- package/dist/commons/events/state/utils.d.ts +11 -1
- package/dist/commons/events/test.utils.d.ts +89 -7
- package/dist/commons/events/toNotificationForm.d.ts +17 -0
- package/dist/commons/events/utils.d.ts +90 -10
- 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 +29 -9
- 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 +24 -4
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +27 -4
- package/dist/environment/questions.d.ts +42 -9
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +71 -48
- 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 +165 -35
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/events/index.js +2050 -1156
- 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 +9 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +1306 -0
- package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
- package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
- package/dist/migrations/move-declaration-to-declare-action.js +260 -0
- package/dist/migrations/{v2.1 → persistent}/add-translations.d.ts +7 -1
- package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
- package/dist/migrations/{v2.1 → persistent}/add-translations.js +14 -12
- package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
- package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
- package/dist/migrations/persistent/check-upgrade-path.js +105 -0
- package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
- package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
- package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
- package/dist/migrations/read-declaration-through-helper.d.ts +39 -0
- package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
- package/dist/migrations/read-declaration-through-helper.js +199 -0
- package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
- package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
- package/dist/migrations/replace-incomplete-flag.js +126 -0
- 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 +1081 -209
- 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 +83 -100
- package/dist/scopes/index.js +29 -13
- package/dist/templates/charts-values/dependencies/values.yaml +6 -3
- package/dist/templates/charts-values/opencrvs-services/values.yaml +5 -10
- package/dist/templates/charts-values/traefik/values.yaml +4 -3
- 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 +5 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +3 -5
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
- package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
- package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
- package/dist/migrations/v2.1/enable-telemetry.js +0 -455
- package/dist/migrations/v2.1/index.d.ts +0 -6
- package/dist/migrations/v2.1/index.d.ts.map +0 -1
- package/dist/migrations/v2.1/index.js +0 -2170
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -14
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
- package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
- package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
- package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
- package/dist/migrations/v2.1/remove-sentry.js +0 -354
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
- package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
- package/dist/migrations/v2.1/template-files.d.ts +0 -8
- package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
- package/dist/migrations/v2.1/template-files.js +0 -49
- package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -8
- package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
- package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
- package/dist/templates/countryconfig-template/.tiltignore +0 -1
- package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
- package/dist/templates/countryconfig-template/Tiltfile +0 -112
- package/dist/templates/countryconfig-template/assets/README.md +0 -1
- package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
- package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
- package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
- package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
- package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
- package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
- package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
- package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
- package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
- package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
- package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
- package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
- package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
- package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
- package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
- package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
- package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
- package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
- package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
- package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
- package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
- package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
- package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
- package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
- package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
- package/opencrvs-toolkit-2.1.2.tgz +0 -0
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.metabaseAdminQuestions = exports.sentryQuestions = exports.emailQuestions = exports.databaseAndMonitoringQuestions = exports.diskQuestions = exports.backupQuestions = exports.staticSSLCertQuestions = exports.infrastructureQuestions = exports.countryQuestions = exports.githubTokenQuestion = exports.githubOtherQuestions = exports.githubQuestions = exports.
|
|
16
|
+
exports.metabaseAdminQuestions = exports.sentryQuestions = exports.emailQuestions = exports.databaseAndMonitoringQuestions = exports.diskQuestions = exports.backupQuestions = exports.staticSSLCertQuestions = exports.infrastructureQuestions = exports.countryQuestions = exports.githubTokenQuestion = exports.githubOtherQuestions = exports.githubApproversQuestion = exports.githubApprovalRequiredQuestion = exports.githubQuestions = exports.registryQuestions = void 0;
|
|
17
17
|
const kleur_1 = __importDefault(require("kleur"));
|
|
18
18
|
const utils_1 = require("./utils");
|
|
19
19
|
const git_1 = require("./git");
|
|
@@ -40,45 +40,66 @@ function validateCIDRs(input) {
|
|
|
40
40
|
}
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
// A host with an optional port, without protocol or path (e.g. docker.io, ghcr.io, registry.example.org:5000)
|
|
44
|
+
function validateRegistryHost(input) {
|
|
45
|
+
return /^[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[0-9]+)?$/i.test(input)
|
|
46
|
+
? true
|
|
47
|
+
: 'Please enter a registry host without protocol or path (e.g. docker.io, ghcr.io)';
|
|
48
|
+
}
|
|
49
|
+
// The DOCKER_* and DOCKERHUB_* secrets are the previous names of the REGISTRY_* secrets
|
|
50
|
+
exports.registryQuestions = [
|
|
44
51
|
{
|
|
45
|
-
name: '
|
|
52
|
+
name: 'registryHost',
|
|
46
53
|
type: 'text',
|
|
47
|
-
message: 'What is the
|
|
54
|
+
message: 'What is the host of your container registry? (e.g. docker.io, ghcr.io)',
|
|
55
|
+
valueType: 'VARIABLE',
|
|
56
|
+
valueLabel: 'REGISTRY_HOST',
|
|
57
|
+
validate: validateRegistryHost,
|
|
58
|
+
initial: process.env.REGISTRY_HOST || 'docker.io',
|
|
59
|
+
scope: 'REPOSITORY'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'registryOrganisation',
|
|
63
|
+
type: 'text',
|
|
64
|
+
message: 'What is the name of your organisation (or user) in the container registry?',
|
|
48
65
|
valueType: 'SECRET',
|
|
49
|
-
valueLabel: '
|
|
66
|
+
valueLabel: 'REGISTRY_ORGANISATION',
|
|
67
|
+
legacyValueLabel: 'DOCKERHUB_ACCOUNT',
|
|
50
68
|
validate: notEmpty,
|
|
51
|
-
initial: process.env.
|
|
69
|
+
initial: process.env.REGISTRY_ORGANISATION,
|
|
52
70
|
scope: 'REPOSITORY'
|
|
53
71
|
},
|
|
54
72
|
{
|
|
55
|
-
name: '
|
|
73
|
+
name: 'registryRepository',
|
|
56
74
|
type: 'text',
|
|
57
|
-
message: 'What is the name of your private
|
|
75
|
+
message: 'What is the name of your private container repository?',
|
|
58
76
|
valueType: 'SECRET',
|
|
59
|
-
valueLabel: '
|
|
77
|
+
valueLabel: 'REGISTRY_REPOSITORY',
|
|
78
|
+
legacyValueLabel: 'DOCKERHUB_REPO',
|
|
60
79
|
validate: notEmpty,
|
|
61
|
-
initial: process.env.
|
|
80
|
+
initial: process.env.REGISTRY_REPOSITORY,
|
|
62
81
|
scope: 'REPOSITORY'
|
|
63
82
|
},
|
|
64
83
|
{
|
|
65
|
-
name: '
|
|
84
|
+
name: 'registryUsername',
|
|
66
85
|
type: 'text',
|
|
67
|
-
message: 'What is the
|
|
86
|
+
message: 'What is the container registry username the target server should be using?',
|
|
68
87
|
valueType: 'SECRET',
|
|
69
|
-
valueLabel: '
|
|
88
|
+
valueLabel: 'REGISTRY_USERNAME',
|
|
89
|
+
legacyValueLabel: 'DOCKER_USERNAME',
|
|
70
90
|
validate: notEmpty,
|
|
71
|
-
initial: process.env.
|
|
91
|
+
initial: process.env.REGISTRY_USERNAME,
|
|
72
92
|
scope: 'REPOSITORY'
|
|
73
93
|
},
|
|
74
94
|
{
|
|
75
|
-
name: '
|
|
95
|
+
name: 'registryToken',
|
|
76
96
|
type: 'text',
|
|
77
|
-
message: 'What is the token of this
|
|
97
|
+
message: 'What is the token of this container registry account?',
|
|
78
98
|
valueType: 'SECRET',
|
|
79
|
-
valueLabel: '
|
|
99
|
+
valueLabel: 'REGISTRY_TOKEN',
|
|
100
|
+
legacyValueLabel: 'DOCKER_TOKEN',
|
|
80
101
|
validate: notEmpty,
|
|
81
|
-
initial: process.env.
|
|
102
|
+
initial: process.env.REGISTRY_TOKEN,
|
|
82
103
|
scope: 'REPOSITORY'
|
|
83
104
|
}
|
|
84
105
|
];
|
|
@@ -100,36 +121,38 @@ exports.githubQuestions = [
|
|
|
100
121
|
scope: 'REPOSITORY'
|
|
101
122
|
}
|
|
102
123
|
];
|
|
124
|
+
exports.githubApprovalRequiredQuestion = {
|
|
125
|
+
name: 'approvalRequired',
|
|
126
|
+
type: 'select',
|
|
127
|
+
message: 'Would you like to enable approvals process for GitHub action workflows?',
|
|
128
|
+
choices: [
|
|
129
|
+
{
|
|
130
|
+
title: 'True',
|
|
131
|
+
value: 'true'
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
title: 'False',
|
|
135
|
+
value: 'false'
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
valueType: 'VARIABLE',
|
|
139
|
+
validate: notEmpty,
|
|
140
|
+
valueLabel: 'APPROVAL_REQUIRED',
|
|
141
|
+
initial: process.env.APPROVAL_REQUIRED,
|
|
142
|
+
scope: 'ENVIRONMENT'
|
|
143
|
+
};
|
|
144
|
+
exports.githubApproversQuestion = {
|
|
145
|
+
name: 'githubApprovers',
|
|
146
|
+
type: 'text',
|
|
147
|
+
message: 'Please provide/update list of approvers?',
|
|
148
|
+
initial: process.env.GH_APPROVERS,
|
|
149
|
+
valueType: 'VARIABLE',
|
|
150
|
+
valueLabel: 'GH_APPROVERS',
|
|
151
|
+
scope: 'REPOSITORY'
|
|
152
|
+
};
|
|
103
153
|
exports.githubOtherQuestions = [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
type: 'text',
|
|
107
|
-
message: 'Please provide/update list of production approvers?',
|
|
108
|
-
initial: process.env.GH_APPROVERS,
|
|
109
|
-
valueType: 'VARIABLE',
|
|
110
|
-
valueLabel: 'GH_APPROVERS',
|
|
111
|
-
scope: 'REPOSITORY'
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: 'approvalRequired',
|
|
115
|
-
type: 'select',
|
|
116
|
-
message: 'Would you like to enable approvals process for GitHub action workflows?',
|
|
117
|
-
choices: [
|
|
118
|
-
{
|
|
119
|
-
title: 'True',
|
|
120
|
-
value: 'true'
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
title: 'False',
|
|
124
|
-
value: 'false'
|
|
125
|
-
}
|
|
126
|
-
],
|
|
127
|
-
valueType: 'VARIABLE',
|
|
128
|
-
validate: notEmpty,
|
|
129
|
-
valueLabel: 'APPROVAL_REQUIRED',
|
|
130
|
-
initial: process.env.APPROVAL_REQUIRED,
|
|
131
|
-
scope: 'ENVIRONMENT'
|
|
132
|
-
}
|
|
154
|
+
exports.githubApprovalRequiredQuestion,
|
|
155
|
+
exports.githubApproversQuestion
|
|
133
156
|
];
|
|
134
157
|
exports.githubTokenQuestion = [
|
|
135
158
|
{
|
|
@@ -201,7 +224,7 @@ exports.infrastructureQuestions = [
|
|
|
201
224
|
valueLabel: 'KUBE_API_ALLOWED_CIDRS',
|
|
202
225
|
initial: process.env.KUBE_API_ALLOWED_CIDRS || '',
|
|
203
226
|
scope: 'ENVIRONMENT'
|
|
204
|
-
}
|
|
227
|
+
}
|
|
205
228
|
];
|
|
206
229
|
exports.staticSSLCertQuestions = [
|
|
207
230
|
{
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type RegistryValidationResult = {
|
|
2
|
+
status: 'valid' | 'skipped' | 'invalid-credentials' | 'repository-not-found' | 'unreachable';
|
|
3
|
+
reason?: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Checks, using the OCI Distribution (Docker Registry HTTP API v2) that every
|
|
7
|
+
* registry implements, that the username/token pair is accepted by the registry
|
|
8
|
+
* and that the organisation/repository is visible to that account.
|
|
9
|
+
*
|
|
10
|
+
* Existing GitHub secrets cannot be read back, so when any value is missing
|
|
11
|
+
* (kept from an existing secret) the check is skipped.
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateRegistryCredentials(registry: string | undefined, organisation: string | undefined, repository: string | undefined, username: string | undefined, token: string | undefined): Promise<RegistryValidationResult>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/environment/registry.ts"],"names":[],"mappings":"AAaA,KAAK,wBAAwB,GAAG;IAC9B,MAAM,EACF,OAAO,GAEP,SAAS,GACT,qBAAqB,GACrB,sBAAsB,GAEtB,aAAa,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAyCD;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,OAAO,CAAC,wBAAwB,CAAC,CA0DnC"}
|
|
@@ -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,10 +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 registry_1 = require("./registry");
|
|
68
69
|
const manage_users_1 = require("./manage-users");
|
|
69
70
|
const paths_1 = require("./paths");
|
|
70
71
|
function questionToPrompt(_a) {
|
|
71
|
-
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"]);
|
|
72
73
|
return promptOptions;
|
|
73
74
|
}
|
|
74
75
|
const ALL_QUESTIONS = [];
|
|
@@ -112,6 +113,14 @@ function getAnswers(existingValues) {
|
|
|
112
113
|
});
|
|
113
114
|
});
|
|
114
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
|
+
}
|
|
115
124
|
function promptAndStoreAnswer(questions, existingValues) {
|
|
116
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
126
|
(0, logger_1.log)('');
|
|
@@ -122,13 +131,15 @@ function promptAndStoreAnswer(questions, existingValues) {
|
|
|
122
131
|
}
|
|
123
132
|
if (questionWithVariableLabel.valueType === 'VARIABLE') {
|
|
124
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
|
+
}
|
|
125
142
|
if (existingVariable) {
|
|
126
|
-
let initial_value = existingVariable.value;
|
|
127
|
-
// Get correct initial value for select questions
|
|
128
|
-
if (questionWithVariableLabel.type === 'select' &&
|
|
129
|
-
Array.isArray(questionWithVariableLabel.choices)) {
|
|
130
|
-
initial_value = (0, questions_helper_1.getIndexFromChoices)(questionWithVariableLabel.choices, existingVariable.value);
|
|
131
|
-
}
|
|
132
143
|
return [
|
|
133
144
|
{
|
|
134
145
|
name: 'overWrite' + questionWithVariableLabel.name,
|
|
@@ -136,12 +147,30 @@ function promptAndStoreAnswer(questions, existingValues) {
|
|
|
136
147
|
scope: questionWithVariableLabel.scope,
|
|
137
148
|
message: `${kleur_1.default.yellow(`Variable ${kleur_1.default.cyan(existingVariable.name)} already exists in Github. Do you want to update it?`)}`
|
|
138
149
|
},
|
|
139
|
-
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) })
|
|
140
151
|
];
|
|
141
152
|
}
|
|
142
153
|
}
|
|
143
154
|
if (questionWithVariableLabel.valueType === 'SECRET') {
|
|
144
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
|
+
}
|
|
145
174
|
if (existingSecret) {
|
|
146
175
|
return [
|
|
147
176
|
{
|
|
@@ -175,7 +204,47 @@ function promptAndStoreAnswer(questions, existingValues) {
|
|
|
175
204
|
return Object.assign(Object.assign({}, Object.fromEntries(existingValuesForQuestions)), result);
|
|
176
205
|
});
|
|
177
206
|
}
|
|
178
|
-
|
|
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) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
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);
|
|
234
|
+
if (result.status === 'valid' || result.status === 'skipped') {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
(0, logger_1.error)(`\n${result.status}: ${result.reason || 'Generic error'}\n`);
|
|
238
|
+
const continueNotValidated = yield confirm({
|
|
239
|
+
message: 'Container registry credentials are not validated. Continue anyway?',
|
|
240
|
+
default: false
|
|
241
|
+
});
|
|
242
|
+
if (!continueNotValidated) {
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
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);
|
|
179
248
|
function runSetupEnvironment() {
|
|
180
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
250
|
var _a, _b, _c, _d;
|
|
@@ -239,16 +308,6 @@ function runSetupEnvironment() {
|
|
|
239
308
|
]
|
|
240
309
|
});
|
|
241
310
|
}
|
|
242
|
-
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Two-factor authentication (2FA)'));
|
|
243
|
-
const two_fa_enabled = yield confirm({
|
|
244
|
-
message: 'Enable two-factor authentication (2FA)? This should be enabled for any environment that hosts PII data.',
|
|
245
|
-
default: process.env.TWO_FA_ENABLED
|
|
246
|
-
? process.env.TWO_FA_ENABLED === 'true'
|
|
247
|
-
: environment_type === 'production'
|
|
248
|
-
});
|
|
249
|
-
if (!two_fa_enabled && ['production', 'staging'].includes(environment_type)) {
|
|
250
|
-
(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.');
|
|
251
|
-
}
|
|
252
311
|
const environment_exists = existingEnvironments
|
|
253
312
|
.map((e) => e.trim())
|
|
254
313
|
.includes(environment);
|
|
@@ -275,10 +334,30 @@ function runSetupEnvironment() {
|
|
|
275
334
|
(0, logger_1.log)('\n', kleur_1.default
|
|
276
335
|
.yellow()
|
|
277
336
|
.bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
|
|
278
|
-
yield promptAndStoreAnswer(questions_1.githubOtherQuestions, existingValues);
|
|
279
337
|
}
|
|
280
|
-
(0, logger_1.log)('\n', kleur_1.default.bold().underline('
|
|
281
|
-
|
|
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);
|
|
346
|
+
}
|
|
347
|
+
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Two-factor authentication (2FA)'));
|
|
348
|
+
const existingTwoFaEnabled = (0, utils_1.findExistingValue)('TWO_FA_ENABLED', 'VARIABLE', 'ENVIRONMENT', existingValues);
|
|
349
|
+
const twoFaDefault = process.env.TWO_FA_ENABLED || (existingTwoFaEnabled === null || existingTwoFaEnabled === void 0 ? void 0 : existingTwoFaEnabled.value);
|
|
350
|
+
const two_fa_enabled = yield confirm({
|
|
351
|
+
message: 'Enable two-factor authentication (2FA)? This should be enabled for any environment that hosts PII data.',
|
|
352
|
+
default: twoFaDefault
|
|
353
|
+
? twoFaDefault === 'true'
|
|
354
|
+
: environment_type === 'production'
|
|
355
|
+
});
|
|
356
|
+
if (!two_fa_enabled && ['production', 'staging'].includes(environment_type)) {
|
|
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.');
|
|
358
|
+
}
|
|
359
|
+
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Container registry'));
|
|
360
|
+
yield promptAndValidateRegistry(existingValues);
|
|
282
361
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
|
|
283
362
|
const infrastructure = yield promptAndStoreAnswer(questions_1.infrastructureQuestions, existingValues);
|
|
284
363
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes
|
|
@@ -340,6 +419,20 @@ function runSetupEnvironment() {
|
|
|
340
419
|
.yellow('Variable DISK_SPACE is read-only, allocated space:'), DISK_SPACE === null || DISK_SPACE === void 0 ? void 0 : DISK_SPACE.value);
|
|
341
420
|
}
|
|
342
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';
|
|
343
436
|
// Backup and restore configuration
|
|
344
437
|
let backupHost = ((_a = (0, utils_1.findExistingValue)('BACKUP_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _a === void 0 ? void 0 : _a.value) || '';
|
|
345
438
|
let backupType = '';
|
|
@@ -417,7 +510,18 @@ function runSetupEnvironment() {
|
|
|
417
510
|
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Restore is disabled'));
|
|
418
511
|
}
|
|
419
512
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Monitoring'));
|
|
420
|
-
|
|
513
|
+
const existingMonitoringEnabled = (0, utils_1.findExistingValue)('MONITORING_ENABLED', 'VARIABLE', 'ENVIRONMENT', existingValues);
|
|
514
|
+
const monitoringDefault = process.env.MONITORING_ENABLED || (existingMonitoringEnabled === null || existingMonitoringEnabled === void 0 ? void 0 : existingMonitoringEnabled.value);
|
|
515
|
+
const monitoring_enabled = yield confirm({
|
|
516
|
+
message: 'Enable monitoring (Kibana, APM, Filebeat, Metricbeat, Elastalert, OpenTelemetry Collector and tracing)? Disable it if this environment does not need its own monitoring stack.',
|
|
517
|
+
default: monitoringDefault ? monitoringDefault === 'true' : true
|
|
518
|
+
});
|
|
519
|
+
if (monitoring_enabled) {
|
|
520
|
+
yield promptAndStoreAnswer(questions_1.databaseAndMonitoringQuestions, existingValues);
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Monitoring is disabled'));
|
|
524
|
+
}
|
|
421
525
|
const sentryDSNExists = (0, utils_1.findExistingValue)('SENTRY_DSN', 'SECRET', 'ENVIRONMENT', existingValues);
|
|
422
526
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Sentry'));
|
|
423
527
|
if (sentryDSNExists) {
|
|
@@ -447,11 +551,7 @@ function runSetupEnvironment() {
|
|
|
447
551
|
* Variables the user doesn't need to set manually
|
|
448
552
|
*/
|
|
449
553
|
const answerOrExisting = (variable, existingValue, fn) => fn(variable || (existingValue === null || existingValue === void 0 ? void 0 : existingValue.value)) || '';
|
|
450
|
-
|
|
451
|
-
return (0, utils_1.findExistingValue)(name, type, scope, existingValues)
|
|
452
|
-
? null
|
|
453
|
-
: process.env[name] || newValue;
|
|
454
|
-
}
|
|
554
|
+
const findExistingOrDefine = (name, type, scope, newValue) => defineIfMissing(existingValues, name, type, scope, newValue);
|
|
455
555
|
const derivedUpdates = [
|
|
456
556
|
{
|
|
457
557
|
name: 'GH_ENCRYPTION_PASSWORD',
|
|
@@ -468,6 +568,32 @@ function runSetupEnvironment() {
|
|
|
468
568
|
value: findExistingOrDefine('NOTIFICATION_TRANSPORT', 'VARIABLE', 'ENVIRONMENT', 'email'),
|
|
469
569
|
scope: 'ENVIRONMENT'
|
|
470
570
|
});
|
|
571
|
+
derivedUpdates.push({
|
|
572
|
+
name: 'TWO_FA_ENABLED',
|
|
573
|
+
type: 'VARIABLE',
|
|
574
|
+
didExist: existingTwoFaEnabled,
|
|
575
|
+
// Always stored, so the next run defaults to the current answer
|
|
576
|
+
value: two_fa_enabled ? 'true' : 'false',
|
|
577
|
+
scope: 'ENVIRONMENT'
|
|
578
|
+
});
|
|
579
|
+
// Read by the deployment workflows (vars.MONITORING_ENABLED) to decide
|
|
580
|
+
// whether the OpenTelemetry Collector is installed
|
|
581
|
+
derivedUpdates.push({
|
|
582
|
+
name: 'MONITORING_ENABLED',
|
|
583
|
+
type: 'VARIABLE',
|
|
584
|
+
didExist: existingMonitoringEnabled,
|
|
585
|
+
value: monitoring_enabled ? 'true' : 'false',
|
|
586
|
+
scope: 'ENVIRONMENT'
|
|
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
|
+
});
|
|
471
597
|
derivedUpdates.push(...ssl_answers);
|
|
472
598
|
if (configureBackup) {
|
|
473
599
|
derivedUpdates.push({
|
|
@@ -494,17 +620,17 @@ function runSetupEnvironment() {
|
|
|
494
620
|
scope: 'ENVIRONMENT'
|
|
495
621
|
},
|
|
496
622
|
{
|
|
497
|
-
name: '
|
|
623
|
+
name: 'S3_ADMIN_ACCESS_KEY',
|
|
498
624
|
type: 'SECRET',
|
|
499
|
-
didExist: (0, utils_1.findExistingValue)('
|
|
500
|
-
value: findExistingOrDefine('
|
|
625
|
+
didExist: (0, utils_1.findExistingValue)('S3_ADMIN_ACCESS_KEY', 'SECRET', 'ENVIRONMENT', existingValues),
|
|
626
|
+
value: findExistingOrDefine('S3_ADMIN_ACCESS_KEY', 'SECRET', 'ENVIRONMENT', (0, utils_1.generateLongPassword)()),
|
|
501
627
|
scope: 'ENVIRONMENT'
|
|
502
628
|
},
|
|
503
629
|
{
|
|
504
|
-
name: '
|
|
630
|
+
name: 'S3_ADMIN_SECRET_KEY',
|
|
505
631
|
type: 'SECRET',
|
|
506
|
-
didExist: (0, utils_1.findExistingValue)('
|
|
507
|
-
value: findExistingOrDefine('
|
|
632
|
+
didExist: (0, utils_1.findExistingValue)('S3_ADMIN_SECRET_KEY', 'SECRET', 'ENVIRONMENT', existingValues),
|
|
633
|
+
value: findExistingOrDefine('S3_ADMIN_SECRET_KEY', 'SECRET', 'ENVIRONMENT', (0, utils_1.generateLongPassword)()),
|
|
508
634
|
scope: 'ENVIRONMENT'
|
|
509
635
|
},
|
|
510
636
|
{
|
|
@@ -633,7 +759,8 @@ function runSetupEnvironment() {
|
|
|
633
759
|
const newVariables = updates.filter((update) => update.type === 'VARIABLE' && !update.didExist);
|
|
634
760
|
const updatedVariables = updates.filter((update) => update.type === 'VARIABLE' && Boolean(update.didExist));
|
|
635
761
|
const unknownVariables = existingValues.filter((value) => {
|
|
636
|
-
return !ALL_QUESTIONS.find((question) => question.valueLabel === value.name
|
|
762
|
+
return !ALL_QUESTIONS.find((question) => (question.valueLabel === value.name ||
|
|
763
|
+
question.legacyValueLabel === value.name) &&
|
|
637
764
|
question.valueType === value.type &&
|
|
638
765
|
question.scope === value.scope);
|
|
639
766
|
});
|
|
@@ -762,6 +889,9 @@ function runSetupEnvironment() {
|
|
|
762
889
|
env: environment,
|
|
763
890
|
environment_type: environment_type,
|
|
764
891
|
two_fa_enabled,
|
|
892
|
+
monitoring_enabled,
|
|
893
|
+
rustfs_host_data_path,
|
|
894
|
+
rustfs_pvc_name,
|
|
765
895
|
traefik_mode: traefikConfOption,
|
|
766
896
|
restore_enabled: restoreEnvironmentName ? true : false,
|
|
767
897
|
restore_environment_name: restoreEnvironmentName || '',
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,QAyBzE"}
|