@catladder/pipeline 1.110.2 → 1.110.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/build/custom/buildJob.js +4 -2
- package/dist/build/node/buildJob.js +4 -2
- package/dist/build/rails/build.js +13 -2
- package/dist/build/sbom.d.ts +5 -0
- package/dist/build/sbom.js +29 -0
- package/dist/bundles/catladder-gitlab/index.js +3 -3
- package/dist/constants.js +1 -1
- package/dist/deploy/base.js +38 -2
- package/dist/deploy/cloudRun/deployJob.js +5 -4
- package/dist/deploy/custom/deployJob.js +3 -2
- package/dist/deploy/kubernetes/deployJob.js +3 -2
- package/dist/deploy/sbom.d.ts +4 -0
- package/dist/deploy/sbom.js +17 -0
- package/dist/pipeline/createJobsForComponent.js +1 -3
- package/dist/pipeline/gitlab/createGitlabJobs.js +5 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +40 -96
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +40 -96
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +40 -96
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +80 -192
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +80 -192
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +40 -96
- package/examples/__snapshots__/custom-build-job.ts.snap +40 -96
- package/examples/__snapshots__/custom-deploy.ts.snap +40 -96
- package/examples/__snapshots__/custom-envs.ts.snap +6 -126
- package/examples/__snapshots__/custom-sbom-java.ts.snap +40 -96
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +40 -96
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +40 -96
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +40 -96
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +80 -192
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +40 -96
- package/examples/__snapshots__/native-app.ts.snap +72 -192
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +40 -96
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +40 -96
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +64 -192
- package/package.json +1 -1
- package/src/build/custom/buildJob.ts +3 -0
- package/src/build/node/buildJob.ts +3 -0
- package/src/build/rails/build.ts +3 -0
- package/src/build/sbom.ts +43 -0
- package/src/deploy/base.ts +14 -7
- package/src/deploy/cloudRun/deployJob.ts +6 -0
- package/src/deploy/custom/deployJob.ts +9 -1
- package/src/deploy/kubernetes/deployJob.ts +10 -1
- package/src/deploy/sbom.ts +24 -0
- package/src/pipeline/createJobsForComponent.ts +1 -3
- package/src/pipeline/gitlab/createGitlabJobs.ts +6 -2
- package/dist/verify/reporting.d.ts +0 -3
- package/dist/verify/reporting.js +0 -48
- package/src/verify/reporting.ts +0 -69
|
@@ -6,6 +6,10 @@ import type { Context } from "../../types/context";
|
|
|
6
6
|
import type { CatladderJob } from "../../types/jobs";
|
|
7
7
|
import { getBaseDeploymentJob, getBaseDeploymentStopJob } from "../base";
|
|
8
8
|
import { isOfDeployType } from "../types";
|
|
9
|
+
import {
|
|
10
|
+
getDependencyTrackDeleteScript,
|
|
11
|
+
getDependencyTrackUploadScript,
|
|
12
|
+
} from "../sbom";
|
|
9
13
|
|
|
10
14
|
export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
|
|
11
15
|
const deployConfig = context.componentConfig.deploy;
|
|
@@ -27,13 +31,17 @@ export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
|
|
|
27
31
|
`cd ${context.componentConfig.dir}`,
|
|
28
32
|
...(deployConfig.requiresYarnInstall ? yarnInstall : []),
|
|
29
33
|
...deployConfig.script,
|
|
34
|
+
...getDependencyTrackUploadScript(context),
|
|
30
35
|
],
|
|
31
36
|
}),
|
|
32
37
|
...(deployConfig.stopScript
|
|
33
38
|
? [
|
|
34
39
|
merge({}, getBaseDeploymentStopJob(context), {
|
|
35
40
|
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
|
|
36
|
-
script:
|
|
41
|
+
script: [
|
|
42
|
+
...deployConfig.stopScript,
|
|
43
|
+
...getDependencyTrackDeleteScript(context),
|
|
44
|
+
],
|
|
37
45
|
}),
|
|
38
46
|
]
|
|
39
47
|
: []),
|
|
@@ -11,6 +11,10 @@ import {
|
|
|
11
11
|
} from "../base";
|
|
12
12
|
import { isOfDeployType } from "../types";
|
|
13
13
|
import { createKubeValues } from "./kubeValues";
|
|
14
|
+
import {
|
|
15
|
+
getDependencyTrackDeleteScript,
|
|
16
|
+
getDependencyTrackUploadScript,
|
|
17
|
+
} from "../sbom";
|
|
14
18
|
|
|
15
19
|
export const createKubernetesDeployJobs = (
|
|
16
20
|
context: Context
|
|
@@ -76,6 +80,7 @@ export const createKubernetesDeployJobs = (
|
|
|
76
80
|
...connectContext,
|
|
77
81
|
"kubernetesCreateSecret",
|
|
78
82
|
"kubernetesDeploy",
|
|
83
|
+
...getDependencyTrackUploadScript(context),
|
|
79
84
|
"echo deployment successful 😻",
|
|
80
85
|
],
|
|
81
86
|
environment: {
|
|
@@ -83,7 +88,11 @@ export const createKubernetesDeployJobs = (
|
|
|
83
88
|
},
|
|
84
89
|
}),
|
|
85
90
|
merge({}, baseStopJob, shared, {
|
|
86
|
-
script: [
|
|
91
|
+
script: [
|
|
92
|
+
...connectContext,
|
|
93
|
+
"kubernetesDelete",
|
|
94
|
+
...getDependencyTrackDeleteScript(context),
|
|
95
|
+
],
|
|
87
96
|
environment: {
|
|
88
97
|
kubernetes: kubernetesEnvironment,
|
|
89
98
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Context } from "../types/context";
|
|
2
|
+
import { SBOM_FILE } from "../build/sbom";
|
|
3
|
+
|
|
4
|
+
export const sbomDeactivated = (context: Context) =>
|
|
5
|
+
context.componentConfig.build.type === "custom" &&
|
|
6
|
+
context.componentConfig.build.sbom === false;
|
|
7
|
+
|
|
8
|
+
export const getDependencyTrackUploadScript = (context: Context): string[] => {
|
|
9
|
+
return sbomDeactivated(context)
|
|
10
|
+
? []
|
|
11
|
+
: [
|
|
12
|
+
"echo Uploading SBOM to Dependency Track",
|
|
13
|
+
`/dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "${context.fullConfig.customerName}-${context.fullConfig.appName}/${context.componentName}" "${context.environment.url}" "${SBOM_FILE}" vex.json || true`,
|
|
14
|
+
];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getDependencyTrackDeleteScript = (context: Context): string[] => {
|
|
18
|
+
return sbomDeactivated(context)
|
|
19
|
+
? []
|
|
20
|
+
: [
|
|
21
|
+
"echo Disabling component in Dependency Track",
|
|
22
|
+
`/dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" disable "${context.fullConfig.customerName}-${context.fullConfig.appName}/${context.componentName}" "${context.environment.url}" || true`,
|
|
23
|
+
];
|
|
24
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isFunction } from "lodash";
|
|
2
2
|
import { BUILD_TYPES } from "../build";
|
|
3
|
-
import { createReportingJobs } from "../verify/reporting";
|
|
4
3
|
import { createContext } from "../context";
|
|
5
4
|
import { DEPLOY_TYPES } from "../deploy";
|
|
6
5
|
import type { Config, PipelineTrigger } from "../types/config";
|
|
@@ -36,10 +35,9 @@ const createRawJobs = (context: Context): CatladderJob[] => {
|
|
|
36
35
|
context.componentConfig.deploy !== false
|
|
37
36
|
? DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context)
|
|
38
37
|
: [];
|
|
39
|
-
const reportingJobs = createReportingJobs(context);
|
|
40
38
|
|
|
41
39
|
const customJobs = getCustomJobs(context);
|
|
42
|
-
return [...buildJobs, ...deployJobs, ...
|
|
40
|
+
return [...buildJobs, ...deployJobs, ...customJobs];
|
|
43
41
|
};
|
|
44
42
|
export const createJobsForComponent = async (
|
|
45
43
|
config: Config,
|
|
@@ -72,10 +72,10 @@ export const makeGitlabJob = (
|
|
|
72
72
|
}));
|
|
73
73
|
});
|
|
74
74
|
const cleanedNeeds: CatladderJob["needs"] = [
|
|
75
|
+
...(needsFromStages ?? []),
|
|
75
76
|
...(needs ?? []),
|
|
76
77
|
// pull in legacy needs from other component, which is now identical to needs
|
|
77
78
|
...(needsOtherComponent ?? []),
|
|
78
|
-
...(needsFromStages ?? []),
|
|
79
79
|
];
|
|
80
80
|
|
|
81
81
|
const gitlabNeeds: GitlabJobDef["needs"] = cleanedNeeds
|
|
@@ -94,6 +94,10 @@ export const makeGitlabJob = (
|
|
|
94
94
|
) // sort in a predictable manner for snapshot tests
|
|
95
95
|
.sort((a, b) => getJobName(a).localeCompare(getJobName(b)));
|
|
96
96
|
|
|
97
|
+
const deduplicatedGitlabNeeds: GitlabJobDef["needs"] = [
|
|
98
|
+
...new Map(gitlabNeeds.map((n) => [isObject(n) ? n.job : n, n])).values(),
|
|
99
|
+
];
|
|
100
|
+
|
|
97
101
|
const fullJobName = getFullJobName(
|
|
98
102
|
name,
|
|
99
103
|
componentName,
|
|
@@ -116,7 +120,7 @@ export const makeGitlabJob = (
|
|
|
116
120
|
}
|
|
117
121
|
: job.environment,
|
|
118
122
|
// sort in a predictable manner for snapshot tests
|
|
119
|
-
needs:
|
|
123
|
+
needs: deduplicatedGitlabNeeds,
|
|
120
124
|
retry: BASE_RETRY,
|
|
121
125
|
interruptible: true,
|
|
122
126
|
});
|
package/dist/verify/reporting.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.createReportingJobs = void 0;
|
|
5
|
-
var base_1 = require("../deploy/base");
|
|
6
|
-
var utils_1 = require("../utils");
|
|
7
|
-
var STAGE = "verify";
|
|
8
|
-
var SBOM_GENERATE_JOB_NAME = "🧾 sbom";
|
|
9
|
-
var SBOM_FILE = "__sbom.json";
|
|
10
|
-
var createSbomGenerateJob = function (context) {
|
|
11
|
-
var _a, _b, _c, _d, _e;
|
|
12
|
-
var buildConfig = context.componentConfig.build;
|
|
13
|
-
var defaultImage = "aquasec/trivy:0.38.3";
|
|
14
|
-
var defaultScript = ["trivy fs --quiet --format cyclonedx --output \"".concat(SBOM_FILE, "\" ").concat(((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace) ? "." : context.componentConfig.dir)];
|
|
15
|
-
var image = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_c = (_b = buildConfig.sbom) === null || _b === void 0 ? void 0 : _b.jobImage) !== null && _c !== void 0 ? _c : defaultImage : defaultImage;
|
|
16
|
-
var script = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_e = (0, utils_1.ensureArray)((_d = buildConfig.sbom) === null || _d === void 0 ? void 0 : _d.command)) !== null && _e !== void 0 ? _e : defaultScript : defaultScript;
|
|
17
|
-
return {
|
|
18
|
-
name: SBOM_GENERATE_JOB_NAME,
|
|
19
|
-
stage: STAGE,
|
|
20
|
-
needs: context.componentConfig.deploy !== false ? [base_1.DEPLOY_JOB_NAME] : [],
|
|
21
|
-
envMode: "jobPerEnv",
|
|
22
|
-
variables: {},
|
|
23
|
-
cache: undefined,
|
|
24
|
-
image: image,
|
|
25
|
-
script: script,
|
|
26
|
-
allow_failure: true,
|
|
27
|
-
artifacts: {
|
|
28
|
-
paths: [SBOM_FILE]
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
var createSbomUploadJob = function (context) {
|
|
33
|
-
return {
|
|
34
|
-
name: "🧾 sbom upload",
|
|
35
|
-
stage: STAGE,
|
|
36
|
-
needs: [SBOM_GENERATE_JOB_NAME],
|
|
37
|
-
envMode: "jobPerEnv",
|
|
38
|
-
variables: {},
|
|
39
|
-
cache: undefined,
|
|
40
|
-
image: "git.panter.ch:5001/open-source/dependency-track-uploader:dtrackuploader-v0.2.1",
|
|
41
|
-
script: ["/dtrackuploader https://dep.panter.swiss/ \"$DT_KEY_PROD\" upload \"".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName, "/").concat(context.componentName, "\" \"").concat(context.environment.shortName, "\" \"").concat(SBOM_FILE, "\" vex.json")],
|
|
42
|
-
allow_failure: true
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
var createReportingJobs = function (context) {
|
|
46
|
-
return context.componentConfig.build.type === "custom" && context.componentConfig.build.sbom === false ? [] : [createSbomGenerateJob(context), createSbomUploadJob(context)];
|
|
47
|
-
};
|
|
48
|
-
exports.createReportingJobs = createReportingJobs;
|
package/src/verify/reporting.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { DEPLOY_JOB_NAME } from "../deploy/base";
|
|
2
|
-
import type { Context } from "../types/context";
|
|
3
|
-
import type { CatladderJob } from "../types/jobs";
|
|
4
|
-
import { ensureArray } from "../utils";
|
|
5
|
-
|
|
6
|
-
const STAGE = "verify";
|
|
7
|
-
const SBOM_GENERATE_JOB_NAME = "🧾 sbom";
|
|
8
|
-
const SBOM_FILE = "__sbom.json";
|
|
9
|
-
|
|
10
|
-
const createSbomGenerateJob = (context: Context): CatladderJob => {
|
|
11
|
-
const buildConfig = context.componentConfig.build;
|
|
12
|
-
|
|
13
|
-
const defaultImage = "aquasec/trivy:0.38.3";
|
|
14
|
-
const defaultScript = [
|
|
15
|
-
`trivy fs --quiet --format cyclonedx --output "${SBOM_FILE}" ${
|
|
16
|
-
context.packageManagerInfo?.componentIsInWorkspace
|
|
17
|
-
? "."
|
|
18
|
-
: context.componentConfig.dir
|
|
19
|
-
}`,
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
const image =
|
|
23
|
-
buildConfig.type === "custom" && buildConfig.sbom !== false
|
|
24
|
-
? buildConfig.sbom?.jobImage ?? defaultImage
|
|
25
|
-
: defaultImage;
|
|
26
|
-
|
|
27
|
-
const script =
|
|
28
|
-
buildConfig.type === "custom" && buildConfig.sbom !== false
|
|
29
|
-
? ensureArray(buildConfig.sbom?.command) ?? defaultScript
|
|
30
|
-
: defaultScript;
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
name: SBOM_GENERATE_JOB_NAME,
|
|
34
|
-
stage: STAGE,
|
|
35
|
-
needs: context.componentConfig.deploy !== false ? [DEPLOY_JOB_NAME] : [],
|
|
36
|
-
envMode: "jobPerEnv",
|
|
37
|
-
variables: {},
|
|
38
|
-
cache: undefined,
|
|
39
|
-
image,
|
|
40
|
-
script,
|
|
41
|
-
allow_failure: true,
|
|
42
|
-
artifacts: {
|
|
43
|
-
paths: [SBOM_FILE],
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const createSbomUploadJob = (context: Context): CatladderJob => {
|
|
49
|
-
return {
|
|
50
|
-
name: "🧾 sbom upload",
|
|
51
|
-
stage: STAGE,
|
|
52
|
-
needs: [SBOM_GENERATE_JOB_NAME],
|
|
53
|
-
envMode: "jobPerEnv",
|
|
54
|
-
variables: {},
|
|
55
|
-
cache: undefined,
|
|
56
|
-
image:
|
|
57
|
-
"git.panter.ch:5001/open-source/dependency-track-uploader:dtrackuploader-v0.2.1",
|
|
58
|
-
script: [
|
|
59
|
-
`/dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "${context.fullConfig.customerName}-${context.fullConfig.appName}/${context.componentName}" "${context.environment.shortName}" "${SBOM_FILE}" vex.json`,
|
|
60
|
-
],
|
|
61
|
-
allow_failure: true,
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const createReportingJobs = (context: Context) =>
|
|
66
|
-
context.componentConfig.build.type === "custom" &&
|
|
67
|
-
context.componentConfig.build.sbom === false
|
|
68
|
-
? []
|
|
69
|
-
: [createSbomGenerateJob(context), createSbomUploadJob(context)];
|