@opencrvs/toolkit 2.0.0-rc.e25c39b → 2.0.0-rc.e290634
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 +15 -0
- package/build.sh +3 -2
- package/dist/application-config/index.js +15 -5
- package/dist/cli.js +3252 -46
- package/dist/commons/api/router.d.ts +8 -0
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
- package/dist/commons/events/EventConfig.d.ts +2 -0
- package/dist/commons/events/EventIndex.d.ts +11 -0
- package/dist/commons/events/EventMetadata.d.ts +26 -0
- package/dist/commons/events/FieldConfig.d.ts +10 -0
- package/dist/commons/events/locations.d.ts +1 -0
- package/dist/commons/events/state/index.d.ts +8 -0
- package/dist/commons/events/state/utils.d.ts +9 -0
- package/dist/conditionals/index.js +10 -5
- package/dist/environment/custom-types.d.ts +33 -0
- package/dist/environment/custom-types.d.ts.map +1 -0
- package/dist/environment/custom-types.js +12 -0
- package/dist/environment/derived-variables.d.ts +134 -0
- package/dist/environment/derived-variables.d.ts.map +1 -0
- package/dist/environment/derived-variables.js +169 -0
- package/dist/environment/editor-questions.d.ts +4 -0
- package/dist/environment/editor-questions.d.ts.map +1 -0
- package/dist/environment/editor-questions.js +67 -0
- package/dist/environment/git.d.ts +5 -0
- package/dist/environment/git.d.ts.map +1 -0
- package/dist/environment/git.js +38 -0
- package/dist/environment/github.d.ts +26 -0
- package/dist/environment/github.d.ts.map +1 -0
- package/dist/environment/github.js +247 -0
- package/dist/environment/index.d.ts +5 -0
- package/dist/environment/index.d.ts.map +1 -0
- package/dist/environment/index.js +71 -0
- package/dist/environment/logger.d.ts +15 -0
- package/dist/environment/logger.d.ts.map +1 -0
- package/dist/environment/logger.js +25 -0
- package/dist/environment/manage-users.d.ts +11 -0
- package/dist/environment/manage-users.d.ts.map +1 -0
- package/dist/environment/manage-users.js +497 -0
- package/dist/environment/questions-helper.d.ts +15 -0
- package/dist/environment/questions-helper.d.ts.map +1 -0
- package/dist/environment/questions-helper.js +70 -0
- package/dist/environment/questions.d.ts +199 -0
- package/dist/environment/questions.d.ts.map +1 -0
- package/dist/environment/questions.js +412 -0
- package/dist/environment/setup-environment.d.ts +2 -0
- package/dist/environment/setup-environment.d.ts.map +1 -0
- package/dist/environment/setup-environment.js +794 -0
- package/dist/environment/ssh-keygen.d.ts +5 -0
- package/dist/environment/ssh-keygen.d.ts.map +1 -0
- package/dist/environment/ssh-keygen.js +21 -0
- package/dist/environment/swarm-to-k8s.d.ts +2 -0
- package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
- package/dist/environment/swarm-to-k8s.js +173 -0
- package/dist/environment/templates.d.ts +27 -0
- package/dist/environment/templates.d.ts.map +1 -0
- package/dist/environment/templates.js +163 -0
- package/dist/environment/update-workflows.d.ts +2 -0
- package/dist/environment/update-workflows.d.ts.map +1 -0
- package/dist/environment/update-workflows.js +169 -0
- package/dist/environment/users.d.ts +2 -0
- package/dist/environment/users.d.ts.map +1 -0
- package/dist/environment/users.js +112 -0
- package/dist/environment/utils.d.ts +18 -0
- package/dist/environment/utils.d.ts.map +1 -0
- package/dist/environment/utils.js +100 -0
- package/dist/events/index.js +38 -5
- package/dist/migrations/v2.0/index.js +10 -5
- package/dist/notification/index.js +15 -5
- package/dist/scopes/index.d.ts +89 -1
- package/dist/scopes/index.js +10 -5
- package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
- package/dist/templates/charts-values/dependencies/values.yaml +83 -0
- package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
- package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
- package/dist/templates/charts-values/traefik/values.yaml +115 -0
- package/dist/templates/inventory/inventory.template.yml +100 -0
- package/dist/templates/inventory/production.example.yml +77 -0
- package/dist/templates/inventory/qa.example.yml +48 -0
- package/opencrvs-toolkit-2.0.0-rc.e290634.tgz +0 -0
- package/package.json +15 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.e25c39b.tgz +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.derivedVariables = void 0;
|
|
14
|
+
exports.derivedVariables = [
|
|
15
|
+
{
|
|
16
|
+
name: 'ACTIVATE_USERS',
|
|
17
|
+
valueLabel: 'ACTIVATE_USERS',
|
|
18
|
+
valueType: 'VARIABLE',
|
|
19
|
+
type: 'disabled',
|
|
20
|
+
scope: 'ENVIRONMENT'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'COUNTRY_CONFIG_HOST',
|
|
24
|
+
valueLabel: 'COUNTRY_CONFIG_HOST',
|
|
25
|
+
valueType: 'VARIABLE',
|
|
26
|
+
type: 'disabled',
|
|
27
|
+
scope: 'ENVIRONMENT'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'GATEWAY_HOST',
|
|
31
|
+
valueLabel: 'GATEWAY_HOST',
|
|
32
|
+
valueType: 'VARIABLE',
|
|
33
|
+
type: 'disabled',
|
|
34
|
+
scope: 'ENVIRONMENT'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'CONTENT_SECURITY_POLICY_WILDCARD',
|
|
38
|
+
valueLabel: 'CONTENT_SECURITY_POLICY_WILDCARD',
|
|
39
|
+
valueType: 'VARIABLE',
|
|
40
|
+
type: 'disabled',
|
|
41
|
+
scope: 'ENVIRONMENT'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'CLIENT_APP_URL',
|
|
45
|
+
valueLabel: 'CLIENT_APP_URL',
|
|
46
|
+
valueType: 'VARIABLE',
|
|
47
|
+
type: 'disabled',
|
|
48
|
+
scope: 'ENVIRONMENT'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'LOGIN_URL',
|
|
52
|
+
valueLabel: 'LOGIN_URL',
|
|
53
|
+
valueType: 'VARIABLE',
|
|
54
|
+
type: 'disabled',
|
|
55
|
+
scope: 'ENVIRONMENT'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'ELASTICSEARCH_SUPERUSER_PASSWORD',
|
|
59
|
+
valueLabel: 'ELASTICSEARCH_SUPERUSER_PASSWORD',
|
|
60
|
+
valueType: 'SECRET',
|
|
61
|
+
type: 'disabled',
|
|
62
|
+
scope: 'ENVIRONMENT'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'KIBANA_SYSTEM_PASSWORD',
|
|
66
|
+
valueLabel: 'KIBANA_SYSTEM_PASSWORD',
|
|
67
|
+
valueType: 'SECRET',
|
|
68
|
+
type: 'disabled',
|
|
69
|
+
scope: 'ENVIRONMENT'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'MINIO_ROOT_USER',
|
|
73
|
+
valueLabel: 'MINIO_ROOT_USER',
|
|
74
|
+
valueType: 'SECRET',
|
|
75
|
+
type: 'disabled',
|
|
76
|
+
scope: 'ENVIRONMENT'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'MINIO_ROOT_PASSWORD',
|
|
80
|
+
valueLabel: 'MINIO_ROOT_PASSWORD',
|
|
81
|
+
valueType: 'SECRET',
|
|
82
|
+
type: 'disabled',
|
|
83
|
+
scope: 'ENVIRONMENT'
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'MONGODB_ADMIN_USER',
|
|
87
|
+
valueLabel: 'MONGODB_ADMIN_USER',
|
|
88
|
+
valueType: 'SECRET',
|
|
89
|
+
type: 'disabled',
|
|
90
|
+
scope: 'ENVIRONMENT'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'MONGODB_ADMIN_PASSWORD',
|
|
94
|
+
valueLabel: 'MONGODB_ADMIN_PASSWORD',
|
|
95
|
+
valueType: 'SECRET',
|
|
96
|
+
type: 'disabled',
|
|
97
|
+
scope: 'ENVIRONMENT'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'POSTGRES_USER',
|
|
101
|
+
valueLabel: 'POSTGRES_USER',
|
|
102
|
+
valueType: 'SECRET',
|
|
103
|
+
type: 'disabled',
|
|
104
|
+
scope: 'ENVIRONMENT'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'POSTGRES_PASSWORD',
|
|
108
|
+
valueLabel: 'POSTGRES_PASSWORD',
|
|
109
|
+
valueType: 'SECRET',
|
|
110
|
+
type: 'disabled',
|
|
111
|
+
scope: 'ENVIRONMENT'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'SUPER_USER_PASSWORD',
|
|
115
|
+
valueLabel: 'SUPER_USER_PASSWORD',
|
|
116
|
+
valueType: 'SECRET',
|
|
117
|
+
type: 'disabled',
|
|
118
|
+
scope: 'ENVIRONMENT'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'ENCRYPTION_KEY',
|
|
122
|
+
valueLabel: 'ENCRYPTION_KEY',
|
|
123
|
+
valueType: 'SECRET',
|
|
124
|
+
type: 'disabled',
|
|
125
|
+
scope: 'ENVIRONMENT'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'GH_ENCRYPTION_PASSWORD',
|
|
129
|
+
valueLabel: 'GH_ENCRYPTION_PASSWORD',
|
|
130
|
+
valueType: 'SECRET',
|
|
131
|
+
type: 'disabled',
|
|
132
|
+
scope: 'REPOSITORY'
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: 'BACKUP_ENCRYPTION_PASSPHRASE',
|
|
136
|
+
valueLabel: 'BACKUP_ENCRYPTION_PASSPHRASE',
|
|
137
|
+
valueType: 'SECRET',
|
|
138
|
+
type: 'disabled',
|
|
139
|
+
scope: 'ENVIRONMENT'
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'BACKUP_HOST_PRIVATE_KEY',
|
|
143
|
+
valueLabel: 'BACKUP_HOST_PRIVATE_KEY',
|
|
144
|
+
valueType: 'SECRET',
|
|
145
|
+
type: 'disabled',
|
|
146
|
+
scope: 'ENVIRONMENT'
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'BACKUP_HOST_PUBLIC_KEY',
|
|
150
|
+
valueLabel: 'BACKUP_HOST_PUBLIC_KEY',
|
|
151
|
+
valueType: 'SECRET',
|
|
152
|
+
type: 'disabled',
|
|
153
|
+
scope: 'ENVIRONMENT'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'RESTORE_ENVIRONMENT_NAME',
|
|
157
|
+
valueLabel: 'RESTORE_ENVIRONMENT_NAME',
|
|
158
|
+
valueType: 'VARIABLE',
|
|
159
|
+
type: 'disabled',
|
|
160
|
+
scope: 'ENVIRONMENT'
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'NOTIFICATION_TRANSPORT',
|
|
164
|
+
valueLabel: 'NOTIFICATION_TRANSPORT',
|
|
165
|
+
valueType: 'VARIABLE',
|
|
166
|
+
type: 'disabled',
|
|
167
|
+
scope: 'ENVIRONMENT'
|
|
168
|
+
}
|
|
169
|
+
];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Secret, Variable } from './github';
|
|
2
|
+
import { AnswerWithNullValue, QuestionDescriptor } from './custom-types';
|
|
3
|
+
export declare function askQuestionWithEditor(questions: Array<QuestionDescriptor<any>>, existingValues: Array<Secret | Variable>): Promise<AnswerWithNullValue[]>;
|
|
4
|
+
//# sourceMappingURL=editor-questions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-questions.d.ts","sourceRoot":"","sources":["../../src/environment/editor-questions.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EACL,mBAAmB,EAEnB,kBAAkB,EACnB,MAAM,gBAAgB,CAAA;AAUvB,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,EACzC,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GACvC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAoDhC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.askQuestionWithEditor = askQuestionWithEditor;
|
|
26
|
+
const utils_1 = require("./utils");
|
|
27
|
+
const kleur_1 = __importDefault(require("kleur"));
|
|
28
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
29
|
+
function editorQuestion(question) {
|
|
30
|
+
return import('@inquirer/prompts').then(({ editor }) => editor({ message: question }));
|
|
31
|
+
}
|
|
32
|
+
function askQuestionWithEditor(questions, existingValues) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const answers = [];
|
|
35
|
+
for (const question of questions) {
|
|
36
|
+
const questionWithVariableLabel = Object.assign(Object.assign({}, question), { message: `${kleur_1.default.cyan(question.valueLabel || '')}: ${question.message}` });
|
|
37
|
+
if (!questionWithVariableLabel.valueLabel) {
|
|
38
|
+
throw Error('Undefined Label');
|
|
39
|
+
}
|
|
40
|
+
const existingSecret = (0, utils_1.findExistingValue)(questionWithVariableLabel.valueLabel, 'SECRET', questionWithVariableLabel.scope, existingValues);
|
|
41
|
+
let updateSecret = true;
|
|
42
|
+
if (existingSecret) {
|
|
43
|
+
updateSecret = (yield (0, prompts_1.default)([
|
|
44
|
+
{
|
|
45
|
+
name: 'overWrite',
|
|
46
|
+
type: 'confirm',
|
|
47
|
+
message: `${kleur_1.default.yellow(`${existingSecret.scope === 'REPOSITORY'
|
|
48
|
+
? 'Repository secret'
|
|
49
|
+
: 'Secret'} ${kleur_1.default.cyan(existingSecret.name)} already exists in Github. Do you want to update it?`)}`
|
|
50
|
+
}
|
|
51
|
+
])).overWrite;
|
|
52
|
+
}
|
|
53
|
+
if (!existingSecret || updateSecret === true) {
|
|
54
|
+
const question_answer = yield editorQuestion(questionWithVariableLabel.message);
|
|
55
|
+
const answer = {
|
|
56
|
+
type: 'SECRET',
|
|
57
|
+
scope: 'ENVIRONMENT',
|
|
58
|
+
name: questionWithVariableLabel.valueLabel,
|
|
59
|
+
value: question_answer,
|
|
60
|
+
didExist: existingSecret
|
|
61
|
+
};
|
|
62
|
+
answers.push(answer);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return answers;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/environment/git.ts"],"names":[],"mappings":"AAaA,wBAAgB,WAAW;;;EAyB1B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.getRepoInfo = getRepoInfo;
|
|
14
|
+
const child_process_1 = require("child_process");
|
|
15
|
+
function getRepoInfo() {
|
|
16
|
+
try {
|
|
17
|
+
const remoteUrl = (0, child_process_1.execSync)('git config --get remote.origin.url', {
|
|
18
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
19
|
+
})
|
|
20
|
+
.toString()
|
|
21
|
+
.trim();
|
|
22
|
+
// Handle both SSH and HTTPS formats
|
|
23
|
+
const match = remoteUrl.match(/github\.com[:/](.+?)\/(.+?)(\.git)?$/);
|
|
24
|
+
if (!match) {
|
|
25
|
+
return { organization: '', repository: '' };
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
organization: match[1],
|
|
29
|
+
repository: match[2]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (_a) {
|
|
33
|
+
return {
|
|
34
|
+
organization: '',
|
|
35
|
+
repository: ''
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Octokit } from '@octokit/core';
|
|
2
|
+
export declare function createEnvironmentVariable(octokit: Octokit, repositoryId: number, environment: string, name: string, value: string): Promise<void>;
|
|
3
|
+
export declare function updateEnvironmentVariable(octokit: Octokit, repositoryId: number, environment: string, name: string, value: string): Promise<void>;
|
|
4
|
+
export declare function createRepositoryVariable(octokit: Octokit, repositoryId: number, name: string, value: string): Promise<void>;
|
|
5
|
+
export declare function updateRepositoryVariable(octokit: Octokit, repositoryId: number, name: string, value: string): Promise<void>;
|
|
6
|
+
export declare function getRepositoryId(octokit: Octokit, owner: string, repo: string): Promise<number>;
|
|
7
|
+
export declare function createEnvironmentSecret(octokit: Octokit, repositoryId: number, environment: string, name: string, secret: string, organisationName: string, repositoryName: string): Promise<void>;
|
|
8
|
+
export declare function createRepositorySecret(octokit: Octokit, repositoryId: number, name: string, secret: string, organisationName: string, repositoryName: string): Promise<void>;
|
|
9
|
+
export declare function getRepositoryEnvironments(octokit: Octokit, githubOrganisation: string, repository: string): Promise<string[]>;
|
|
10
|
+
export declare function createEnvironment(octokit: Octokit, environment: string, ORGANISATION: string, REPOSITORY_NAME: string): Promise<boolean>;
|
|
11
|
+
export type Secret = {
|
|
12
|
+
type: 'SECRET';
|
|
13
|
+
name: string;
|
|
14
|
+
scope: 'ENVIRONMENT' | 'REPOSITORY';
|
|
15
|
+
};
|
|
16
|
+
export type Variable = {
|
|
17
|
+
type: 'VARIABLE';
|
|
18
|
+
name: string;
|
|
19
|
+
value: string;
|
|
20
|
+
scope: 'ENVIRONMENT' | 'REPOSITORY';
|
|
21
|
+
};
|
|
22
|
+
export declare function listEnvironmentSecrets(octokit: Octokit, owner: string, repositoryId: number, environmentName: string): Promise<Secret[]>;
|
|
23
|
+
export declare function listRepositorySecrets(octokit: Octokit, owner: string, repositoryName: string): Promise<Secret[]>;
|
|
24
|
+
export declare function listEnvironmentVariables(octokit: Octokit, repositoryId: number, environmentName: string): Promise<Variable[]>;
|
|
25
|
+
export declare function listRepositoryVariables(octokit: Octokit, owner: string, repositoryName: string): Promise<Variable[]>;
|
|
26
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/environment/github.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,247 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.createEnvironmentVariable = createEnvironmentVariable;
|
|
26
|
+
exports.updateEnvironmentVariable = updateEnvironmentVariable;
|
|
27
|
+
exports.createRepositoryVariable = createRepositoryVariable;
|
|
28
|
+
exports.updateRepositoryVariable = updateRepositoryVariable;
|
|
29
|
+
exports.getRepositoryId = getRepositoryId;
|
|
30
|
+
exports.createEnvironmentSecret = createEnvironmentSecret;
|
|
31
|
+
exports.createRepositorySecret = createRepositorySecret;
|
|
32
|
+
exports.getRepositoryEnvironments = getRepositoryEnvironments;
|
|
33
|
+
exports.createEnvironment = createEnvironment;
|
|
34
|
+
exports.listEnvironmentSecrets = listEnvironmentSecrets;
|
|
35
|
+
exports.listRepositorySecrets = listRepositorySecrets;
|
|
36
|
+
exports.listEnvironmentVariables = listEnvironmentVariables;
|
|
37
|
+
exports.listRepositoryVariables = listRepositoryVariables;
|
|
38
|
+
const libsodium_wrappers_1 = __importDefault(require("libsodium-wrappers"));
|
|
39
|
+
const logger_1 = require("./logger");
|
|
40
|
+
function createEnvironmentVariable(octokit, repositoryId, environment, name, value) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
yield octokit.request(`POST /repositories/${repositoryId}/environments/${environment}/variables`, {
|
|
43
|
+
repository_id: repositoryId,
|
|
44
|
+
environment_name: environment,
|
|
45
|
+
name: name,
|
|
46
|
+
value: value,
|
|
47
|
+
headers: {
|
|
48
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function updateEnvironmentVariable(octokit, repositoryId, environment, name, value) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
yield octokit.request(`PATCH /repositories/${repositoryId}/environments/${environment}/variables/${name}`, {
|
|
56
|
+
repository_id: repositoryId,
|
|
57
|
+
environment_name: environment,
|
|
58
|
+
name: name,
|
|
59
|
+
value: value,
|
|
60
|
+
headers: {
|
|
61
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Create repository variable
|
|
67
|
+
function createRepositoryVariable(octokit, repositoryId, name, value) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
yield octokit.request(`POST /repositories/${repositoryId}/actions/variables`, {
|
|
70
|
+
repository_id: repositoryId,
|
|
71
|
+
name: name,
|
|
72
|
+
value: value,
|
|
73
|
+
headers: {
|
|
74
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Update repository variable
|
|
80
|
+
function updateRepositoryVariable(octokit, repositoryId, name, value) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
yield octokit.request(`PATCH /repositories/${repositoryId}/actions/variables/${name}`, {
|
|
83
|
+
repository_id: repositoryId,
|
|
84
|
+
name: name,
|
|
85
|
+
value: value,
|
|
86
|
+
headers: {
|
|
87
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function getRepositoryId(octokit, owner, repo) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const response = yield octokit.request('GET /repos/{owner}/{repo}', {
|
|
95
|
+
owner: owner,
|
|
96
|
+
repo: repo
|
|
97
|
+
});
|
|
98
|
+
return response.data.id;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function getRepositoryPublicKey(octokit, owner, repo) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const res = yield octokit.request('GET /repos/{owner}/{repo}/actions/secrets/public-key', {
|
|
104
|
+
owner: owner,
|
|
105
|
+
repo: repo
|
|
106
|
+
});
|
|
107
|
+
return res.data;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function getPublicKey(octokit, environment, ORGANISATION, REPOSITORY_NAME) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const repositoryId = yield getRepositoryId(octokit, ORGANISATION, REPOSITORY_NAME);
|
|
113
|
+
yield octokit.request(`PUT /repos/${ORGANISATION}/${REPOSITORY_NAME}/environments/${environment}`, {
|
|
114
|
+
headers: {
|
|
115
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const res = yield octokit.request(`GET /repositories/${repositoryId}/environments/${environment}/secrets/public-key`, {
|
|
119
|
+
owner: ORGANISATION,
|
|
120
|
+
repo: REPOSITORY_NAME,
|
|
121
|
+
headers: {
|
|
122
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return res.data;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function createEnvironmentSecret(octokit, repositoryId, environment, name, secret, organisationName, repositoryName) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
//Check if libsodium is ready and then proceed.
|
|
131
|
+
yield libsodium_wrappers_1.default.ready;
|
|
132
|
+
const { key, key_id } = yield getPublicKey(octokit, environment, organisationName, repositoryName);
|
|
133
|
+
// Convert Secret & Base64 key to Uint8Array.
|
|
134
|
+
const binkey = libsodium_wrappers_1.default.from_base64(key, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
135
|
+
const binsec = libsodium_wrappers_1.default.from_string(secret);
|
|
136
|
+
//Encrypt the secret using LibSodium
|
|
137
|
+
const encBytes = libsodium_wrappers_1.default.crypto_box_seal(binsec, binkey);
|
|
138
|
+
// Convert encrypted Uint8Array to Base64
|
|
139
|
+
const encryptedValue = libsodium_wrappers_1.default.to_base64(encBytes, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
140
|
+
yield octokit.request(`PUT /repositories/${repositoryId}/environments/${environment}/secrets/${name}`, {
|
|
141
|
+
repository_id: repositoryId,
|
|
142
|
+
environment_name: environment,
|
|
143
|
+
secret_name: name,
|
|
144
|
+
encrypted_value: encryptedValue,
|
|
145
|
+
key_id,
|
|
146
|
+
headers: {
|
|
147
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function createRepositorySecret(octokit, repositoryId, name, secret, organisationName, repositoryName) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
//Check if libsodium is ready and then proceed.
|
|
155
|
+
yield libsodium_wrappers_1.default.ready;
|
|
156
|
+
const { key, key_id } = yield getRepositoryPublicKey(octokit, organisationName, repositoryName);
|
|
157
|
+
// Convert Secret & Base64 key to Uint8Array.
|
|
158
|
+
const binkey = libsodium_wrappers_1.default.from_base64(key, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
159
|
+
const binsec = libsodium_wrappers_1.default.from_string(secret);
|
|
160
|
+
//Encrypt the secret using LibSodium
|
|
161
|
+
const encBytes = libsodium_wrappers_1.default.crypto_box_seal(binsec, binkey);
|
|
162
|
+
// Convert encrypted Uint8Array to Base64
|
|
163
|
+
const encryptedValue = libsodium_wrappers_1.default.to_base64(encBytes, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
164
|
+
yield octokit.request(`PUT /repositories/${repositoryId}/actions/secrets/${name}`, {
|
|
165
|
+
encrypted_value: encryptedValue,
|
|
166
|
+
key_id,
|
|
167
|
+
headers: {
|
|
168
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function getRepositoryEnvironments(octokit, githubOrganisation, repository) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
var _a;
|
|
176
|
+
const response = yield octokit.request('GET /repos/{githubOrganisation}/{repository}/environments', {
|
|
177
|
+
githubOrganisation,
|
|
178
|
+
repository
|
|
179
|
+
});
|
|
180
|
+
// Safe access with fallback to empty array if undefined
|
|
181
|
+
const environments = ((_a = response.data.environments) !== null && _a !== void 0 ? _a : []).map((env) => env.name);
|
|
182
|
+
return environments;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function createEnvironment(octokit, environment, ORGANISATION, REPOSITORY_NAME) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
var _a, _b, _c, _d;
|
|
188
|
+
try {
|
|
189
|
+
yield octokit.request(`PUT /repos/${ORGANISATION}/${REPOSITORY_NAME}/environments/${environment}`, {
|
|
190
|
+
headers: {
|
|
191
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
(0, logger_1.error)(`Cannot create environment: [${err.status}] ${(_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message}`);
|
|
198
|
+
throw new Error(`Cannot create environment: [${err.status}] ${(_d = (_c = err.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message}`);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function listEnvironmentSecrets(octokit, owner, repositoryId, environmentName) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
const response = yield octokit.request('GET /repositories/{repository_id}/environments/{environment_name}/secrets', {
|
|
205
|
+
owner: owner,
|
|
206
|
+
repository_id: repositoryId,
|
|
207
|
+
environment_name: environmentName,
|
|
208
|
+
per_page: 100
|
|
209
|
+
});
|
|
210
|
+
return response.data.secrets.map((secret) => (Object.assign(Object.assign({}, secret), { type: 'SECRET', scope: 'ENVIRONMENT' })));
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function listRepositorySecrets(octokit, owner, repositoryName) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
const response = yield octokit.request('GET /repos/{owner}/{repo}/actions/secrets', {
|
|
216
|
+
owner: owner,
|
|
217
|
+
repo: repositoryName,
|
|
218
|
+
per_page: 100
|
|
219
|
+
});
|
|
220
|
+
return response.data.secrets.map((secret) => (Object.assign(Object.assign({}, secret), { type: 'SECRET', scope: 'REPOSITORY' })));
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function listEnvironmentVariables(octokit, repositoryId, environmentName) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
const response = yield octokit.request('GET /repositories/{repository_id}/environments/{environment_name}/variables', {
|
|
226
|
+
repository_id: repositoryId,
|
|
227
|
+
environment_name: environmentName,
|
|
228
|
+
per_page: 100,
|
|
229
|
+
headers: {
|
|
230
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
return response.data.variables
|
|
234
|
+
.map((variable) => (Object.assign(Object.assign({}, variable), { type: 'VARIABLE', scope: 'ENVIRONMENT' })))
|
|
235
|
+
.filter((variable) => variable.name !== 'ACTIONS_RUNNER_DEBUG');
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function listRepositoryVariables(octokit, owner, repositoryName) {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
+
const response = yield octokit.request('GET /repos/{owner}/{repo}/actions/variables', {
|
|
241
|
+
owner: owner,
|
|
242
|
+
repo: repositoryName,
|
|
243
|
+
per_page: 100
|
|
244
|
+
});
|
|
245
|
+
return response.data.variables.map((variable) => (Object.assign(Object.assign({}, variable), { type: 'VARIABLE', scope: 'REPOSITORY' })));
|
|
246
|
+
});
|
|
247
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function runEnvironmentInit(): Promise<void>;
|
|
2
|
+
export declare function runEnvironmentUpdateWorkflows(): Promise<void>;
|
|
3
|
+
export declare function runEnvironmentUsers(): Promise<void>;
|
|
4
|
+
export declare function runEnvironmentSwarmToK8s(): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"AAwCA,wBAAsB,kBAAkB,kBAGvC;AAED,wBAAsB,6BAA6B,kBAIlD;AAED,wBAAsB,mBAAmB,kBAIxC;AAED,wBAAsB,wBAAwB,kBAG7C"}
|
|
@@ -0,0 +1,71 @@
|
|
|
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.runEnvironmentInit = runEnvironmentInit;
|
|
23
|
+
exports.runEnvironmentUpdateWorkflows = runEnvironmentUpdateWorkflows;
|
|
24
|
+
exports.runEnvironmentUsers = runEnvironmentUsers;
|
|
25
|
+
exports.runEnvironmentSwarmToK8s = runEnvironmentSwarmToK8s;
|
|
26
|
+
const fs_1 = require("fs");
|
|
27
|
+
const path_1 = require("path");
|
|
28
|
+
const REQUIRED_REPOSITORY_DIRECTORIES = [
|
|
29
|
+
'.github/workflows',
|
|
30
|
+
'environments',
|
|
31
|
+
'infrastructure'
|
|
32
|
+
];
|
|
33
|
+
function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
34
|
+
const missingDirectories = REQUIRED_REPOSITORY_DIRECTORIES.filter((directory) => {
|
|
35
|
+
try {
|
|
36
|
+
return !(0, fs_1.statSync)((0, path_1.resolve)(repositoryRoot, directory)).isDirectory();
|
|
37
|
+
}
|
|
38
|
+
catch (_a) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (missingDirectories.length > 0) {
|
|
43
|
+
throw new Error(`The current directory is not a valid OpenCRVS country configuration repository. Missing required director${missingDirectories.length === 1 ? 'y' : 'ies'}: ${missingDirectories.join(', ')}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function runEnvironmentInit() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
validateRepositoryStructure();
|
|
49
|
+
yield import('./setup-environment.js');
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function runEnvironmentUpdateWorkflows() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
validateRepositoryStructure();
|
|
55
|
+
const { updateWorkflowEnvironments } = yield import('./update-workflows.js');
|
|
56
|
+
yield updateWorkflowEnvironments();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function runEnvironmentUsers() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
validateRepositoryStructure();
|
|
62
|
+
const { manageEnvironmentUsers } = yield import('./users.js');
|
|
63
|
+
yield manageEnvironmentUsers();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function runEnvironmentSwarmToK8s() {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
validateRepositoryStructure();
|
|
69
|
+
yield import('./swarm-to-k8s.js');
|
|
70
|
+
});
|
|
71
|
+
}
|