@catladder/pipeline 1.146.2 → 1.148.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/createAppBuildJob.js +6 -6
- package/dist/build/base/writeBuildInfo.js +1 -1
- package/dist/build/base/writeDotEnv.js +1 -1
- package/dist/build/custom/__tests__/testJob.test.js +11 -14
- package/dist/build/custom/buildJob.js +5 -5
- package/dist/build/custom/testJob.js +5 -5
- package/dist/build/docker.d.ts +26 -9
- package/dist/build/docker.js +41 -20
- package/dist/build/node/buildJob.js +8 -8
- package/dist/build/node/cache.js +1 -1
- package/dist/build/node/meteor.js +6 -6
- package/dist/build/node/testJob.js +11 -11
- package/dist/build/rails/build.js +3 -3
- package/dist/build/rails/test.js +4 -4
- package/dist/build/sbom.js +2 -2
- package/dist/build/types.d.ts +34 -26
- package/dist/bundles/catladder-gitlab/index.js +2 -2
- package/dist/constants.js +1 -1
- package/dist/context/getLabels.js +1 -1
- package/dist/context/index.js +34 -12
- package/dist/deploy/base/deploy.js +9 -8
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +1 -5
- package/dist/deploy/cloudRun/artifactsRegistry.js +8 -9
- package/dist/deploy/cloudRun/cloudRunRevisions.js +4 -5
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +1 -1
- package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
- package/dist/deploy/cloudRun/createJobs/common.js +2 -1
- package/dist/deploy/cloudRun/createJobs/index.js +2 -4
- package/dist/deploy/custom/deployJob.js +7 -10
- package/dist/deploy/dockerTag/deployJob.js +3 -5
- package/dist/deploy/kubernetes/cloudSql/index.js +11 -9
- package/dist/deploy/kubernetes/deployJob.js +4 -7
- package/dist/deploy/kubernetes/kubeEnv.js +2 -1
- package/dist/deploy/kubernetes/kubeValues.js +10 -10
- package/dist/deploy/kubernetes/mongodb.js +11 -11
- package/dist/deploy/sbom.js +1 -1
- package/dist/deploy/types/index.d.ts +1 -1
- package/dist/deploy/types/index.js +1 -1
- package/dist/deploy/utils.js +2 -1
- package/dist/pipeline/createJobsForComponent.js +5 -5
- package/dist/pipeline/generatePipelineFiles.js +40 -9
- package/dist/pipeline/gitlab/createGitlabJobs.js +2 -9
- package/dist/pipeline/gitlab/sortGitLabJobDefProps.d.ts +7 -0
- package/dist/pipeline/gitlab/sortGitLabJobDefProps.js +27 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/context.d.ts +13 -1
- package/dist/utils/removeUndefined.d.ts +1 -0
- package/dist/utils/removeUndefined.js +36 -0
- package/examples/__snapshots__/cloud-run-storybook.ts.snap +1687 -0
- package/examples/__snapshots__/cloud-run-with-ngnix.ts.snap +1971 -0
- package/examples/cloud-run-storybook.ts +24 -0
- package/examples/cloud-run-with-ngnix.ts +24 -0
- package/package.json +1 -1
- package/src/build/base/createAppBuildJob.ts +7 -7
- package/src/build/base/writeBuildInfo.ts +1 -1
- package/src/build/base/writeDotEnv.ts +1 -1
- package/src/build/custom/__tests__/testJob.test.ts +5 -8
- package/src/build/custom/buildJob.ts +6 -9
- package/src/build/custom/testJob.ts +5 -5
- package/src/build/docker.ts +68 -24
- package/src/build/node/buildJob.ts +12 -12
- package/src/build/node/cache.ts +1 -1
- package/src/build/node/meteor.ts +11 -17
- package/src/build/node/testJob.ts +14 -14
- package/src/build/rails/build.ts +3 -3
- package/src/build/rails/test.ts +4 -4
- package/src/build/sbom.ts +3 -3
- package/src/build/types.ts +53 -38
- package/src/context/getLabels.ts +1 -1
- package/src/context/index.ts +21 -5
- package/src/deploy/base/deploy.ts +8 -14
- package/src/deploy/cloudRun/artifactsRegistry.ts +5 -10
- package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -5
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +1 -1
- package/src/deploy/cloudRun/createJobs/common.ts +5 -5
- package/src/deploy/cloudRun/createJobs/index.ts +1 -4
- package/src/deploy/custom/deployJob.ts +4 -6
- package/src/deploy/dockerTag/deployJob.ts +2 -5
- package/src/deploy/kubernetes/cloudSql/index.ts +7 -4
- package/src/deploy/kubernetes/deployJob.ts +1 -4
- package/src/deploy/kubernetes/kubeEnv.ts +1 -1
- package/src/deploy/kubernetes/kubeValues.ts +3 -3
- package/src/deploy/kubernetes/mongodb.ts +6 -6
- package/src/deploy/sbom.ts +1 -2
- package/src/deploy/types/index.ts +2 -2
- package/src/deploy/utils.ts +1 -1
- package/src/pipeline/createJobsForComponent.ts +6 -10
- package/src/pipeline/generatePipelineFiles.ts +21 -8
- package/src/pipeline/gitlab/createGitlabJobs.ts +2 -7
- package/src/pipeline/gitlab/sortGitLabJobDefProps.ts +59 -0
- package/src/types/config.ts +3 -1
- package/src/types/context.ts +16 -1
- package/src/utils/removeUndefined.ts +4 -0
package/src/build/rails/test.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const createRailsTestJobs = (
|
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const buildConfig = context.
|
|
14
|
+
const buildConfig = context.build.config;
|
|
15
15
|
|
|
16
16
|
const base: Omit<CatladderJob, "script" | "name"> = {
|
|
17
17
|
variables: {
|
|
@@ -45,7 +45,7 @@ export const createRailsTestJobs = (
|
|
|
45
45
|
image:
|
|
46
46
|
buildConfig.audit?.jobImage ?? buildConfig.jobImage ?? defaultImage,
|
|
47
47
|
script: [
|
|
48
|
-
`cd ${context.
|
|
48
|
+
`cd ${context.build.dir}`,
|
|
49
49
|
...(ensureArray(buildConfig.audit?.command) ?? [
|
|
50
50
|
"gem install bundler-audit",
|
|
51
51
|
"bundle audit check",
|
|
@@ -65,7 +65,7 @@ export const createRailsTestJobs = (
|
|
|
65
65
|
image:
|
|
66
66
|
buildConfig.lint?.jobImage ?? buildConfig.jobImage ?? defaultImage,
|
|
67
67
|
script: [
|
|
68
|
-
`cd ${context.
|
|
68
|
+
`cd ${context.build.dir}`,
|
|
69
69
|
...bundlerInstall,
|
|
70
70
|
...(ensureArray(buildConfig.lint?.command) ?? [
|
|
71
71
|
"bundle exec rubocop",
|
|
@@ -83,7 +83,7 @@ export const createRailsTestJobs = (
|
|
|
83
83
|
image:
|
|
84
84
|
buildConfig.test?.jobImage ?? buildConfig.jobImage ?? defaultImage,
|
|
85
85
|
script: [
|
|
86
|
-
`cd ${context.
|
|
86
|
+
`cd ${context.build.dir}`,
|
|
87
87
|
...bundlerInstall,
|
|
88
88
|
...(ensureArray(buildConfig.test?.command) ?? [
|
|
89
89
|
"bundle exec rspec",
|
package/src/build/sbom.ts
CHANGED
|
@@ -6,14 +6,14 @@ export const SBOM_BUILD_JOB_NAME = "🧾 sbom";
|
|
|
6
6
|
export const SBOM_FILE = "__sbom.json";
|
|
7
7
|
|
|
8
8
|
export const createSbomBuildJob = (context: ComponentContext): CatladderJob => {
|
|
9
|
-
const buildConfig = context.
|
|
9
|
+
const buildConfig = context.build.config;
|
|
10
10
|
|
|
11
11
|
const defaultImage = "aquasec/trivy:0.38.3";
|
|
12
12
|
const defaultScript = [
|
|
13
13
|
`trivy fs --quiet --format cyclonedx --output "${SBOM_FILE}" ${
|
|
14
|
-
context.
|
|
14
|
+
context.build.packageManagerInfo?.componentIsInWorkspace
|
|
15
15
|
? "."
|
|
16
|
-
: context.
|
|
16
|
+
: context.build.dir
|
|
17
17
|
}`,
|
|
18
18
|
];
|
|
19
19
|
|
package/src/build/types.ts
CHANGED
|
@@ -58,28 +58,6 @@ export type BuildConfigBase = {
|
|
|
58
58
|
*/
|
|
59
59
|
buildCommand?: string | string[] | null;
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
* customize docker build
|
|
63
|
-
*/
|
|
64
|
-
docker?: {
|
|
65
|
-
/**
|
|
66
|
-
* Custom Dockerfile lines integrated in the generated Dockerfile before the standard build steps.
|
|
67
|
-
*
|
|
68
|
-
* - [runner-images/docker-build/scripts/ensureNodeDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNodeDockerfile)
|
|
69
|
-
* - [runner-images/docker-build/scripts/ensureNginxDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNginxDockerfile)
|
|
70
|
-
* - [runner-images/docker-build/scripts/ensureMeteorDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureMeteorDockerfile)
|
|
71
|
-
*/
|
|
72
|
-
additionsBegin?: string[];
|
|
73
|
-
/**
|
|
74
|
-
* Custom Dockerfile lines integrated in the generated Dockerfile after the standard build steps.
|
|
75
|
-
*
|
|
76
|
-
* - [runner-images/docker-build/scripts/ensureNodeDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNodeDockerfile)
|
|
77
|
-
* - [runner-images/docker-build/scripts/ensureNginxDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNginxDockerfile)
|
|
78
|
-
* - [runner-images/docker-build/scripts/ensureMeteorDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureMeteorDockerfile)
|
|
79
|
-
*/
|
|
80
|
-
additionsEnd?: string[];
|
|
81
|
-
};
|
|
82
|
-
|
|
83
61
|
/**
|
|
84
62
|
* customize lint, set false to disable
|
|
85
63
|
*/
|
|
@@ -132,11 +110,13 @@ export type BuildConfigNodeBase = BuildConfigBase & {
|
|
|
132
110
|
|
|
133
111
|
export type BuildConfigNode = {
|
|
134
112
|
type: "node";
|
|
113
|
+
docker?: Omit<BuildConfigDockerBuiltInNode, "type"> | BuildConfigDocker;
|
|
135
114
|
} & BuildConfigNodeBase;
|
|
136
115
|
|
|
137
116
|
export type BuildConfigNodeStatic = BuildConfigNodeBase & {
|
|
138
117
|
type: "node-static";
|
|
139
118
|
startCommand?: never;
|
|
119
|
+
docker?: Omit<BuildConfigDockerBuiltInNgninx, "type"> | BuildConfigDocker;
|
|
140
120
|
};
|
|
141
121
|
|
|
142
122
|
export type BuildConfigMeteor = BuildConfigNodeBase & {
|
|
@@ -146,23 +126,58 @@ export type BuildConfigMeteor = BuildConfigNodeBase & {
|
|
|
146
126
|
* This is only required if you have custom scripts in your image
|
|
147
127
|
*/
|
|
148
128
|
installScripts?: boolean;
|
|
129
|
+
docker?: Omit<BuildConfigDockerBuiltInMeteor, "type"> | BuildConfigDocker;
|
|
149
130
|
};
|
|
150
131
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
132
|
+
type BuildConfigDockerWithAdditions = {
|
|
133
|
+
/**
|
|
134
|
+
* Custom Dockerfile lines integrated in the generated Dockerfile before the standard build steps.
|
|
135
|
+
*
|
|
136
|
+
*/
|
|
137
|
+
additionsBegin?: string[];
|
|
138
|
+
/**
|
|
139
|
+
* Custom Dockerfile lines integrated in the generated Dockerfile after the standard build steps.
|
|
140
|
+
*
|
|
141
|
+
*/
|
|
142
|
+
additionsEnd?: string[];
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
type BuildConfigDockerBuiltInNode = {
|
|
146
|
+
type: "node";
|
|
147
|
+
} & BuildConfigDockerWithAdditions;
|
|
148
|
+
|
|
149
|
+
type BuildConfigDockerBuiltInMeteor = {
|
|
150
|
+
type: "meteor";
|
|
151
|
+
} & BuildConfigDockerWithAdditions;
|
|
152
|
+
|
|
153
|
+
type BuildConfigDockerBuiltInNgninx = {
|
|
154
|
+
/**
|
|
155
|
+
* use the built-in nginx image for simple static apps
|
|
156
|
+
*/
|
|
157
|
+
type: "nginx";
|
|
158
|
+
} & BuildConfigDockerWithAdditions;
|
|
159
|
+
type BuildConfigDockerBuiltIn =
|
|
160
|
+
| BuildConfigDockerBuiltInNgninx
|
|
161
|
+
| BuildConfigDockerBuiltInNode
|
|
162
|
+
| BuildConfigDockerBuiltInMeteor;
|
|
163
|
+
|
|
164
|
+
type BuildConfigDockerCustom = {
|
|
165
|
+
/**
|
|
166
|
+
* custom docker build, expect that a Dockerfile in your directory
|
|
167
|
+
*/
|
|
168
|
+
type: "custom";
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export type BuildConfigDocker =
|
|
172
|
+
| BuildConfigDockerBuiltIn
|
|
173
|
+
| BuildConfigDockerCustom;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated this type is no longer used. Use {@link BuildConfigDocker} instead.
|
|
177
|
+
*/
|
|
178
|
+
export type BuildConfigCustomDocker =
|
|
179
|
+
| BuildConfigDockerCustom
|
|
180
|
+
| BuildConfigDockerBuiltInNgninx;
|
|
166
181
|
|
|
167
182
|
export type BuildConfigCustom = Omit<
|
|
168
183
|
BuildConfigBase,
|
|
@@ -175,7 +190,7 @@ export type BuildConfigCustom = Omit<
|
|
|
175
190
|
*/
|
|
176
191
|
jobServices?: Services;
|
|
177
192
|
|
|
178
|
-
docker:
|
|
193
|
+
docker: BuildConfigDocker;
|
|
179
194
|
|
|
180
195
|
/**
|
|
181
196
|
* custom lint, disabled when not set
|
package/src/context/getLabels.ts
CHANGED
|
@@ -14,7 +14,7 @@ export const getLabels = (context: ComponentContext) => {
|
|
|
14
14
|
"app-name": sanitize(context.fullConfig.appName),
|
|
15
15
|
"env-type": sanitize(context.environment.envType),
|
|
16
16
|
"env-name": sanitize(context.environment.shortName),
|
|
17
|
-
"build-type": sanitize(context.
|
|
17
|
+
"build-type": sanitize(context.build.config?.type),
|
|
18
18
|
...(context.fullConfig.meta?.labels ?? {}),
|
|
19
19
|
};
|
|
20
20
|
return labels;
|
package/src/context/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isFunction } from "lodash";
|
|
1
2
|
import { BUILD_TYPES } from "../build";
|
|
2
3
|
import type { BuildConfig, BuildConfigType } from "../build/types";
|
|
3
4
|
import { DEPLOY_TYPES } from "../deploy";
|
|
@@ -56,20 +57,35 @@ export const createComponentContext = async (
|
|
|
56
57
|
componentConfigWithoutDefaults,
|
|
57
58
|
);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
const environment = await getEnvironment(ctx);
|
|
61
|
+
const { deploy, build, customJobs, dir } = componentConfig;
|
|
62
|
+
const context: Omit<ComponentContext, "customJobs"> = {
|
|
60
63
|
fullConfig: ctx.config,
|
|
61
64
|
componentConfig,
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
|
|
66
|
+
build: {
|
|
67
|
+
dir: dir,
|
|
64
68
|
packageManagerInfo: ctx.packageManagerInfo,
|
|
65
|
-
config:
|
|
69
|
+
config: build,
|
|
66
70
|
},
|
|
71
|
+
deploy: deploy
|
|
72
|
+
? {
|
|
73
|
+
config: deploy,
|
|
74
|
+
}
|
|
75
|
+
: null,
|
|
67
76
|
componentName: ctx.componentName,
|
|
68
|
-
environment
|
|
77
|
+
environment,
|
|
69
78
|
packageManagerInfo: ctx.packageManagerInfo,
|
|
70
79
|
pipelineType: ctx.pipelineType,
|
|
71
80
|
trigger: ctx.trigger,
|
|
72
81
|
};
|
|
82
|
+
const resolvedCustomJobs = isFunction(customJobs)
|
|
83
|
+
? customJobs(context)
|
|
84
|
+
: customJobs;
|
|
85
|
+
return {
|
|
86
|
+
...context,
|
|
87
|
+
customJobs: resolvedCustomJobs,
|
|
88
|
+
};
|
|
73
89
|
};
|
|
74
90
|
|
|
75
91
|
/**
|
|
@@ -37,11 +37,11 @@ export const createDeployJob = (
|
|
|
37
37
|
? "4 weeks"
|
|
38
38
|
: undefined;
|
|
39
39
|
|
|
40
|
+
const deployConfig = context.deploy?.config;
|
|
41
|
+
|
|
40
42
|
// if auto or manual is configured explicitly, use that
|
|
41
43
|
const whenDeployDefined =
|
|
42
|
-
|
|
43
|
-
? context.componentConfig.deploy.when
|
|
44
|
-
: undefined;
|
|
44
|
+
deployConfig && deployConfig.when ? deployConfig.when : undefined;
|
|
45
45
|
// otherwise auto deploy if env is not prod. If its prod, deploy automatically if stage is disabled
|
|
46
46
|
const whenDeployDefault =
|
|
47
47
|
context.environment.envType !== "prod"
|
|
@@ -64,8 +64,8 @@ export const createDeployJob = (
|
|
|
64
64
|
...(sbomDeactivated(context)
|
|
65
65
|
? []
|
|
66
66
|
: [{ job: SBOM_BUILD_JOB_NAME, artifacts: true }]),
|
|
67
|
-
...(
|
|
68
|
-
?
|
|
67
|
+
...(deployConfig
|
|
68
|
+
? deployConfig.waitFor?.map((c) => ({
|
|
69
69
|
componentName: c,
|
|
70
70
|
job: DEPLOY_JOB_NAME,
|
|
71
71
|
artifacts: false,
|
|
@@ -91,17 +91,13 @@ export const createDeployJob = (
|
|
|
91
91
|
...context.environment.envVars,
|
|
92
92
|
...(hasDocker ? getDockerImageVariables(context) : {}),
|
|
93
93
|
...context.environment.jobOnlyVars.deploy.envVars,
|
|
94
|
-
...(
|
|
95
|
-
? context.componentConfig.deploy.extraVars ?? {}
|
|
96
|
-
: {}),
|
|
94
|
+
...(deployConfig ? deployConfig.extraVars ?? {} : {}),
|
|
97
95
|
...jobDefinition.variables,
|
|
98
96
|
},
|
|
99
97
|
runnerVariables: {
|
|
100
98
|
...DEPLOY_RUNNER_VARIABLES,
|
|
101
99
|
...(jobDefinition.runnerVariables ?? {}),
|
|
102
|
-
...(
|
|
103
|
-
? context.componentConfig.deploy.runnerVariables ?? {}
|
|
104
|
-
: {}),
|
|
100
|
+
...(deployConfig ? deployConfig.runnerVariables ?? {} : {}),
|
|
105
101
|
},
|
|
106
102
|
environment: isStoppable
|
|
107
103
|
? {
|
|
@@ -109,8 +105,6 @@ export const createDeployJob = (
|
|
|
109
105
|
auto_stop_in: autoStop,
|
|
110
106
|
}
|
|
111
107
|
: undefined,
|
|
112
|
-
jobTags:
|
|
113
|
-
? context.componentConfig.deploy.jobTags
|
|
114
|
-
: undefined,
|
|
108
|
+
jobTags: deployConfig ? deployConfig.jobTags : undefined,
|
|
115
109
|
};
|
|
116
110
|
};
|
|
@@ -5,18 +5,16 @@ import { allowFailureInScripts } from "../../utils/gitlab";
|
|
|
5
5
|
import { isOfDeployType } from "../types";
|
|
6
6
|
import { removeFirstLinesFromCommandOutput } from "./utils/removeFirstLinesFromCommandOutput";
|
|
7
7
|
|
|
8
|
-
export const getArtifactsRegistryHost = ({
|
|
9
|
-
|
|
10
|
-
}: ComponentContext) => {
|
|
11
|
-
if (!isOfDeployType(deploy, "google-cloudrun")) {
|
|
8
|
+
export const getArtifactsRegistryHost = (context: ComponentContext) => {
|
|
9
|
+
if (!isOfDeployType(context.deploy?.config, "google-cloudrun")) {
|
|
12
10
|
// should not happen
|
|
13
11
|
throw new Error("deploy config is wrong");
|
|
14
12
|
}
|
|
15
|
-
return `${deploy.region}-docker.pkg.dev`;
|
|
13
|
+
return `${context.deploy.config.region}-docker.pkg.dev`;
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
export const getArtifactsRegistryDockerUrl = (context: ComponentContext) => {
|
|
19
|
-
const deployConfig = context.
|
|
17
|
+
const deployConfig = context.deploy?.config;
|
|
20
18
|
|
|
21
19
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
22
20
|
// should not happen
|
|
@@ -102,10 +100,7 @@ export const getDeleteUnusedImagesCommands = (
|
|
|
102
100
|
context: ComponentContext,
|
|
103
101
|
keep = 0,
|
|
104
102
|
) => {
|
|
105
|
-
const deployConfig = context.
|
|
106
|
-
if (deployConfig === false) {
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
103
|
+
const deployConfig = context.deploy?.config;
|
|
109
104
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
110
105
|
// should not happen
|
|
111
106
|
throw new Error("deploy config is wrong");
|
|
@@ -12,7 +12,8 @@ const getListRevisionsCommand = (
|
|
|
12
12
|
},
|
|
13
13
|
) => {
|
|
14
14
|
const serviceName = getServiceName(context);
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
const deployConfig = context.deploy?.config;
|
|
16
17
|
|
|
17
18
|
if (!deployConfig || !isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
18
19
|
// should not happen
|
|
@@ -37,10 +38,7 @@ export const getDeleteUnusedRevisionsCommands = (
|
|
|
37
38
|
context: ComponentContext,
|
|
38
39
|
keep: number,
|
|
39
40
|
) => {
|
|
40
|
-
const deployConfig = context.
|
|
41
|
-
if (deployConfig === false) {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
41
|
+
const deployConfig = context.deploy?.config;
|
|
44
42
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
45
43
|
// should not happen
|
|
46
44
|
throw new Error("deploy config is wrong");
|
|
@@ -25,7 +25,7 @@ export const getServiceDeployScript = (
|
|
|
25
25
|
const customConfig = service !== true ? service : undefined;
|
|
26
26
|
const command =
|
|
27
27
|
service !== true
|
|
28
|
-
? service?.command ?? context.
|
|
28
|
+
? service?.command ?? context.build.config.startCommand
|
|
29
29
|
: undefined;
|
|
30
30
|
|
|
31
31
|
const commandArray = command
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Context } from "../../../types/context";
|
|
2
2
|
|
|
3
3
|
import { isOfDeployType } from "../../types";
|
|
4
4
|
import type { DeployConfigCloudRun } from "../../types/googleCloudRun";
|
|
@@ -29,8 +29,8 @@ export const makeLabelString = (obj: Record<string, unknown>) =>
|
|
|
29
29
|
.map(([key, value]) => `${key}=${value}`)
|
|
30
30
|
.join(",");
|
|
31
31
|
|
|
32
|
-
export const getCloudRunDeployConfig = (context:
|
|
33
|
-
const deployConfig = context.
|
|
32
|
+
export const getCloudRunDeployConfig = (context: Context) => {
|
|
33
|
+
const deployConfig = context.deploy?.config;
|
|
34
34
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
35
35
|
// should not happen
|
|
36
36
|
throw new Error("deploy config is wrong");
|
|
@@ -38,7 +38,7 @@ export const getCloudRunDeployConfig = (context: ComponentContext) => {
|
|
|
38
38
|
return deployConfig;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export function getCommonCloudRunArgs(context:
|
|
41
|
+
export function getCommonCloudRunArgs(context: Context) {
|
|
42
42
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
43
43
|
return {
|
|
44
44
|
project: deployConfig.projectId,
|
|
@@ -46,7 +46,7 @@ export function getCommonCloudRunArgs(context: ComponentContext) {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function getCommonDeployArgs(context:
|
|
49
|
+
export function getCommonDeployArgs(context: Context) {
|
|
50
50
|
const commonArgs = getCommonCloudRunArgs(context);
|
|
51
51
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
52
52
|
return {
|
|
@@ -12,10 +12,7 @@ import { getCloudRunStopScripts } from "./getCloudRunStopScripts";
|
|
|
12
12
|
export const createGoogleCloudRunDeployJobs = (
|
|
13
13
|
context: ComponentContext,
|
|
14
14
|
): CatladderJob[] => {
|
|
15
|
-
const deployConfig = context.
|
|
16
|
-
if (deployConfig === false) {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
15
|
+
const deployConfig = context.deploy?.config;
|
|
19
16
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
20
17
|
// should not happen
|
|
21
18
|
throw new Error("deploy config is wrong");
|
|
@@ -12,16 +12,14 @@ import { isOfDeployType } from "../types";
|
|
|
12
12
|
export const createCustomDeployJobs = (
|
|
13
13
|
context: ComponentContext,
|
|
14
14
|
): CatladderJob[] => {
|
|
15
|
-
const deployConfig = context.
|
|
16
|
-
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
15
|
+
const deployConfig = context.deploy?.config;
|
|
16
|
+
|
|
19
17
|
if (!isOfDeployType(deployConfig, "custom")) {
|
|
20
18
|
// should not happen
|
|
21
19
|
throw new Error("deploy config is not custom");
|
|
22
20
|
}
|
|
23
21
|
// FIXME: custom deploy currently assumes yarn-based project
|
|
24
|
-
const yarnInstall = getYarnInstall(context.
|
|
22
|
+
const yarnInstall = getYarnInstall(context.build, {
|
|
25
23
|
noCustomPostInstall: true,
|
|
26
24
|
});
|
|
27
25
|
return createDeployementJobs(context, {
|
|
@@ -29,7 +27,7 @@ export const createCustomDeployJobs = (
|
|
|
29
27
|
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
|
|
30
28
|
cache: deployConfig.jobCache ?? [],
|
|
31
29
|
script: [
|
|
32
|
-
`cd ${context.
|
|
30
|
+
`cd ${context.build.dir}`,
|
|
33
31
|
...(deployConfig.requiresYarnInstall ? yarnInstall : []),
|
|
34
32
|
...deployConfig.script,
|
|
35
33
|
...getDependencyTrackUploadScript(context),
|
|
@@ -8,10 +8,7 @@ import { isOfDeployType } from "../types";
|
|
|
8
8
|
export const createDockerTagDeployJobs = (
|
|
9
9
|
context: ComponentContext,
|
|
10
10
|
): CatladderJob[] => {
|
|
11
|
-
const deployConfig = context.
|
|
12
|
-
if (deployConfig === false) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
11
|
+
const deployConfig = context.deploy?.config;
|
|
15
12
|
if (!isOfDeployType(deployConfig, "dockerTag")) {
|
|
16
13
|
// should not happen
|
|
17
14
|
throw new Error("deploy config is not dockerTag");
|
|
@@ -19,7 +16,7 @@ export const createDockerTagDeployJobs = (
|
|
|
19
16
|
const tag = deployConfig.tag;
|
|
20
17
|
return createDeployementJobs(context, {
|
|
21
18
|
deploy: {
|
|
22
|
-
...getDockerJobBaseProps(
|
|
19
|
+
...getDockerJobBaseProps(),
|
|
23
20
|
script: [
|
|
24
21
|
...gitlabDockerLogin(context),
|
|
25
22
|
`docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG`,
|
|
@@ -5,8 +5,10 @@ import { getFullDbName } from "../../cloudSql/utils";
|
|
|
5
5
|
import { isOfDeployType } from "../../types";
|
|
6
6
|
|
|
7
7
|
export const hasKubernetesCloudSQL = (context: ComponentContext) => {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const deployConfig = context.deploy?.config;
|
|
9
|
+
|
|
10
|
+
if (isOfDeployType(deployConfig, "kubernetes")) {
|
|
11
|
+
return deployConfig.values?.cloudsql?.enabled;
|
|
10
12
|
}
|
|
11
13
|
return false;
|
|
12
14
|
};
|
|
@@ -24,11 +26,12 @@ export const createKubernetesCloudsqlBaseValues = (
|
|
|
24
26
|
): {
|
|
25
27
|
cloudsql: CloudSqlValues;
|
|
26
28
|
} => {
|
|
27
|
-
|
|
29
|
+
const deployConfig = context.deploy?.config;
|
|
30
|
+
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
28
31
|
throw new Error("cannot get cloud sql config");
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
const config =
|
|
34
|
+
const config = deployConfig.values?.cloudsql;
|
|
32
35
|
|
|
33
36
|
if (!config) {
|
|
34
37
|
throw new Error("cannot get cloud sql config");
|
|
@@ -17,10 +17,7 @@ const ALL_VALUES_FILE = "__all_values.yml";
|
|
|
17
17
|
export const createKubernetesDeployJobs = (
|
|
18
18
|
context: ComponentContext,
|
|
19
19
|
): CatladderJob[] => {
|
|
20
|
-
const deployConfig = context.
|
|
21
|
-
if (deployConfig === false) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
20
|
+
const deployConfig = context.deploy?.config;
|
|
24
21
|
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
25
22
|
// should not happen
|
|
26
23
|
throw new Error("deploy config is not kubernetes");
|
|
@@ -15,7 +15,7 @@ const shouldGoIntoSecrets = (key: string, value: string | undefined) => {
|
|
|
15
15
|
* we evalulate the actual values later, but want to store the secrets in kubernetes secrets
|
|
16
16
|
*/
|
|
17
17
|
export const createKubeEnv = (context: ComponentContext) => {
|
|
18
|
-
if (!isOfDeployType(context.
|
|
18
|
+
if (!isOfDeployType(context.deploy?.config, "kubernetes")) {
|
|
19
19
|
// should not happen
|
|
20
20
|
throw new Error("deploy config is not kubernetes");
|
|
21
21
|
}
|
|
@@ -28,7 +28,7 @@ const createAppConfig = (
|
|
|
28
28
|
return mergeWithMergingArrays(
|
|
29
29
|
{
|
|
30
30
|
host: context.environment.host,
|
|
31
|
-
command: command ?? context.
|
|
31
|
+
command: command ?? context.build.config.startCommand,
|
|
32
32
|
livenessProbe: {
|
|
33
33
|
httpGet: {
|
|
34
34
|
path: healthRoute ?? "__health",
|
|
@@ -57,8 +57,8 @@ const removeFalsy = <T>(record?: Record<string, false | T>) => {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
export const createKubeValues = (context: ComponentContext) => {
|
|
60
|
-
const deployConfig = context.
|
|
61
|
-
if (deployConfig
|
|
60
|
+
const deployConfig = context.deploy?.config;
|
|
61
|
+
if (!deployConfig) {
|
|
62
62
|
return [];
|
|
63
63
|
}
|
|
64
64
|
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
@@ -23,10 +23,10 @@ const getMongodbReplicasetHost = (context: ComponentContext, index: number) => {
|
|
|
23
23
|
);
|
|
24
24
|
};
|
|
25
25
|
const createMongodbUrl = (context: ComponentContext, dbName: string) => {
|
|
26
|
-
if (!isOfDeployType(context.
|
|
26
|
+
if (!isOfDeployType(context.deploy?.config, "kubernetes")) {
|
|
27
27
|
throw new Error("can only createMongodbUrl on supported deploys");
|
|
28
28
|
}
|
|
29
|
-
const mongodbConfig = context.
|
|
29
|
+
const mongodbConfig = context.deploy?.config.values?.mongodb;
|
|
30
30
|
|
|
31
31
|
let queryParams: string | undefined = undefined;
|
|
32
32
|
|
|
@@ -47,10 +47,10 @@ const createMongodbUrl = (context: ComponentContext, dbName: string) => {
|
|
|
47
47
|
}`;
|
|
48
48
|
};
|
|
49
49
|
const createMongoBackupDefaultConfig = (context: ComponentContext) => {
|
|
50
|
-
if (!isOfDeployType(context.
|
|
50
|
+
if (!isOfDeployType(context.deploy?.config, "kubernetes")) {
|
|
51
51
|
throw new Error("can only create mongodb base config on supported deploys");
|
|
52
52
|
}
|
|
53
|
-
const mongodbConfig = context.
|
|
53
|
+
const mongodbConfig = context.deploy?.config.values?.mongodb;
|
|
54
54
|
const fullAppName = context.environment.envVars.KUBE_APP_NAME;
|
|
55
55
|
const backupEnabled = ["prod", "stage"].includes(context.environment.envType);
|
|
56
56
|
|
|
@@ -84,10 +84,10 @@ const createMongoBackupDefaultConfig = (context: ComponentContext) => {
|
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
86
|
export const createMongodbBaseConfig = (context: ComponentContext) => {
|
|
87
|
-
if (!isOfDeployType(context.
|
|
87
|
+
if (!isOfDeployType(context.deploy?.config, "kubernetes")) {
|
|
88
88
|
throw new Error("can only create mongodb base config on supported deploys");
|
|
89
89
|
}
|
|
90
|
-
const mongodbConfig = context.
|
|
90
|
+
const mongodbConfig = context.deploy?.config.values?.mongodb;
|
|
91
91
|
|
|
92
92
|
return {
|
|
93
93
|
mongodb: {
|
package/src/deploy/sbom.ts
CHANGED
|
@@ -2,8 +2,7 @@ import type { ComponentContext } from "../types/context";
|
|
|
2
2
|
import { SBOM_FILE } from "../build/sbom";
|
|
3
3
|
|
|
4
4
|
export const sbomDeactivated = (context: ComponentContext) =>
|
|
5
|
-
context.
|
|
6
|
-
context.componentConfig.build.sbom === false;
|
|
5
|
+
context.build.config.type === "custom" && context.build.config.sbom === false;
|
|
7
6
|
|
|
8
7
|
export const getDependencyTrackUploadScript = (
|
|
9
8
|
context: ComponentContext,
|
|
@@ -21,8 +21,8 @@ export type DeployConfigGeneric<T extends DeployConfigType> = Extract<
|
|
|
21
21
|
>;
|
|
22
22
|
|
|
23
23
|
export const isOfDeployType = <T extends Array<DeployConfigType>>(
|
|
24
|
-
t: DeployConfig | false,
|
|
24
|
+
t: DeployConfig | false | null | undefined,
|
|
25
25
|
...types: T
|
|
26
26
|
): t is Extract<DeployConfig, { type: T[number] }> => {
|
|
27
|
-
return t && types.includes(t.type);
|
|
27
|
+
return t && types.includes(t.type) ? true : false;
|
|
28
28
|
};
|
package/src/deploy/utils.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const getKubernetesNamespace = (
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export const contextIsStoppable = (context: ComponentContext) => {
|
|
21
|
-
const deployConfig = context.
|
|
21
|
+
const deployConfig = context.deploy?.config;
|
|
22
22
|
if (isOfDeployType(deployConfig, "kubernetes")) {
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
@@ -23,21 +23,17 @@ const injectDefaultVarsInCustomJobs = (
|
|
|
23
23
|
...job,
|
|
24
24
|
}));
|
|
25
25
|
const getCustomJobs = (context: ComponentContext) => {
|
|
26
|
-
if (!context.
|
|
26
|
+
if (!context.customJobs) {
|
|
27
27
|
return [];
|
|
28
28
|
}
|
|
29
|
-
const rawJobs =
|
|
30
|
-
? context.componentConfig.customJobs(context)
|
|
31
|
-
: context.componentConfig.customJobs;
|
|
29
|
+
const rawJobs = context.customJobs;
|
|
32
30
|
return injectDefaultVarsInCustomJobs(context, rawJobs);
|
|
33
31
|
};
|
|
34
32
|
const createRawJobs = (context: Context): CatladderJob[] => {
|
|
35
|
-
const buildJobs =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
? DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context)
|
|
40
|
-
: [];
|
|
33
|
+
const buildJobs = BUILD_TYPES[context.build.config.type].jobs(context);
|
|
34
|
+
const deployJobs = context.deploy?.config
|
|
35
|
+
? DEPLOY_TYPES[context.deploy?.config.type].jobs(context)
|
|
36
|
+
: [];
|
|
41
37
|
|
|
42
38
|
const customJobs = getCustomJobs(context);
|
|
43
39
|
return [...buildJobs, ...deployJobs, ...customJobs];
|