@catladder/pipeline 1.150.2 → 1.150.3
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/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/context/createComponentContext.js +1 -0
- package/dist/pipeline/createAllJobs.d.ts +6 -6
- package/dist/pipeline/createAllJobs.js +7 -24
- package/dist/pipeline/createMainPipeline.js +2 -2
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +5 -6
- package/dist/pipeline/gitlab/createGitlabJobs.js +31 -29
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/context.d.ts +3 -5
- package/package.json +1 -1
- package/src/context/createComponentContext.ts +1 -0
- package/src/pipeline/createAllJobs.ts +9 -19
- package/src/pipeline/createMainPipeline.ts +6 -2
- package/src/pipeline/gitlab/createGitlabJobs.ts +47 -46
- package/src/types/context.ts +1 -4
package/dist/constants.js
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
7
|
-
exports.PIPELINE_IMAGE_TAG = "v1-150-
|
|
7
|
+
exports.PIPELINE_IMAGE_TAG = "v1-150-3-6b689f25" || "latest";
|
|
8
8
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
import type { ComponentContext, Config, PipelineTrigger, PipelineType } from "../types";
|
|
2
|
+
import type { CatladderJob } from "../types/jobs";
|
|
3
|
+
export type AllCatladderJobs = Array<{
|
|
4
|
+
context: ComponentContext;
|
|
5
|
+
jobs: Array<CatladderJob>;
|
|
6
|
+
}>;
|
|
7
7
|
export type AllJobsContext = {
|
|
8
8
|
config: Config;
|
|
9
9
|
trigger: PipelineTrigger;
|
|
@@ -1,15 +1,5 @@
|
|
|
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
|
-
};
|
|
13
3
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
14
4
|
function adopt(value) {
|
|
15
5
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -189,20 +179,13 @@ var createAllJobs = function (_a) {
|
|
|
189
179
|
})];
|
|
190
180
|
case 1:
|
|
191
181
|
allComponentContext = _c.sent();
|
|
192
|
-
return [2 /*return*/, allComponentContext.
|
|
193
|
-
var
|
|
194
|
-
|
|
195
|
-
context
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
acc[componentName][env] = (0, createJobsForComponent_1.createJobsForComponentContext)(context).map(function (job) {
|
|
200
|
-
return __assign(__assign({}, job), {
|
|
201
|
-
context: context
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
return acc;
|
|
205
|
-
}, {})];
|
|
182
|
+
return [2 /*return*/, allComponentContext.map(function (_a) {
|
|
183
|
+
var context = _a.context;
|
|
184
|
+
return {
|
|
185
|
+
context: context,
|
|
186
|
+
jobs: (0, createJobsForComponent_1.createJobsForComponentContext)(context)
|
|
187
|
+
};
|
|
188
|
+
})];
|
|
206
189
|
}
|
|
207
190
|
});
|
|
208
191
|
});
|
|
@@ -203,10 +203,10 @@ var createMainPipeline = function (pipelineType, config) {
|
|
|
203
203
|
.sort(function (a, b) {
|
|
204
204
|
var componentNames = Object.keys(config.components);
|
|
205
205
|
var aIndex = componentNames.findIndex(function (c) {
|
|
206
|
-
return c === a.componentName;
|
|
206
|
+
return c === a.context.componentName;
|
|
207
207
|
});
|
|
208
208
|
var bIndex = componentNames.findIndex(function (c) {
|
|
209
|
-
return c === b.componentName;
|
|
209
|
+
return c === b.context.componentName;
|
|
210
210
|
});
|
|
211
211
|
return aIndex - bIndex;
|
|
212
212
|
}).reduce(function (acc, _a) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext, GitlabJobDef, GitlabRule } from "../../types";
|
|
2
|
+
import type { CatladderJob } from "../../types/jobs";
|
|
2
3
|
import type { AllCatladderJobs } from "../createAllJobs";
|
|
3
4
|
export type AllGitlabJobs = {
|
|
4
5
|
name: string;
|
|
5
6
|
gitlabJob: GitlabJobDef;
|
|
6
|
-
|
|
7
|
-
env: string;
|
|
7
|
+
context: ComponentContext;
|
|
8
8
|
}[];
|
|
9
9
|
export declare const GITLAB_ENVIRONMENT_URL_VARIABLE = "CL_GITLAB_ENVIRONMENT_URL";
|
|
10
|
-
export declare const makeGitlabJob: (
|
|
10
|
+
export declare const makeGitlabJob: (context: ComponentContext, {
|
|
11
11
|
environment,
|
|
12
12
|
envMode,
|
|
13
13
|
needsStages,
|
|
@@ -16,10 +16,9 @@ export declare const makeGitlabJob: (componentName: string, env: string, {
|
|
|
16
16
|
needs,
|
|
17
17
|
jobTags,
|
|
18
18
|
script,
|
|
19
|
-
context,
|
|
20
19
|
variables,
|
|
21
20
|
runnerVariables,
|
|
22
21
|
when,
|
|
23
22
|
...job
|
|
24
|
-
}:
|
|
23
|
+
}: CatladderJob<string>, allJobs: AllCatladderJobs, baseRules?: GitlabRule[]) => [fullName: string, job: GitlabJobDef];
|
|
25
24
|
export declare const createGitlabJobs: (allJobs: AllCatladderJobs, baseRules?: GitlabRule[]) => Promise<AllGitlabJobs>;
|
|
@@ -183,7 +183,9 @@ var getFullJobName = function (name, componentName, env) {
|
|
|
183
183
|
};
|
|
184
184
|
var getFullReferencedJobName = function (referencedJobName, componentName, env, allJobs) {
|
|
185
185
|
var _a, _b;
|
|
186
|
-
var referencedJob = (_b = (_a = allJobs
|
|
186
|
+
var referencedJob = (_b = (_a = allJobs.find(function (j) {
|
|
187
|
+
return j.context.componentName === componentName && j.context.env === env;
|
|
188
|
+
})) === null || _a === void 0 ? void 0 : _a.jobs) === null || _b === void 0 ? void 0 : _b.find(function (j) {
|
|
187
189
|
return j.name === referencedJobName;
|
|
188
190
|
});
|
|
189
191
|
if (!referencedJob) {
|
|
@@ -195,7 +197,7 @@ var getFullReferencedJobName = function (referencedJobName, componentName, env,
|
|
|
195
197
|
var getJobName = function (need) {
|
|
196
198
|
return (0, lodash_1.isObject)(need) ? need.job : need;
|
|
197
199
|
};
|
|
198
|
-
var makeGitlabJob = function (
|
|
200
|
+
var makeGitlabJob = function (context, _a, allJobs, baseRules) {
|
|
199
201
|
var _b, _c;
|
|
200
202
|
var environment = _a.environment,
|
|
201
203
|
envMode = _a.envMode,
|
|
@@ -205,20 +207,23 @@ var makeGitlabJob = function (componentName, env, _a, allJobs, baseRules) {
|
|
|
205
207
|
needs = _a.needs,
|
|
206
208
|
jobTags = _a.jobTags,
|
|
207
209
|
script = _a.script,
|
|
208
|
-
context = _a.context,
|
|
209
210
|
variables = _a.variables,
|
|
210
211
|
runnerVariables = _a.runnerVariables,
|
|
211
212
|
when = _a.when,
|
|
212
|
-
job = __rest(_a, ["environment", "envMode", "needsStages", "needsOtherComponent", "name", "needs", "jobTags", "script", "
|
|
213
|
-
var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
|
|
213
|
+
job = __rest(_a, ["environment", "envMode", "needsStages", "needsOtherComponent", "name", "needs", "jobTags", "script", "variables", "runnerVariables", "when"]);
|
|
214
|
+
var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(context.env) : job.stage;
|
|
214
215
|
var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
|
|
215
|
-
var _a, _b, _c
|
|
216
|
-
var referencedComponentName = componentName;
|
|
217
|
-
var allJobNamesFromThatStage = (
|
|
216
|
+
var _a, _b, _c;
|
|
217
|
+
var referencedComponentName = context.componentName;
|
|
218
|
+
var allJobNamesFromThatStage = (_c = (_b = (_a = allJobs.filter(function (j) {
|
|
219
|
+
return j.context.componentName === referencedComponentName && j.context.env === context.env;
|
|
220
|
+
}).flatMap(function (j) {
|
|
221
|
+
return j.jobs;
|
|
222
|
+
})) === null || _a === void 0 ? void 0 : _a.filter(function (j) {
|
|
218
223
|
return j.stage === n.stage;
|
|
219
|
-
})) === null ||
|
|
224
|
+
})) === null || _b === void 0 ? void 0 : _b.map(function (j) {
|
|
220
225
|
return j.name;
|
|
221
|
-
})) !== null &&
|
|
226
|
+
})) !== null && _c !== void 0 ? _c : [];
|
|
222
227
|
return allJobNamesFromThatStage.map(function (job) {
|
|
223
228
|
var _a;
|
|
224
229
|
return {
|
|
@@ -232,16 +237,16 @@ var makeGitlabJob = function (componentName, env, _a, allJobs, baseRules) {
|
|
|
232
237
|
var gitlabNeeds = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
|
|
233
238
|
var _a;
|
|
234
239
|
return (0, lodash_1.isObject)(n) ? {
|
|
235
|
-
job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allJobs),
|
|
240
|
+
job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : context.componentName, context.env, allJobs),
|
|
236
241
|
artifacts: n.artifacts
|
|
237
|
-
} : getFullReferencedJobName(n, componentName, env, allJobs);
|
|
242
|
+
} : getFullReferencedJobName(n, context.componentName, context.env, allJobs);
|
|
238
243
|
}).sort(function (a, b) {
|
|
239
244
|
return getJobName(a).localeCompare(getJobName(b));
|
|
240
245
|
});
|
|
241
246
|
var deduplicatedGitlabNeeds = __spreadArray([], __read(new Map(gitlabNeeds.map(function (n) {
|
|
242
247
|
return [(0, lodash_1.isObject)(n) ? n.job : n, n];
|
|
243
248
|
})).values()), false);
|
|
244
|
-
var fullJobName = getFullJobName(name, componentName, envMode !== "none" ? env : undefined);
|
|
249
|
+
var fullJobName = getFullJobName(name, context.componentName, envMode !== "none" ? context.env : undefined);
|
|
245
250
|
// backwards compatibility, some may still use KUBERNETES_CPU_REQUEST, KUBERNETES_MEMORY_REQUEST, etc. in variables.
|
|
246
251
|
// those should now be set in the runnerVariables as they don't work in the variables key of the catladder job, becuase those get injected
|
|
247
252
|
var PIPELINE_RUNNER_VARIABLES = ["KUBERNETES_CPU_REQUEST", "KUBERNETES_MEMORY_REQUEST", "KUBERNETES_CPU_LIMIT", "KUBERNETES_MEMORY_LIMIT"];
|
|
@@ -278,7 +283,7 @@ var makeGitlabJob = function (componentName, env, _a, allJobs, baseRules) {
|
|
|
278
283
|
needs: deduplicatedGitlabNeeds,
|
|
279
284
|
retry: defaults_1.BASE_RETRY,
|
|
280
285
|
interruptible: true
|
|
281
|
-
}), componentName, env, allJobs);
|
|
286
|
+
}), context.componentName, context.env, allJobs);
|
|
282
287
|
return [fullJobName, (0, removeUndefined_1.removeUndefined)(modified)];
|
|
283
288
|
};
|
|
284
289
|
exports.makeGitlabJob = makeGitlabJob;
|
|
@@ -318,21 +323,18 @@ allJobs) {
|
|
|
318
323
|
var createGitlabJobs = function (allJobs, baseRules) {
|
|
319
324
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
320
325
|
return __generator(this, function (_a) {
|
|
321
|
-
return [2 /*return*/,
|
|
322
|
-
var
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
env: env
|
|
334
|
-
};
|
|
335
|
-
});
|
|
326
|
+
return [2 /*return*/, allJobs.flatMap(function (_a) {
|
|
327
|
+
var context = _a.context,
|
|
328
|
+
jobs = _a.jobs;
|
|
329
|
+
return jobs.map(function (job) {
|
|
330
|
+
var _a = __read((0, exports.makeGitlabJob)(context, job, allJobs, baseRules), 2),
|
|
331
|
+
fullJobName = _a[0],
|
|
332
|
+
gitlabJob = _a[1];
|
|
333
|
+
return {
|
|
334
|
+
name: fullJobName,
|
|
335
|
+
gitlabJob: gitlabJob,
|
|
336
|
+
context: context
|
|
337
|
+
};
|
|
336
338
|
});
|
|
337
339
|
})];
|
|
338
340
|
});
|