@catladder/pipeline 1.101.4 → 1.103.0
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/dist/build/base/createBuildJob.js +3 -2
- package/dist/build/base/writeDotEnv.d.ts +7 -0
- package/dist/build/base/writeDotEnv.js +43 -0
- package/dist/build/custom/testJob.js +2 -2
- package/dist/build/node/testJob.js +2 -2
- package/dist/build/rails/build.js +11 -1
- package/dist/build/rails/test.js +1 -1
- package/dist/build/types.d.ts +8 -1
- package/dist/bundles/catladder-gitlab/index.js +3 -3
- package/dist/constants.js +1 -1
- package/dist/context/getEnvironment.js +18 -12
- package/dist/context/getEnvironmentVariables.d.ts +2 -7
- package/dist/context/getEnvironmentVariables.js +27 -31
- package/dist/context/transformJobOnlyVars.d.ts +10 -0
- package/dist/context/transformJobOnlyVars.js +160 -0
- package/dist/context/utils/envVars.d.ts +8 -0
- package/dist/context/utils/envVars.js +52 -0
- package/dist/deploy/base.js +3 -3
- package/dist/deploy/types/base.d.ts +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +6 -0
- package/dist/types/context.d.ts +16 -6
- package/examples/__snapshots__/custom-deploy.ts.snap +8 -0
- package/examples/__snapshots__/native-app.ts.snap +2958 -0
- package/examples/custom-deploy.ts +3 -0
- package/examples/native-app.ts +81 -0
- package/package.json +1 -1
- package/src/build/base/createBuildJob.ts +3 -0
- package/src/build/base/writeDotEnv.ts +21 -0
- package/src/build/custom/testJob.ts +1 -0
- package/src/build/node/testJob.ts +1 -0
- package/src/build/rails/build.ts +4 -1
- package/src/build/rails/test.ts +4 -1
- package/src/build/types.ts +9 -1
- package/src/context/getEnvironment.ts +9 -7
- package/src/context/getEnvironmentVariables.ts +36 -24
- package/src/context/transformJobOnlyVars.ts +42 -0
- package/src/context/utils/envVars.ts +26 -0
- package/src/deploy/base.ts +3 -0
- package/src/deploy/types/base.ts +10 -0
- package/src/types/config.ts +7 -0
- package/src/types/context.ts +18 -6
- package/tsconfig.json +1 -1
package/dist/constants.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
5
|
-
exports.PIPELINE_IMAGE_TAG = "v1-
|
|
5
|
+
exports.PIPELINE_IMAGE_TAG = "v1-103-0-dd05e19b" || "";
|
|
6
6
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
3
13
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
14
|
function adopt(value) {
|
|
5
15
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -121,30 +131,26 @@ var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
|
121
131
|
var getEnvironmentVariables_1 = require("./getEnvironmentVariables");
|
|
122
132
|
var getEnvironment = function (config, componentName, env, commitInfo) {
|
|
123
133
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
124
|
-
var
|
|
125
|
-
return __generator(this, function (
|
|
126
|
-
switch (
|
|
134
|
+
var variables, envContext, envType;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
switch (_a.label) {
|
|
127
137
|
case 0:
|
|
128
138
|
return [4 /*yield*/, (0, getEnvironmentVariables_1.getEnvironmentVariables)(config, componentName, env, commitInfo)];
|
|
129
139
|
case 1:
|
|
130
|
-
|
|
140
|
+
variables = _a.sent();
|
|
131
141
|
envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
|
|
132
142
|
envType = envContext.envType;
|
|
133
|
-
return [2 /*return*/, {
|
|
143
|
+
return [2 /*return*/, __assign({
|
|
134
144
|
envType: envType,
|
|
135
|
-
host: host,
|
|
136
|
-
url: url,
|
|
137
145
|
gitlabEnvironment: {
|
|
138
146
|
name: envContext.gitlabEnvironmentName,
|
|
139
|
-
url: url
|
|
147
|
+
url: variables.url
|
|
140
148
|
},
|
|
141
149
|
fullName: envContext.fullName,
|
|
142
150
|
slugPrefix: envContext.environmentSlugPrefix,
|
|
143
151
|
slug: envContext.environmentSlug,
|
|
144
|
-
shortName: env
|
|
145
|
-
|
|
146
|
-
secretEnvVarKeys: secretEnvVarKeys
|
|
147
|
-
}];
|
|
152
|
+
shortName: env
|
|
153
|
+
}, variables)];
|
|
148
154
|
}
|
|
149
155
|
});
|
|
150
156
|
});
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import type { CommitInfo, Context } from "../types";
|
|
1
|
+
import type { CommitInfo, Context, EnvironmentEnvVarPart as EnvironmentVariables } from "../types";
|
|
2
2
|
import type { Config } from "../types/config";
|
|
3
3
|
export declare type SecretEnvVar = {
|
|
4
4
|
key: string;
|
|
5
5
|
hidden?: boolean;
|
|
6
6
|
};
|
|
7
|
-
export declare const getEnvironmentVariables: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, alreadyVisited?: Record<string, Record<string, boolean>>) => Promise<
|
|
8
|
-
envVars: Record<string, string>;
|
|
9
|
-
secretEnvVarKeys: SecretEnvVar[];
|
|
10
|
-
host: string;
|
|
11
|
-
url: string;
|
|
12
|
-
}>;
|
|
7
|
+
export declare const getEnvironmentVariables: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, alreadyVisited?: Record<string, Record<string, boolean>>) => Promise<EnvironmentVariables>;
|
|
13
8
|
export declare const getSecretVarName: (env: string, componentName: string, key: string) => string;
|
|
14
9
|
export declare const getSecretVarNameForContext: (context: Context, key: string) => string;
|
|
@@ -162,19 +162,22 @@ var lodash_1 = require("lodash");
|
|
|
162
162
|
var deploy_1 = require("../deploy");
|
|
163
163
|
var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
164
164
|
var resolveReferences_1 = require("./resolveReferences");
|
|
165
|
+
var envVars_1 = require("./utils/envVars");
|
|
166
|
+
var transformJobOnlyVars_1 = require("./transformJobOnlyVars");
|
|
165
167
|
var getEnvironmentVariables = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
|
|
166
168
|
) {
|
|
167
169
|
if (alreadyVisited === void 0) {
|
|
168
170
|
alreadyVisited = {};
|
|
169
171
|
}
|
|
170
172
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
171
|
-
var environmentContext, envConfigRaw, deployConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents,
|
|
172
|
-
var _a, _b
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
var environmentContext, envConfigRaw, deployConfigRaw, buildConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegacyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
|
|
174
|
+
var _a, _b;
|
|
175
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
176
|
+
return __generator(this, function (_m) {
|
|
177
|
+
switch (_m.label) {
|
|
175
178
|
case 0:
|
|
176
179
|
environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
|
|
177
|
-
envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, envType = environmentContext.envType;
|
|
180
|
+
envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, buildConfigRaw = environmentContext.buildConfigRaw, envType = environmentContext.envType;
|
|
178
181
|
basePredefinedVariables = {
|
|
179
182
|
ENV_SHORT: env,
|
|
180
183
|
APP_DIR: envConfigRaw.dir,
|
|
@@ -185,7 +188,7 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
|
|
|
185
188
|
};
|
|
186
189
|
if (envType === "local") {
|
|
187
190
|
devLocalConfig = envConfigRaw;
|
|
188
|
-
port = (
|
|
191
|
+
port = (_c = devLocalConfig.port) !== null && _c !== void 0 ? _c : 3000;
|
|
189
192
|
host = "localhost:" + port;
|
|
190
193
|
url = "http://" + host;
|
|
191
194
|
predefinedVariables = {
|
|
@@ -195,7 +198,7 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
|
|
|
195
198
|
};
|
|
196
199
|
} else {
|
|
197
200
|
additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
|
|
198
|
-
host = (
|
|
201
|
+
host = (_e = (_d = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _d !== void 0 ? _d : additionalEnvVars.HOST_CANONICAL) !== null && _e !== void 0 ? _e : "unknown-host.example.com";
|
|
199
202
|
url = "https://".concat(host);
|
|
200
203
|
predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), config.components[componentName].build.type === "rails" ? {} : {
|
|
201
204
|
HOST: host
|
|
@@ -203,25 +206,13 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
|
|
|
203
206
|
ROOT_URL: url
|
|
204
207
|
}), additionalEnvVars);
|
|
205
208
|
}
|
|
206
|
-
publicEnvVarsRaw = (
|
|
209
|
+
publicEnvVarsRaw = (_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.public) !== null && _g !== void 0 ? _g : {};
|
|
207
210
|
additionalSecretKeys = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(environmentContext) : [];
|
|
208
|
-
secretEnvVarKeys = __spreadArray(__spreadArray([], __read(((
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (_a) {
|
|
214
|
-
var key = _a.key;
|
|
215
|
-
return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
|
|
216
|
-
}));
|
|
217
|
-
legacyFromComponents = (_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.fromComponents) !== null && _j !== void 0 ? _j : {};
|
|
218
|
-
publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
|
|
219
|
-
publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
|
|
220
|
-
var _b = __read(_a, 2),
|
|
221
|
-
key = _b[0],
|
|
222
|
-
value = _b[1];
|
|
223
|
-
return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
|
|
224
|
-
}));
|
|
211
|
+
secretEnvVarKeys = __spreadArray(__spreadArray([], __read((0, envVars_1.stringListToSecreteEnvVarList)((_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.secret) !== null && _j !== void 0 ? _j : [])), false), __read(additionalSecretKeys), false);
|
|
212
|
+
secretEnvVars = (0, envVars_1.makeSecretEnvVarMapping)(env, componentName, secretEnvVarKeys);
|
|
213
|
+
legacyFromComponents = (_l = (_k = envConfigRaw.vars) === null || _k === void 0 ? void 0 : _k.fromComponents) !== null && _l !== void 0 ? _l : {};
|
|
214
|
+
publicEnvVarsRawWithLegacyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
|
|
215
|
+
publicEnvVarsRawSanitized = (0, envVars_1.stringifyValues)(publicEnvVarsRawWithLegacyFromComponents);
|
|
225
216
|
envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
|
|
226
217
|
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, alreadyVisited) {
|
|
227
218
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -238,13 +229,18 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
|
|
|
238
229
|
});
|
|
239
230
|
}, alreadyVisited)];
|
|
240
231
|
case 1:
|
|
241
|
-
envVars =
|
|
242
|
-
|
|
232
|
+
envVars = _m.sent();
|
|
233
|
+
_a = {
|
|
243
234
|
envVars: envVars,
|
|
244
|
-
secretEnvVarKeys: secretEnvVarKeys
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
235
|
+
secretEnvVarKeys: secretEnvVarKeys
|
|
236
|
+
};
|
|
237
|
+
_b = {};
|
|
238
|
+
return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, buildConfigRaw && buildConfigRaw.jobVars || null)];
|
|
239
|
+
case 2:
|
|
240
|
+
_b.build = _m.sent();
|
|
241
|
+
return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, deployConfigRaw && deployConfigRaw.jobVars || null)];
|
|
242
|
+
case 3:
|
|
243
|
+
return [2 /*return*/, (_a.jobOnlyVars = (_b.deploy = _m.sent(), _b), _a.host = host, _a.url = url, _a)];
|
|
248
244
|
}
|
|
249
245
|
});
|
|
250
246
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EnvironmentEnvVars } from "..";
|
|
2
|
+
import type { EnvVars } from "../types/config";
|
|
3
|
+
/**
|
|
4
|
+
* transform EnvVars for environment.
|
|
5
|
+
*
|
|
6
|
+
* currently does not resolve references and is only used for additional job-only-vars
|
|
7
|
+
* @param vars
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const transformJobOnlyVars: (env: string, componentName: string, vars: EnvVars | null) => Promise<EnvironmentEnvVars>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) {
|
|
15
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
16
|
+
resolve(value);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function rejected(value) {
|
|
28
|
+
try {
|
|
29
|
+
step(generator["throw"](value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function step(result) {
|
|
35
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
36
|
+
}
|
|
37
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
41
|
+
var _ = {
|
|
42
|
+
label: 0,
|
|
43
|
+
sent: function () {
|
|
44
|
+
if (t[0] & 1) throw t[1];
|
|
45
|
+
return t[1];
|
|
46
|
+
},
|
|
47
|
+
trys: [],
|
|
48
|
+
ops: []
|
|
49
|
+
},
|
|
50
|
+
f,
|
|
51
|
+
y,
|
|
52
|
+
t,
|
|
53
|
+
g;
|
|
54
|
+
return g = {
|
|
55
|
+
next: verb(0),
|
|
56
|
+
"throw": verb(1),
|
|
57
|
+
"return": verb(2)
|
|
58
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
59
|
+
return this;
|
|
60
|
+
}), g;
|
|
61
|
+
function verb(n) {
|
|
62
|
+
return function (v) {
|
|
63
|
+
return step([n, v]);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function step(op) {
|
|
67
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
68
|
+
while (_) try {
|
|
69
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
70
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
71
|
+
switch (op[0]) {
|
|
72
|
+
case 0:
|
|
73
|
+
case 1:
|
|
74
|
+
t = op;
|
|
75
|
+
break;
|
|
76
|
+
case 4:
|
|
77
|
+
_.label++;
|
|
78
|
+
return {
|
|
79
|
+
value: op[1],
|
|
80
|
+
done: false
|
|
81
|
+
};
|
|
82
|
+
case 5:
|
|
83
|
+
_.label++;
|
|
84
|
+
y = op[1];
|
|
85
|
+
op = [0];
|
|
86
|
+
continue;
|
|
87
|
+
case 7:
|
|
88
|
+
op = _.ops.pop();
|
|
89
|
+
_.trys.pop();
|
|
90
|
+
continue;
|
|
91
|
+
default:
|
|
92
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
93
|
+
_ = 0;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
97
|
+
_.label = op[1];
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
101
|
+
_.label = t[1];
|
|
102
|
+
t = op;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (t && _.label < t[2]) {
|
|
106
|
+
_.label = t[2];
|
|
107
|
+
_.ops.push(op);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
if (t[2]) _.ops.pop();
|
|
111
|
+
_.trys.pop();
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
op = body.call(thisArg, _);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
op = [6, e];
|
|
117
|
+
y = 0;
|
|
118
|
+
} finally {
|
|
119
|
+
f = t = 0;
|
|
120
|
+
}
|
|
121
|
+
if (op[0] & 5) throw op[1];
|
|
122
|
+
return {
|
|
123
|
+
value: op[0] ? op[1] : void 0,
|
|
124
|
+
done: true
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
exports.__esModule = true;
|
|
129
|
+
exports.transformJobOnlyVars = void 0;
|
|
130
|
+
var envVars_1 = require("./utils/envVars");
|
|
131
|
+
/**
|
|
132
|
+
* transform EnvVars for environment.
|
|
133
|
+
*
|
|
134
|
+
* currently does not resolve references and is only used for additional job-only-vars
|
|
135
|
+
* @param vars
|
|
136
|
+
* @returns
|
|
137
|
+
*/
|
|
138
|
+
var transformJobOnlyVars = function (env, componentName, vars) {
|
|
139
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
+
var publicVars, secretEnvVarKeys, deployJobOnlySecretEnvVars, envVars;
|
|
141
|
+
var _a, _b;
|
|
142
|
+
return __generator(this, function (_c) {
|
|
143
|
+
if (!vars) {
|
|
144
|
+
return [2 /*return*/, {
|
|
145
|
+
envVars: {},
|
|
146
|
+
secretEnvVarKeys: []
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
149
|
+
publicVars = (0, envVars_1.stringifyValues)((_a = vars === null || vars === void 0 ? void 0 : vars.public) !== null && _a !== void 0 ? _a : {});
|
|
150
|
+
secretEnvVarKeys = (0, envVars_1.stringListToSecreteEnvVarList)((_b = vars === null || vars === void 0 ? void 0 : vars.secret) !== null && _b !== void 0 ? _b : []);
|
|
151
|
+
deployJobOnlySecretEnvVars = (vars === null || vars === void 0 ? void 0 : vars.secret) ? (0, envVars_1.makeSecretEnvVarMapping)(env, componentName, secretEnvVarKeys) : {};
|
|
152
|
+
envVars = __assign(__assign({}, deployJobOnlySecretEnvVars), publicVars);
|
|
153
|
+
return [2 /*return*/, {
|
|
154
|
+
envVars: envVars,
|
|
155
|
+
secretEnvVarKeys: secretEnvVarKeys
|
|
156
|
+
}];
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
exports.transformJobOnlyVars = transformJobOnlyVars;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SecretEnvVar } from "../getEnvironmentVariables";
|
|
2
|
+
export declare const stringifyValues: (obj: Record<string, unknown>) => {
|
|
3
|
+
[k: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const stringListToSecreteEnvVarList: (keys: string[]) => SecretEnvVar[];
|
|
6
|
+
export declare const makeSecretEnvVarMapping: (env: string, componentName: string, secretEnvVars: SecretEnvVar[]) => {
|
|
7
|
+
[k: string]: string;
|
|
8
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __read = this && this.__read || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o),
|
|
7
|
+
r,
|
|
8
|
+
ar = [],
|
|
9
|
+
e;
|
|
10
|
+
try {
|
|
11
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
e = {
|
|
14
|
+
error: error
|
|
15
|
+
};
|
|
16
|
+
} finally {
|
|
17
|
+
try {
|
|
18
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
19
|
+
} finally {
|
|
20
|
+
if (e) throw e.error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
exports.__esModule = true;
|
|
26
|
+
exports.makeSecretEnvVarMapping = exports.stringListToSecreteEnvVarList = exports.stringifyValues = void 0;
|
|
27
|
+
var lodash_1 = require("lodash");
|
|
28
|
+
var getEnvironmentVariables_1 = require("../getEnvironmentVariables");
|
|
29
|
+
var stringifyValues = function (obj) {
|
|
30
|
+
return Object.fromEntries(Object.entries(obj).map(function (_a) {
|
|
31
|
+
var _b = __read(_a, 2),
|
|
32
|
+
key = _b[0],
|
|
33
|
+
value = _b[1];
|
|
34
|
+
return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
exports.stringifyValues = stringifyValues;
|
|
38
|
+
var stringListToSecreteEnvVarList = function (keys) {
|
|
39
|
+
return keys.map(function (key) {
|
|
40
|
+
return {
|
|
41
|
+
key: key
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
exports.stringListToSecreteEnvVarList = stringListToSecreteEnvVarList;
|
|
46
|
+
var makeSecretEnvVarMapping = function (env, componentName, secretEnvVars) {
|
|
47
|
+
return Object.fromEntries(secretEnvVars.map(function (_a) {
|
|
48
|
+
var key = _a.key;
|
|
49
|
+
return [key, "$".concat((0, getEnvironmentVariables_1.getSecretVarName)(env, componentName, key))];
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
exports.makeSecretEnvVarMapping = makeSecretEnvVarMapping;
|
package/dist/deploy/base.js
CHANGED
|
@@ -60,7 +60,7 @@ var getBaseDeploymentJob = function (context) {
|
|
|
60
60
|
}],
|
|
61
61
|
allow_failure: whenDeploy === "manual" ? true : false,
|
|
62
62
|
stage: "deploy",
|
|
63
|
-
variables: __assign(__assign(__assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.envVars), hasDocker ? (0, docker_1.getDockerImageVariables)(context) : {}), context.componentConfig.deploy ? (_d = context.componentConfig.deploy.extraVars) !== null && _d !== void 0 ? _d : {} : {}),
|
|
63
|
+
variables: __assign(__assign(__assign(__assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.envVars), hasDocker ? (0, docker_1.getDockerImageVariables)(context) : {}), context.environment.jobOnlyVars.deploy.envVars), context.componentConfig.deploy ? (_d = context.componentConfig.deploy.extraVars) !== null && _d !== void 0 ? _d : {} : {}),
|
|
64
64
|
environment: __assign(__assign({}, context.environment.gitlabEnvironment), isStoppable ? {
|
|
65
65
|
on_stop: exports.STOP_JOB_NAME,
|
|
66
66
|
auto_stop_in: autoStop
|
|
@@ -82,7 +82,7 @@ var getBaseDeploymentStopJob = function (context) {
|
|
|
82
82
|
when: "manual",
|
|
83
83
|
allow_failure: true
|
|
84
84
|
}],
|
|
85
|
-
variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), {
|
|
85
|
+
variables: __assign(__assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.jobOnlyVars.deploy.envVars), {
|
|
86
86
|
GIT_STRATEGY: "none"
|
|
87
87
|
}),
|
|
88
88
|
stage: "stop",
|
|
@@ -101,7 +101,7 @@ var getBaseRollbackJob = function (context) {
|
|
|
101
101
|
when: "manual",
|
|
102
102
|
allow_failure: true
|
|
103
103
|
}],
|
|
104
|
-
variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), {
|
|
104
|
+
variables: __assign(__assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.jobOnlyVars.deploy.envVars), {
|
|
105
105
|
GIT_STRATEGY: "none"
|
|
106
106
|
}),
|
|
107
107
|
stage: "rollback",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EnvVars } from "../../types/config";
|
|
1
2
|
export declare type DeployConfigBase = {
|
|
2
3
|
/**
|
|
3
4
|
* whether to deploy automatically or manual. If not defined, these rules apply:
|
|
@@ -14,8 +15,15 @@ export declare type DeployConfigBase = {
|
|
|
14
15
|
* tags for the underlying job runner (e.g gitlab)
|
|
15
16
|
*/
|
|
16
17
|
jobTags?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* vars that only exist in the deploy job.
|
|
20
|
+
* Can curently not reference other variables from other components
|
|
21
|
+
*/
|
|
22
|
+
jobVars?: EnvVars;
|
|
17
23
|
/**
|
|
18
24
|
* additional env vars for the deploy job
|
|
25
|
+
*
|
|
26
|
+
* @deprecated use deploy.jobVars for deploy job specific variables
|
|
19
27
|
*/
|
|
20
28
|
extraVars?: Record<string, string>;
|
|
21
29
|
};
|