@catladder/pipeline 1.55.0 → 1.56.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/bin/catladder-gitlab-dev.js +3 -0
- package/dist/build/index.d.ts +2 -1
- package/dist/build/node/cache.js +8 -1
- package/dist/build/node/yarn.js +1 -1
- package/dist/build/types.d.ts +3 -0
- package/dist/bundles/catladder-gitlab/index.js +3 -3
- package/dist/constants.js +1 -1
- package/dist/context/getEnvConfig.d.ts +2 -0
- package/dist/context/getEnvConfig.js +26 -0
- package/dist/context/getEnvType.d.ts +4 -0
- package/dist/context/getEnvType.js +18 -0
- package/dist/context/getEnvironment.d.ts +2 -4
- package/dist/context/getEnvironment.js +15 -195
- package/dist/context/getEnvironmentContext.d.ts +4 -0
- package/dist/context/getEnvironmentContext.js +36 -0
- package/dist/context/getEnvironmentVariables.d.ts +10 -0
- package/dist/context/getEnvironmentVariables.js +322 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.js +12 -16
- package/dist/deploy/cloudRun/deployJob.js +19 -5
- package/dist/deploy/cloudRun/index.js +7 -7
- package/dist/deploy/index.d.ts +7 -20
- package/dist/deploy/index.js +4 -4
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -3
- package/dist/deploy/kubernetes/additionalSecretKeys.js +5 -5
- package/dist/deploy/kubernetes/index.js +2 -2
- package/dist/deploy/types/googleCloudRun.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/types/context.d.ts +6 -0
- package/dist/types/environmentContext.d.ts +22 -0
- package/dist/types/environmentContext.js +3 -0
- package/dist/utils/gitlab.d.ts +1 -0
- package/dist/utils/gitlab.js +46 -0
- package/examples/test.catladder.ts +26 -0
- package/package.json +1 -1
- package/src/build/index.ts +4 -1
- package/src/build/node/cache.ts +13 -5
- package/src/build/node/yarn.ts +1 -1
- package/src/build/types.ts +6 -0
- package/src/context/getEnvConfig.ts +21 -0
- package/src/context/getEnvType.ts +17 -0
- package/src/context/getEnvironment.ts +16 -164
- package/src/context/getEnvironmentContext.ts +57 -0
- package/src/context/getEnvironmentVariables.ts +152 -0
- package/src/context/index.ts +17 -14
- package/src/deploy/cloudRun/deployJob.ts +9 -5
- package/src/deploy/cloudRun/index.ts +5 -4
- package/src/deploy/index.ts +9 -21
- package/src/deploy/kubernetes/additionalSecretKeys.ts +7 -7
- package/src/deploy/kubernetes/index.ts +2 -2
- package/src/deploy/types/googleCloudRun.ts +1 -1
- package/src/types/config.ts +2 -0
- package/src/types/context.ts +8 -0
- package/src/types/environmentContext.ts +26 -0
- package/src/utils/gitlab.ts +5 -0
|
@@ -0,0 +1,322 @@
|
|
|
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
|
+
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) {
|
|
19
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
20
|
+
resolve(value);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25
|
+
function fulfilled(value) {
|
|
26
|
+
try {
|
|
27
|
+
step(generator.next(value));
|
|
28
|
+
} catch (e) {
|
|
29
|
+
reject(e);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function rejected(value) {
|
|
34
|
+
try {
|
|
35
|
+
step(generator["throw"](value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function step(result) {
|
|
42
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
50
|
+
var _ = {
|
|
51
|
+
label: 0,
|
|
52
|
+
sent: function () {
|
|
53
|
+
if (t[0] & 1) throw t[1];
|
|
54
|
+
return t[1];
|
|
55
|
+
},
|
|
56
|
+
trys: [],
|
|
57
|
+
ops: []
|
|
58
|
+
},
|
|
59
|
+
f,
|
|
60
|
+
y,
|
|
61
|
+
t,
|
|
62
|
+
g;
|
|
63
|
+
return g = {
|
|
64
|
+
next: verb(0),
|
|
65
|
+
"throw": verb(1),
|
|
66
|
+
"return": verb(2)
|
|
67
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
68
|
+
return this;
|
|
69
|
+
}), g;
|
|
70
|
+
|
|
71
|
+
function verb(n) {
|
|
72
|
+
return function (v) {
|
|
73
|
+
return step([n, v]);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function step(op) {
|
|
78
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
79
|
+
|
|
80
|
+
while (_) try {
|
|
81
|
+
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;
|
|
82
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
83
|
+
|
|
84
|
+
switch (op[0]) {
|
|
85
|
+
case 0:
|
|
86
|
+
case 1:
|
|
87
|
+
t = op;
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
case 4:
|
|
91
|
+
_.label++;
|
|
92
|
+
return {
|
|
93
|
+
value: op[1],
|
|
94
|
+
done: false
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
case 5:
|
|
98
|
+
_.label++;
|
|
99
|
+
y = op[1];
|
|
100
|
+
op = [0];
|
|
101
|
+
continue;
|
|
102
|
+
|
|
103
|
+
case 7:
|
|
104
|
+
op = _.ops.pop();
|
|
105
|
+
|
|
106
|
+
_.trys.pop();
|
|
107
|
+
|
|
108
|
+
continue;
|
|
109
|
+
|
|
110
|
+
default:
|
|
111
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
112
|
+
_ = 0;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
117
|
+
_.label = op[1];
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
122
|
+
_.label = t[1];
|
|
123
|
+
t = op;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (t && _.label < t[2]) {
|
|
128
|
+
_.label = t[2];
|
|
129
|
+
|
|
130
|
+
_.ops.push(op);
|
|
131
|
+
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (t[2]) _.ops.pop();
|
|
136
|
+
|
|
137
|
+
_.trys.pop();
|
|
138
|
+
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
op = body.call(thisArg, _);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
op = [6, e];
|
|
145
|
+
y = 0;
|
|
146
|
+
} finally {
|
|
147
|
+
f = t = 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (op[0] & 5) throw op[1];
|
|
151
|
+
return {
|
|
152
|
+
value: op[0] ? op[1] : void 0,
|
|
153
|
+
done: true
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
var __read = this && this.__read || function (o, n) {
|
|
159
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
160
|
+
if (!m) return o;
|
|
161
|
+
var i = m.call(o),
|
|
162
|
+
r,
|
|
163
|
+
ar = [],
|
|
164
|
+
e;
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
168
|
+
} catch (error) {
|
|
169
|
+
e = {
|
|
170
|
+
error: error
|
|
171
|
+
};
|
|
172
|
+
} finally {
|
|
173
|
+
try {
|
|
174
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
175
|
+
} finally {
|
|
176
|
+
if (e) throw e.error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return ar;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
184
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
185
|
+
if (ar || !(i in from)) {
|
|
186
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
187
|
+
ar[i] = from[i];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
exports.__esModule = true;
|
|
194
|
+
exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironmentVariables = void 0;
|
|
195
|
+
|
|
196
|
+
var lodash_1 = require("lodash");
|
|
197
|
+
|
|
198
|
+
var deploy_1 = require("../deploy");
|
|
199
|
+
|
|
200
|
+
var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
201
|
+
|
|
202
|
+
var resolveReferences_1 = require("./resolveReferences");
|
|
203
|
+
|
|
204
|
+
var getEnvironmentVariables = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
|
|
205
|
+
) {
|
|
206
|
+
if (alreadyVisited === void 0) {
|
|
207
|
+
alreadyVisited = {};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
211
|
+
var environmentContext, envConfigRaw, deployConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
|
|
212
|
+
|
|
213
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
214
|
+
|
|
215
|
+
return __generator(this, function (_k) {
|
|
216
|
+
switch (_k.label) {
|
|
217
|
+
case 0:
|
|
218
|
+
environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
|
|
219
|
+
envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, envType = environmentContext.envType;
|
|
220
|
+
basePredefinedVariables = {
|
|
221
|
+
ENV_SHORT: env,
|
|
222
|
+
APP_DIR: envConfigRaw.dir,
|
|
223
|
+
ENV_TYPE: envType
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
if (envType === "local") {
|
|
227
|
+
devLocalConfig = envConfigRaw;
|
|
228
|
+
port = (_a = devLocalConfig.port) !== null && _a !== void 0 ? _a : 3000;
|
|
229
|
+
host = "localhost:" + port;
|
|
230
|
+
url = "http://" + host;
|
|
231
|
+
predefinedVariables = {
|
|
232
|
+
ENV_SHORT: "local",
|
|
233
|
+
ROOT_URL: url,
|
|
234
|
+
PORT: port.toString()
|
|
235
|
+
};
|
|
236
|
+
} else {
|
|
237
|
+
additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
|
|
238
|
+
host = (_c = (_b = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _b !== void 0 ? _b : additionalEnvVars.HOST_CANONICAL) !== null && _c !== void 0 ? _c : "unknown-host.example.com";
|
|
239
|
+
url = "https://".concat(host);
|
|
240
|
+
predefinedVariables = __assign(__assign(__assign({}, basePredefinedVariables), {
|
|
241
|
+
HOST: host,
|
|
242
|
+
ROOT_URL: url
|
|
243
|
+
}), additionalEnvVars);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
publicEnvVarsRaw = (_e = (_d = envConfigRaw.vars) === null || _d === void 0 ? void 0 : _d.public) !== null && _e !== void 0 ? _e : {};
|
|
247
|
+
additionalSecretKeys = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(environmentContext) : [];
|
|
248
|
+
secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.secret) !== null && _g !== void 0 ? _g : []), false), __read(additionalSecretKeys), false);
|
|
249
|
+
secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
|
|
250
|
+
return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
|
|
251
|
+
}));
|
|
252
|
+
legacyFromComponents = (_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.fromComponents) !== null && _j !== void 0 ? _j : {};
|
|
253
|
+
publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
|
|
254
|
+
publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
|
|
255
|
+
var _b = __read(_a, 2),
|
|
256
|
+
key = _b[0],
|
|
257
|
+
value = _b[1];
|
|
258
|
+
|
|
259
|
+
return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
|
|
260
|
+
}));
|
|
261
|
+
envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
|
|
262
|
+
return [4
|
|
263
|
+
/*yield*/
|
|
264
|
+
, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, variableName, alreadyVisited) {
|
|
265
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
266
|
+
var otherEnvVars;
|
|
267
|
+
return __generator(this, function (_a) {
|
|
268
|
+
switch (_a.label) {
|
|
269
|
+
case 0:
|
|
270
|
+
return [4
|
|
271
|
+
/*yield*/
|
|
272
|
+
, (0, exports.getEnvironmentVariables)(config, otherComponentName, env, commitInfo, alreadyVisited)];
|
|
273
|
+
|
|
274
|
+
case 1:
|
|
275
|
+
otherEnvVars = _a.sent().envVars;
|
|
276
|
+
return [2
|
|
277
|
+
/*return*/
|
|
278
|
+
, otherEnvVars[variableName]];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
}, alreadyVisited)];
|
|
283
|
+
|
|
284
|
+
case 1:
|
|
285
|
+
envVars = _k.sent();
|
|
286
|
+
return [2
|
|
287
|
+
/*return*/
|
|
288
|
+
, {
|
|
289
|
+
envVars: envVars,
|
|
290
|
+
secretEnvVarKeys: secretEnvVarKeys,
|
|
291
|
+
host: host,
|
|
292
|
+
url: url
|
|
293
|
+
}];
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
exports.getEnvironmentVariables = getEnvironmentVariables;
|
|
300
|
+
|
|
301
|
+
var sanitizeForEnVar = function (s) {
|
|
302
|
+
return s.replace(/-/g, "_");
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
var getSecretVarName = function (env, componentName, key) {
|
|
306
|
+
return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
|
|
307
|
+
}; // remove dash from component name
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
exports.getSecretVarName = getSecretVarName;
|
|
311
|
+
|
|
312
|
+
var addIndexVar = function (vars) {
|
|
313
|
+
return __assign(__assign({}, vars), {
|
|
314
|
+
_ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
var getSecretVarNameForContext = function (context, key) {
|
|
319
|
+
return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
exports.getSecretVarNameForContext = getSecretVarNameForContext;
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Config } from "../types/config";
|
|
2
2
|
import type { CommitInfo, Context } from "../types/context";
|
|
3
3
|
export * from "./getEnvironment";
|
|
4
|
+
export * from "./getEnvironmentVariables";
|
|
4
5
|
export declare const createContext: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, packageManagerInfo?: import("../types/context").YarnPackageManagerInfo | undefined) => Promise<Context>;
|
package/dist/context/index.js
CHANGED
|
@@ -169,34 +169,30 @@ var utils_1 = require("../utils");
|
|
|
169
169
|
|
|
170
170
|
var getEnvironment_1 = require("./getEnvironment");
|
|
171
171
|
|
|
172
|
+
var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
173
|
+
|
|
172
174
|
__exportStar(require("./getEnvironment"), exports);
|
|
173
175
|
|
|
176
|
+
__exportStar(require("./getEnvironmentVariables"), exports);
|
|
177
|
+
|
|
174
178
|
var createContext = function (config, componentName, env, commitInfo, packageManagerInfo) {
|
|
175
179
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
176
|
-
var
|
|
180
|
+
var envContext, componentConfigWithoutDefaults, defaults, componentConfig;
|
|
177
181
|
|
|
178
182
|
var _a;
|
|
179
183
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return __generator(this, function (_d) {
|
|
183
|
-
switch (_d.label) {
|
|
184
|
+
return __generator(this, function (_b) {
|
|
185
|
+
switch (_b.label) {
|
|
184
186
|
case 0:
|
|
185
187
|
if (!/^[a-z0-9-]+$/.test(componentName)) {
|
|
186
188
|
throw new Error("componentName may only contain lower case letters, numbers and -");
|
|
187
189
|
}
|
|
188
190
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (!rawConfig) {
|
|
192
|
-
throw new Error("unknown component " + componentName);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
envConfig = (_c = (_b = rawConfig.env) === null || _b === void 0 ? void 0 : _b[env]) !== null && _c !== void 0 ? _c : {};
|
|
196
|
-
componentConfigWithoutDefaults = (0, utils_1.mergeWithMergingArrays)(rawConfig, envConfig);
|
|
191
|
+
envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
|
|
192
|
+
componentConfigWithoutDefaults = envContext.envConfigRaw;
|
|
197
193
|
defaults = componentConfigWithoutDefaults.deploy ? {
|
|
198
|
-
build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(),
|
|
199
|
-
deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults()
|
|
194
|
+
build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(envContext),
|
|
195
|
+
deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults(envContext)
|
|
200
196
|
} : {
|
|
201
197
|
build: {},
|
|
202
198
|
deploy: {}
|
|
@@ -214,7 +210,7 @@ var createContext = function (config, componentName, env, commitInfo, packageMan
|
|
|
214
210
|
case 1:
|
|
215
211
|
return [2
|
|
216
212
|
/*return*/
|
|
217
|
-
, (_a.environment =
|
|
213
|
+
, (_a.environment = _b.sent(), _a.commitInfo = commitInfo, _a.packageManagerInfo = packageManagerInfo, _a)];
|
|
218
214
|
}
|
|
219
215
|
});
|
|
220
216
|
});
|
|
@@ -56,6 +56,8 @@ var types_1 = require("../types");
|
|
|
56
56
|
|
|
57
57
|
var gcloudServiceAccountLoginCommands_1 = require("./utils/gcloudServiceAccountLoginCommands");
|
|
58
58
|
|
|
59
|
+
var gitlab_1 = require("../../utils/gitlab");
|
|
60
|
+
|
|
59
61
|
var createGoogleCloudRunDeployJobs = function (context) {
|
|
60
62
|
var _a, _b;
|
|
61
63
|
|
|
@@ -97,12 +99,12 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
97
99
|
return "gcloud run deploy ".concat(serviceName, " ").concat(commandArg, " ").concat(commonDeployArgs, " --env-vars-file=____envvars.yaml --allow-unauthenticated");
|
|
98
100
|
};
|
|
99
101
|
|
|
100
|
-
var
|
|
102
|
+
var getJobCreateScripts = function (jobName, job) {
|
|
101
103
|
// due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
|
|
102
104
|
// lucky, update on the other hand accepts it... so let's just imediatly update it
|
|
103
105
|
// also we cannot upsert a job, so we have to create it and catch the error and then update
|
|
104
106
|
var args = "".concat(jobName, " --command=\"").concat(job.command.split(" ").join(","), "\" ").concat(commonDeployArgs);
|
|
105
|
-
return [
|
|
107
|
+
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["gcloud beta run jobs create ".concat(args)])), false), ["gcloud beta run jobs update ".concat(args, " --env-vars-file=____envvars.yaml")], false);
|
|
106
108
|
};
|
|
107
109
|
|
|
108
110
|
var getJobRunScript = function (jobName) {
|
|
@@ -121,13 +123,25 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
121
123
|
return [getFullJobName(name), job];
|
|
122
124
|
});
|
|
123
125
|
|
|
124
|
-
var cloudRunDeployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(jobsWithNames.map(function (_a) {
|
|
126
|
+
var cloudRunDeployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml", "cat ____envvars.yaml"], __read(jobsWithNames.map(function (_a) {
|
|
127
|
+
var _b = __read(_a, 2),
|
|
128
|
+
name = _b[0],
|
|
129
|
+
job = _b[1];
|
|
130
|
+
|
|
131
|
+
return getJobCreateScripts(name, job);
|
|
132
|
+
}).flat()), false), __read(jobsWithNames.filter(function (_a) {
|
|
125
133
|
var _b = __read(_a, 2),
|
|
126
134
|
name = _b[0],
|
|
127
135
|
job = _b[1];
|
|
128
136
|
|
|
129
|
-
return
|
|
130
|
-
}).
|
|
137
|
+
return job.when === "preDeploy";
|
|
138
|
+
}).map(function (_a) {
|
|
139
|
+
var _b = __read(_a, 2),
|
|
140
|
+
name = _b[0],
|
|
141
|
+
job = _b[1];
|
|
142
|
+
|
|
143
|
+
return getJobRunScript(name);
|
|
144
|
+
})), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(jobsWithNames.filter(function (_a) {
|
|
131
145
|
var _b = __read(_a, 2),
|
|
132
146
|
name = _b[0],
|
|
133
147
|
job = _b[1];
|
|
@@ -56,18 +56,18 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
|
|
|
56
56
|
additionalSecretKeys: function () {
|
|
57
57
|
return [exports.GCLOUD_DEPLOY_CREDENTIALS_KEY];
|
|
58
58
|
},
|
|
59
|
-
getAdditionalEnvVars: function (
|
|
60
|
-
var fullName =
|
|
61
|
-
env =
|
|
62
|
-
componentName =
|
|
63
|
-
|
|
59
|
+
getAdditionalEnvVars: function (ctx) {
|
|
60
|
+
var fullName = ctx.fullName,
|
|
61
|
+
env = ctx.env,
|
|
62
|
+
componentName = ctx.componentName,
|
|
63
|
+
deployConfigRaw = ctx.deployConfigRaw;
|
|
64
64
|
var HOST_CANONICAL = fullName.toLowerCase() + "-" + process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)];
|
|
65
|
-
var jobTriggers =
|
|
65
|
+
var jobTriggers = deployConfigRaw && deployConfigRaw.jobs ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(function (_a) {
|
|
66
66
|
var _b = __read(_a, 2),
|
|
67
67
|
name = _b[0],
|
|
68
68
|
job = _b[1];
|
|
69
69
|
|
|
70
|
-
return ["CLOUD_RUN_JOB_TRIGGER_URL_" + name, "https://".concat(
|
|
70
|
+
return ["CLOUD_RUN_JOB_TRIGGER_URL_" + name, "https://".concat(deployConfigRaw.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfigRaw.projectId, "/jobs/").concat(name, ":run")];
|
|
71
71
|
})) : {};
|
|
72
72
|
return __assign({
|
|
73
73
|
HOST_CANONICAL: HOST_CANONICAL
|
package/dist/deploy/index.d.ts
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Context } from "../types/context";
|
|
2
|
+
import type { EnvironmentContext } from "../types/environmentContext";
|
|
3
3
|
import type { CatladderJob } from "../types/jobs";
|
|
4
4
|
import type { DeployConfigGeneric, DeployConfigType } from "./types";
|
|
5
|
+
export * from "./cloudRun";
|
|
6
|
+
export * from "./cloudSql";
|
|
5
7
|
export * from "./kubernetes";
|
|
6
8
|
export * from "./types";
|
|
7
9
|
export * from "./utils";
|
|
8
|
-
export declare type EnvVarContext<D extends DeployConfigType> = {
|
|
9
|
-
deployConfig: false | DeployConfigGeneric<D>;
|
|
10
|
-
commitInfo?: CommitInfo;
|
|
11
|
-
env: string;
|
|
12
|
-
envType: EnvType;
|
|
13
|
-
componentName: string;
|
|
14
|
-
fullName: string;
|
|
15
|
-
/**
|
|
16
|
-
* the full catladder config
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
fullConfig: Config;
|
|
20
|
-
};
|
|
21
10
|
export declare type DeployTypeDefinition<T extends DeployConfigType> = {
|
|
22
11
|
jobs: (context: Context) => CatladderJob[];
|
|
23
|
-
defaults: () => Partial<DeployConfigGeneric<T>>;
|
|
24
|
-
additionalSecretKeys: (
|
|
25
|
-
getAdditionalEnvVars: (
|
|
12
|
+
defaults: (envContext: EnvironmentContext<any, T>) => Partial<DeployConfigGeneric<T>>;
|
|
13
|
+
additionalSecretKeys: (envContext: EnvironmentContext<any, T>) => string[];
|
|
14
|
+
getAdditionalEnvVars: (envContext: EnvironmentContext<any, T>) => Record<string, string | undefined | null>;
|
|
26
15
|
};
|
|
27
|
-
export * from "./cloudSql";
|
|
28
|
-
export * from "./cloudRun";
|
|
29
16
|
export declare type DeployTypes = { [T in DeployConfigType]: DeployTypeDefinition<T> };
|
|
30
17
|
export declare const DEPLOY_TYPES: DeployTypes;
|
package/dist/deploy/index.js
CHANGED
|
@@ -28,16 +28,16 @@ var dockerTag_1 = require("./dockerTag");
|
|
|
28
28
|
|
|
29
29
|
var kubernetes_1 = require("./kubernetes");
|
|
30
30
|
|
|
31
|
+
__exportStar(require("./cloudRun"), exports);
|
|
32
|
+
|
|
33
|
+
__exportStar(require("./cloudSql"), exports);
|
|
34
|
+
|
|
31
35
|
__exportStar(require("./kubernetes"), exports);
|
|
32
36
|
|
|
33
37
|
__exportStar(require("./types"), exports);
|
|
34
38
|
|
|
35
39
|
__exportStar(require("./utils"), exports);
|
|
36
40
|
|
|
37
|
-
__exportStar(require("./cloudSql"), exports);
|
|
38
|
-
|
|
39
|
-
__exportStar(require("./cloudRun"), exports);
|
|
40
|
-
|
|
41
41
|
exports.DEPLOY_TYPES = {
|
|
42
42
|
kubernetes: kubernetes_1.KUBERNETES_DEPLOY_TYPE,
|
|
43
43
|
custom: custom_1.CUSTOM_DEPLOY_TYPE,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EnvironmentContext } from "../../types/environmentContext";
|
|
2
2
|
export declare const additionalKubernetesSecretKeys: ({
|
|
3
|
-
|
|
4
|
-
}:
|
|
3
|
+
deployConfigRaw
|
|
4
|
+
}: EnvironmentContext<any, "kubernetes">) => string[];
|
|
@@ -6,23 +6,23 @@ exports.additionalKubernetesSecretKeys = void 0;
|
|
|
6
6
|
var additionalKubernetesSecretKeys = function (_a) {
|
|
7
7
|
var _b, _c, _d, _e;
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var deployConfigRaw = _a.deployConfigRaw;
|
|
10
10
|
|
|
11
|
-
if (!
|
|
11
|
+
if (!deployConfigRaw) {
|
|
12
12
|
return [];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
var keys = [];
|
|
16
16
|
|
|
17
|
-
if ((_c = (_b =
|
|
17
|
+
if ((_c = (_b = deployConfigRaw.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) {
|
|
18
18
|
keys.push("MONGODB_ROOT_PASSWORD");
|
|
19
19
|
|
|
20
|
-
if (
|
|
20
|
+
if (deployConfigRaw.values.mongodb.architecture === "replicaset") {
|
|
21
21
|
keys.push("MONGODB_REPLICASET_KEY");
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
if ((_e = (_d =
|
|
25
|
+
if ((_e = (_d = deployConfigRaw.values) === null || _d === void 0 ? void 0 : _d.cloudsql) === null || _e === void 0 ? void 0 : _e.enabled) {
|
|
26
26
|
keys.push("POSTGRESQL_PASSWORD");
|
|
27
27
|
keys.push("cloudsqlProxyCredentials");
|
|
28
28
|
}
|
|
@@ -28,7 +28,7 @@ exports.KUBERNETES_DEPLOY_TYPE = {
|
|
|
28
28
|
|
|
29
29
|
var componentName = _a.componentName,
|
|
30
30
|
fullConfig = _a.fullConfig,
|
|
31
|
-
|
|
31
|
+
deployConfigRaw = _a.deployConfigRaw,
|
|
32
32
|
env = _a.env,
|
|
33
33
|
envType = _a.envType,
|
|
34
34
|
commitInfo = _a.commitInfo;
|
|
@@ -37,7 +37,7 @@ exports.KUBERNETES_DEPLOY_TYPE = {
|
|
|
37
37
|
var KUBE_NAMESPACE = (0, __1.getKubernetesNamespace)(fullConfig, env);
|
|
38
38
|
var componentSlug = (0, slugify_1["default"])(componentName);
|
|
39
39
|
var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
|
|
40
|
-
var domainCanonical =
|
|
40
|
+
var domainCanonical = deployConfigRaw && ((_b = deployConfigRaw.cluster) === null || _b === void 0 ? void 0 : _b.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
|
|
41
41
|
fullConfig.domainCanonical || "panter.cloud";
|
|
42
42
|
var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(fullConfig.appName, ".").concat(fullConfig.customerName, ".").concat(domainCanonical); // default for kubernetes and rest
|
|
43
43
|
|