@catladder/pipeline 1.41.2 → 1.41.4

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.
@@ -1,31 +1,194 @@
1
1
  "use strict";
2
2
 
3
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) {
5
+ return value instanceof P ? value : new P(function (resolve) {
6
+ resolve(value);
7
+ });
8
+ }
9
+
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) {
12
+ try {
13
+ step(generator.next(value));
14
+ } catch (e) {
15
+ reject(e);
16
+ }
17
+ }
18
+
19
+ function rejected(value) {
20
+ try {
21
+ step(generator["throw"](value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ }
26
+
27
+ function step(result) {
28
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
+ }
30
+
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+
35
+ var __generator = this && this.__generator || function (thisArg, body) {
36
+ var _ = {
37
+ label: 0,
38
+ sent: function () {
39
+ if (t[0] & 1) throw t[1];
40
+ return t[1];
41
+ },
42
+ trys: [],
43
+ ops: []
44
+ },
45
+ f,
46
+ y,
47
+ t,
48
+ g;
49
+ return g = {
50
+ next: verb(0),
51
+ "throw": verb(1),
52
+ "return": verb(2)
53
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
54
+ return this;
55
+ }), g;
56
+
57
+ function verb(n) {
58
+ return function (v) {
59
+ return step([n, v]);
60
+ };
61
+ }
62
+
63
+ function step(op) {
64
+ if (f) throw new TypeError("Generator is already executing.");
65
+
66
+ while (_) try {
67
+ 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;
68
+ if (y = 0, t) op = [op[0] & 2, t.value];
69
+
70
+ switch (op[0]) {
71
+ case 0:
72
+ case 1:
73
+ t = op;
74
+ break;
75
+
76
+ case 4:
77
+ _.label++;
78
+ return {
79
+ value: op[1],
80
+ done: false
81
+ };
82
+
83
+ case 5:
84
+ _.label++;
85
+ y = op[1];
86
+ op = [0];
87
+ continue;
88
+
89
+ case 7:
90
+ op = _.ops.pop();
91
+
92
+ _.trys.pop();
93
+
94
+ continue;
95
+
96
+ default:
97
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
98
+ _ = 0;
99
+ continue;
100
+ }
101
+
102
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
103
+ _.label = op[1];
104
+ break;
105
+ }
106
+
107
+ if (op[0] === 6 && _.label < t[1]) {
108
+ _.label = t[1];
109
+ t = op;
110
+ break;
111
+ }
112
+
113
+ if (t && _.label < t[2]) {
114
+ _.label = t[2];
115
+
116
+ _.ops.push(op);
117
+
118
+ break;
119
+ }
120
+
121
+ if (t[2]) _.ops.pop();
122
+
123
+ _.trys.pop();
124
+
125
+ continue;
126
+ }
127
+
128
+ op = body.call(thisArg, _);
129
+ } catch (e) {
130
+ op = [6, e];
131
+ y = 0;
132
+ } finally {
133
+ f = t = 0;
134
+ }
135
+
136
+ if (op[0] & 5) throw op[1];
137
+ return {
138
+ value: op[0] ? op[1] : void 0,
139
+ done: true
140
+ };
141
+ }
142
+ };
143
+
3
144
  exports.__esModule = true;
4
145
 
5
146
  var resolveReferences_1 = require("./resolveReferences");
6
147
 
7
148
  describe("resolveReferences", function () {
8
149
  it("replaces occurences of ${componentName:VARIABLE_NAME}", function () {
9
- var variables = {
10
- a: "hello world",
11
- b: "a replaced value looks like this: '${api:FOO}', nice!"
12
- };
13
- var otherVariables = {
14
- api: {
15
- FOO: "foo from api"
16
- },
17
- frontend: {
18
- FOO: "foo from frontend"
19
- }
20
- };
21
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
22
- var _a;
150
+ return __awaiter(void 0, void 0, void 0, function () {
151
+ var variables, otherVariables, result;
152
+ return __generator(this, function (_a) {
153
+ switch (_a.label) {
154
+ case 0:
155
+ variables = {
156
+ a: "hello world",
157
+ b: "a replaced value looks like this: '${api:FOO}', nice!"
158
+ };
159
+ otherVariables = {
160
+ api: {
161
+ FOO: "foo from api"
162
+ },
163
+ frontend: {
164
+ FOO: "foo from frontend"
165
+ }
166
+ };
167
+ return [4
168
+ /*yield*/
169
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
170
+ return __awaiter(void 0, void 0, void 0, function () {
171
+ var _a;
23
172
 
24
- return (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName];
25
- });
26
- expect(result).toEqual({
27
- a: "hello world",
28
- b: "a replaced value looks like this: 'foo from api', nice!"
173
+ return __generator(this, function (_b) {
174
+ return [2
175
+ /*return*/
176
+ , (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
177
+ });
178
+ });
179
+ })];
180
+
181
+ case 1:
182
+ result = _a.sent();
183
+ expect(result).toEqual({
184
+ a: "hello world",
185
+ b: "a replaced value looks like this: 'foo from api', nice!"
186
+ });
187
+ return [2
188
+ /*return*/
189
+ ];
190
+ }
191
+ });
29
192
  });
30
193
  });
31
194
  it("replaces self references with structure ${VARIABLE_NAME}", function () {
@@ -40,81 +203,169 @@ describe("resolveReferences", function () {
40
203
  });
41
204
  });
42
205
  it("replaces self references mixed with other vars", function () {
43
- var variables = {
44
- FOO: "hello from ${api:FOO}",
45
- BAR: "this: ${FOO}!"
46
- };
47
- var otherVariables = {
48
- api: {
49
- FOO: "foo from api"
50
- }
51
- };
52
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
53
- var _a;
206
+ return __awaiter(void 0, void 0, void 0, function () {
207
+ var variables, otherVariables, result;
208
+ return __generator(this, function (_a) {
209
+ switch (_a.label) {
210
+ case 0:
211
+ variables = {
212
+ FOO: "hello from ${api:FOO}",
213
+ BAR: "this: ${FOO}!"
214
+ };
215
+ otherVariables = {
216
+ api: {
217
+ FOO: "foo from api"
218
+ }
219
+ };
220
+ return [4
221
+ /*yield*/
222
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
223
+ return __awaiter(void 0, void 0, void 0, function () {
224
+ var _a;
54
225
 
55
- return (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName];
56
- });
57
- expect(result).toEqual({
58
- FOO: "hello from foo from api",
59
- BAR: "this: hello from foo from api!"
226
+ return __generator(this, function (_b) {
227
+ return [2
228
+ /*return*/
229
+ , (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
230
+ });
231
+ });
232
+ })];
233
+
234
+ case 1:
235
+ result = _a.sent();
236
+ expect(result).toEqual({
237
+ FOO: "hello from foo from api",
238
+ BAR: "this: hello from foo from api!"
239
+ });
240
+ return [2
241
+ /*return*/
242
+ ];
243
+ }
244
+ });
60
245
  });
61
246
  });
62
247
  it("keeps variables as is if not found (when null is returned)", function () {
63
- var variables = {
64
- a: "hello world",
65
- b: "a not found value looks like this: '${api:FOO}'"
66
- };
67
- var otherVariables = {};
68
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
69
- var _a;
248
+ return __awaiter(void 0, void 0, void 0, function () {
249
+ var variables, otherVariables, result;
250
+ return __generator(this, function (_a) {
251
+ switch (_a.label) {
252
+ case 0:
253
+ variables = {
254
+ a: "hello world",
255
+ b: "a not found value looks like this: '${api:FOO}'"
256
+ };
257
+ otherVariables = {};
258
+ return [4
259
+ /*yield*/
260
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
261
+ return __awaiter(void 0, void 0, void 0, function () {
262
+ var _a;
70
263
 
71
- return (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName];
72
- });
73
- expect(result).toEqual({
74
- a: "hello world",
75
- b: "a not found value looks like this: '${api:FOO}'"
264
+ return __generator(this, function (_b) {
265
+ return [2
266
+ /*return*/
267
+ , (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
268
+ });
269
+ });
270
+ })];
271
+
272
+ case 1:
273
+ result = _a.sent();
274
+ expect(result).toEqual({
275
+ a: "hello world",
276
+ b: "a not found value looks like this: '${api:FOO}'"
277
+ });
278
+ return [2
279
+ /*return*/
280
+ ];
281
+ }
282
+ });
76
283
  });
77
284
  });
78
285
  it("replaces mulitple levels deep", function () {
79
- var variables = {
80
- a: "value is ${frontend:FOO}!"
81
- };
82
- var otherVariables = {
83
- api: {
84
- FOO: "foo from api"
85
- },
86
- frontend: {
87
- FOO: "hi, ${api:FOO}"
88
- }
89
- };
90
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
91
- var _a, _b;
286
+ return __awaiter(void 0, void 0, void 0, function () {
287
+ var variables, otherVariables, result;
288
+ return __generator(this, function (_a) {
289
+ switch (_a.label) {
290
+ case 0:
291
+ variables = {
292
+ a: "value is ${frontend:FOO}!"
293
+ };
294
+ otherVariables = {
295
+ api: {
296
+ FOO: "foo from api"
297
+ },
298
+ frontend: {
299
+ FOO: "hi, ${api:FOO}"
300
+ }
301
+ };
302
+ return [4
303
+ /*yield*/
304
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
305
+ return __awaiter(void 0, void 0, void 0, function () {
306
+ var _a, _b;
92
307
 
93
- return (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : "";
94
- });
95
- expect(result).toEqual({
96
- a: "value is hi, foo from api!"
308
+ return __generator(this, function (_c) {
309
+ return [2
310
+ /*return*/
311
+ , (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : ""];
312
+ });
313
+ });
314
+ })];
315
+
316
+ case 1:
317
+ result = _a.sent();
318
+ expect(result).toEqual({
319
+ a: "value is hi, foo from api!"
320
+ });
321
+ return [2
322
+ /*return*/
323
+ ];
324
+ }
325
+ });
97
326
  });
98
327
  });
99
328
  it("prevents endless loops", function () {
100
- var variables = {
101
- a: "value is ${frontend:FOO}!"
102
- };
103
- var otherVariables = {
104
- api: {
105
- FOO: "api ${frontend:FOO}"
106
- },
107
- frontend: {
108
- FOO: "frontend ${api:FOO}"
109
- }
110
- };
111
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
112
- var _a, _b;
329
+ return __awaiter(void 0, void 0, void 0, function () {
330
+ var variables, otherVariables, result;
331
+ return __generator(this, function (_a) {
332
+ switch (_a.label) {
333
+ case 0:
334
+ variables = {
335
+ a: "value is ${frontend:FOO}!"
336
+ };
337
+ otherVariables = {
338
+ api: {
339
+ FOO: "api ${frontend:FOO}"
340
+ },
341
+ frontend: {
342
+ FOO: "frontend ${api:FOO}"
343
+ }
344
+ };
345
+ return [4
346
+ /*yield*/
347
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
348
+ return __awaiter(void 0, void 0, void 0, function () {
349
+ var _a, _b;
113
350
 
114
- return (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : "";
115
- });
116
- expect(result).toEqual({
117
- a: "value is frontend api ${frontend:FOO}!"
351
+ return __generator(this, function (_c) {
352
+ return [2
353
+ /*return*/
354
+ , (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : ""];
355
+ });
356
+ });
357
+ })];
358
+
359
+ case 1:
360
+ result = _a.sent();
361
+ expect(result).toEqual({
362
+ a: "value is frontend api ${frontend:FOO}!"
363
+ });
364
+ return [2
365
+ /*return*/
366
+ ];
367
+ }
368
+ });
118
369
  });
119
370
  });
120
371
  });
@@ -0,0 +1,8 @@
1
+ import type { Context } from "../../types";
2
+ export declare const hasCloudSQL: (context: Context) => boolean | undefined;
3
+ export declare const getCloudSQLConfig: (context: Context) => {
4
+ enabled: boolean;
5
+ instanceId?: string | undefined;
6
+ projectId?: string | undefined;
7
+ region?: string | undefined;
8
+ } | undefined;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getCloudSQLConfig = exports.hasCloudSQL = void 0;
5
+
6
+ var types_1 = require("../types");
7
+
8
+ var hasCloudSQL = function (context) {
9
+ var _a, _b;
10
+
11
+ if ((0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
12
+ return (_b = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.cloudsql) === null || _b === void 0 ? void 0 : _b.enabled;
13
+ }
14
+
15
+ return false;
16
+ };
17
+
18
+ exports.hasCloudSQL = hasCloudSQL;
19
+
20
+ var getCloudSQLConfig = function (context) {
21
+ var _a;
22
+
23
+ if ((0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
24
+ return (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.cloudsql;
25
+ }
26
+
27
+ throw new Error("cannot get cloud sql config");
28
+ };
29
+
30
+ exports.getCloudSQLConfig = getCloudSQLConfig;
@@ -9,5 +9,6 @@ export declare type DeployTypeDefinition<T extends DeployConfigType> = {
9
9
  defaults: () => Partial<DeployConfigGeneric<T>>;
10
10
  additionalSecretKeys: (config: DeployConfigGeneric<T>) => string[];
11
11
  };
12
+ export * from "./cloudSql";
12
13
  export declare type DeployTypes = { [T in DeployConfigType]: DeployTypeDefinition<T> };
13
14
  export declare const DEPLOY_TYPES: DeployTypes;
@@ -30,6 +30,8 @@ __exportStar(require("./types"), exports);
30
30
 
31
31
  __exportStar(require("./utils"), exports);
32
32
 
33
+ __exportStar(require("./cloudSql"), exports);
34
+
33
35
  exports.DEPLOY_TYPES = {
34
36
  kubernetes: kubernetes_1.KUBERNETES_DEPLOY_TYPE,
35
37
  custom: custom_1.CUSTOM_DEPLOY_TYPE
@@ -11,9 +11,9 @@ export declare const createKubeValues: (context: Context) => never[] | ({
11
11
  } & Record<string, unknown>)[] | undefined;
12
12
  hostAliases?: string[] | undefined;
13
13
  replicas?: number | undefined;
14
- autoscale?: import("..").KubernetesAutoscale | undefined;
15
- updateStrategy?: import("..").KubernetesUpdateStrategy | undefined;
16
- resources?: import("..").KubernetesResourcesDef | undefined;
14
+ autoscale?: import("../types").KubernetesAutoscale | undefined;
15
+ updateStrategy?: import("../types").KubernetesUpdateStrategy | undefined;
16
+ resources?: import("../types").KubernetesResourcesDef | undefined;
17
17
  healthRoute?: string | undefined;
18
18
  startupProbe?: {
19
19
  httpGet?: {
@@ -57,7 +57,7 @@ export declare const createKubeValues: (context: Context) => never[] | ({
57
57
  successThreshold?: number | undefined;
58
58
  } | undefined;
59
59
  } | undefined;
60
- worker?: import("..").KubernetesWorkerDef | undefined;
60
+ worker?: import("../types").KubernetesWorkerDef | undefined;
61
61
  } & Record<string, unknown>) | undefined;
62
62
  } & {
63
63
  [x: string]: unknown;
@@ -67,7 +67,7 @@ export declare const createKubeValues: (context: Context) => never[] | ({
67
67
  projectId?: string | undefined;
68
68
  region?: string | undefined;
69
69
  } | undefined;
70
- mongodb?: import("..").DeployConfigMongodb | undefined;
70
+ mongodb?: import("../types").DeployConfigMongodb | undefined;
71
71
  mailhog?: {
72
72
  enabled: boolean;
73
73
  } | undefined;
@@ -18,6 +18,8 @@ var lodash_1 = require("lodash");
18
18
 
19
19
  var utils_1 = require("../../utils");
20
20
 
21
+ var cloudSql_1 = require("../cloudSql");
22
+
21
23
  var types_1 = require("../types");
22
24
 
23
25
  var cloudsql_1 = require("./cloudsql");
@@ -61,7 +63,7 @@ var createAppConfig = function (context, application) {
61
63
  };
62
64
 
63
65
  var createKubeValues = function (context) {
64
- var _a, _b, _c, _d;
66
+ var _a, _b;
65
67
 
66
68
  var deployConfig = context.componentConfig.deploy;
67
69
 
@@ -78,15 +80,15 @@ var createKubeValues = function (context) {
78
80
  // we only merge the rest of the values in
79
81
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
80
82
 
81
- var _e = values !== null && values !== void 0 ? values : {},
82
- application = _e.application,
83
- rest = __rest(_e, ["application"]);
83
+ var _c = values !== null && values !== void 0 ? values : {},
84
+ application = _c.application,
85
+ rest = __rest(_c, ["application"]);
84
86
 
85
87
  var env = (0, kubeEnv_1.createKubeEnv)(context);
86
88
  var defaultKubeValues = (0, lodash_1.merge)({
87
89
  env: env,
88
90
  application: createAppConfig(context, application)
89
- }, ((_b = (_a = deployConfig.values) === null || _a === void 0 ? void 0 : _a.cloudsql) === null || _b === void 0 ? void 0 : _b.enabled) ? (0, cloudsql_1.createCloudsqlBaseConfig)(context) : {}, ((_d = (_c = deployConfig.values) === null || _c === void 0 ? void 0 : _c.mongodb) === null || _d === void 0 ? void 0 : _d.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
91
+ }, (0, cloudSql_1.hasCloudSQL)(context) ? (0, cloudsql_1.createCloudsqlBaseConfig)(context) : {}, ((_b = (_a = deployConfig.values) === null || _a === void 0 ? void 0 : _a.mongodb) === null || _b === void 0 ? void 0 : _b.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
90
92
  var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, rest));
91
93
  return kubeValues;
92
94
  };
@@ -367,23 +367,51 @@ var createJobs = function (type, envs, config, componentName, trigger) {
367
367
  return [2
368
368
  /*return*/
369
369
  , envs.reduce(function (acc, env) {
370
- var context = (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo);
371
- var jobs = addStageNeeds(createRawJobs(context));
372
-
373
- var result = __assign(__assign({}, acc), jobs.reduce(function (acc, job) {
374
- var _a;
375
-
376
- var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
377
- var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
378
-
379
- if (type === "gitlab") {
380
- return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
381
- }
382
-
383
- throw new Error("not supported");
384
- }, {}));
385
-
386
- return result;
370
+ return __awaiter(void 0, void 0, void 0, function () {
371
+ var context, jobs, result, _a, _b, _c, _d, _e;
372
+
373
+ return __generator(this, function (_f) {
374
+ switch (_f.label) {
375
+ case 0:
376
+ return [4
377
+ /*yield*/
378
+ , (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
379
+
380
+ case 1:
381
+ context = _f.sent();
382
+ jobs = addStageNeeds(createRawJobs(context));
383
+ _a = [{}];
384
+ return [4
385
+ /*yield*/
386
+ , acc];
387
+
388
+ case 2:
389
+ _b = [__assign.apply(void 0, _a.concat([_f.sent()]))];
390
+ _d = (_c = jobs).reduce;
391
+ _e = [function (acc, job) {
392
+ var _a;
393
+
394
+ var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
395
+ var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
396
+
397
+ if (type === "gitlab") {
398
+ return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
399
+ }
400
+
401
+ throw new Error("not supported");
402
+ }];
403
+ return [4
404
+ /*yield*/
405
+ , Promise.resolve({})];
406
+
407
+ case 3:
408
+ result = __assign.apply(void 0, _b.concat([_d.apply(_c, _e.concat([_f.sent()]))]));
409
+ return [2
410
+ /*return*/
411
+ , result];
412
+ }
413
+ });
414
+ });
387
415
  }, {})];
388
416
  }
389
417
  });