@catladder/pipeline 1.146.1 → 1.146.2
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.d.ts +2 -2
- package/dist/build/base/createAppBuildJob.js +1 -1
- package/dist/build/base/index.d.ts +2 -2
- package/dist/build/base/writeBuildInfo.d.ts +2 -2
- package/dist/build/base/writeDotEnv.d.ts +2 -2
- package/dist/build/custom/buildJob.d.ts +2 -2
- package/dist/build/custom/index.d.ts +2 -2
- package/dist/build/custom/testJob.d.ts +2 -2
- package/dist/build/docker.d.ts +9 -9
- package/dist/build/index.d.ts +2 -2
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/buildJob.js +6 -6
- package/dist/build/node/cache.d.ts +5 -5
- package/dist/build/node/cache.js +4 -4
- package/dist/build/node/index.d.ts +4 -4
- package/dist/build/node/meteor.d.ts +2 -2
- package/dist/build/node/meteor.js +2 -2
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +6 -6
- package/dist/build/node/yarn.d.ts +4 -4
- package/dist/build/node/yarn.js +1 -1
- package/dist/build/rails/build.d.ts +2 -2
- package/dist/build/rails/index.d.ts +2 -2
- package/dist/build/rails/test.d.ts +2 -2
- package/dist/build/sbom.d.ts +2 -2
- package/dist/build/sbom.js +1 -1
- package/dist/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/context/getEnvironment.d.ts +2 -2
- package/dist/context/getEnvironmentContext.d.ts +2 -2
- package/dist/context/getEnvironmentVariables.d.ts +4 -4
- package/dist/context/getLabels.d.ts +2 -2
- package/dist/context/index.d.ts +7 -3
- package/dist/context/index.js +12 -3
- package/dist/deploy/base/deploy.d.ts +2 -2
- package/dist/deploy/base/index.d.ts +2 -2
- package/dist/deploy/base/rollback.d.ts +2 -2
- package/dist/deploy/base/stop.d.ts +2 -2
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +7 -7
- package/dist/deploy/cloudRun/cleanup.d.ts +2 -2
- package/dist/deploy/cloudRun/cloudRunRevisions.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +6 -6
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +3 -3
- package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
- package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/index.d.ts +2 -2
- package/dist/deploy/cloudRun/utils/database.d.ts +3 -3
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -2
- package/dist/deploy/cloudRun/utils/getServiceName.d.ts +2 -2
- package/dist/deploy/custom/deployJob.d.ts +2 -2
- package/dist/deploy/custom/deployJob.js +1 -1
- package/dist/deploy/dockerTag/deployJob.d.ts +2 -2
- package/dist/deploy/index.d.ts +2 -2
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -3
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeEnv.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/deploy/kubernetes/mongodb.d.ts +2 -2
- package/dist/deploy/sbom.d.ts +4 -4
- package/dist/deploy/utils.d.ts +2 -2
- package/dist/pipeline/createJobsForComponent.d.ts +2 -2
- package/dist/pipeline/createJobsForComponent.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +2 -2
- package/dist/types/context.d.ts +16 -2
- package/package.json +1 -1
- package/src/build/base/createAppBuildJob.ts +3 -3
- package/src/build/base/index.ts +2 -2
- package/src/build/base/writeBuildInfo.ts +2 -2
- package/src/build/base/writeDotEnv.ts +2 -2
- package/src/build/custom/__tests__/testJob.test.ts +5 -5
- package/src/build/custom/buildJob.ts +4 -2
- package/src/build/custom/index.ts +2 -2
- package/src/build/custom/testJob.ts +4 -2
- package/src/build/docker.ts +9 -9
- package/src/build/index.ts +2 -2
- package/src/build/node/buildJob.ts +13 -9
- package/src/build/node/cache.ts +9 -9
- package/src/build/node/index.ts +6 -4
- package/src/build/node/meteor.ts +10 -5
- package/src/build/node/testJob.ts +11 -8
- package/src/build/node/yarn.ts +6 -8
- package/src/build/rails/build.ts +4 -2
- package/src/build/rails/index.ts +2 -2
- package/src/build/rails/test.ts +4 -2
- package/src/build/sbom.ts +4 -4
- package/src/context/getEnvironment.ts +2 -2
- package/src/context/getEnvironmentContext.ts +2 -2
- package/src/context/getEnvironmentVariables.ts +7 -4
- package/src/context/getLabels.ts +2 -2
- package/src/context/index.ts +15 -5
- package/src/deploy/base/deploy.ts +2 -2
- package/src/deploy/base/index.ts +2 -2
- package/src/deploy/base/rollback.ts +2 -2
- package/src/deploy/base/stop.ts +2 -2
- package/src/deploy/cloudRun/artifactsRegistry.ts +12 -7
- package/src/deploy/cloudRun/cleanup.ts +2 -2
- package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -3
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +10 -10
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +3 -3
- package/src/deploy/cloudRun/createJobs/common.ts +4 -4
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +5 -2
- package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +2 -2
- package/src/deploy/cloudRun/createJobs/index.ts +2 -2
- package/src/deploy/cloudRun/utils/database.ts +3 -3
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +4 -2
- package/src/deploy/cloudRun/utils/getServiceName.ts +2 -2
- package/src/deploy/custom/deployJob.ts +7 -3
- package/src/deploy/dockerTag/deployJob.ts +4 -2
- package/src/deploy/index.ts +2 -2
- package/src/deploy/kubernetes/cloudSql/index.ts +3 -3
- package/src/deploy/kubernetes/deployJob.ts +2 -2
- package/src/deploy/kubernetes/kubeEnv.ts +2 -2
- package/src/deploy/kubernetes/kubeValues.ts +3 -3
- package/src/deploy/kubernetes/mongodb.ts +8 -8
- package/src/deploy/sbom.ts +8 -4
- package/src/deploy/utils.ts +2 -2
- package/src/pipeline/createJobsForComponent.ts +11 -7
- package/src/pipeline/gitlab/createGitlabJobs.ts +2 -2
- package/src/types/config.ts +2 -2
- package/src/types/context.ts +18 -2
package/src/deploy/base/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../types/context";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { createDeployJob, type DeployJobDefinition } from "./deploy";
|
|
4
4
|
import { createRollbackJob, type RollbackJobDefinition } from "./rollback";
|
|
5
5
|
import { createStopJob, type StopJobDefinition } from "./stop";
|
|
6
6
|
|
|
7
7
|
export const createDeployementJobs = (
|
|
8
|
-
context:
|
|
8
|
+
context: ComponentContext,
|
|
9
9
|
definitions: {
|
|
10
10
|
deploy: DeployJobDefinition;
|
|
11
11
|
stop?: StopJobDefinition;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../types/context";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { DEPLOY_RUNNER_VARIABLES } from "./variables";
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ export type RollbackJobDefinition = Pick<
|
|
|
9
9
|
"script" | "variables" | "runnerVariables" | "image"
|
|
10
10
|
>;
|
|
11
11
|
export const createRollbackJob = (
|
|
12
|
-
context:
|
|
12
|
+
context: ComponentContext,
|
|
13
13
|
jobDefinition: RollbackJobDefinition,
|
|
14
14
|
): CatladderJob => {
|
|
15
15
|
return {
|
package/src/deploy/base/stop.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../types/context";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
|
|
4
4
|
import { DEPLOY_RUNNER_VARIABLES } from "./variables";
|
|
@@ -9,7 +9,7 @@ export type StopJobDefinition = Pick<
|
|
|
9
9
|
"script" | "variables" | "image" | "runnerVariables"
|
|
10
10
|
>;
|
|
11
11
|
export const createStopJob = (
|
|
12
|
-
context:
|
|
12
|
+
context: ComponentContext,
|
|
13
13
|
jobDefinition: StopJobDefinition,
|
|
14
14
|
): CatladderJob => {
|
|
15
15
|
return {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { StringOrBashExpression } from "../../bash/BashExpression";
|
|
2
2
|
import { joinBashExpressions } from "../../bash/BashExpression";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import { allowFailureInScripts } from "../../utils/gitlab";
|
|
5
5
|
import { isOfDeployType } from "../types";
|
|
6
6
|
import { removeFirstLinesFromCommandOutput } from "./utils/removeFirstLinesFromCommandOutput";
|
|
7
7
|
|
|
8
8
|
export const getArtifactsRegistryHost = ({
|
|
9
9
|
componentConfig: { deploy },
|
|
10
|
-
}:
|
|
10
|
+
}: ComponentContext) => {
|
|
11
11
|
if (!isOfDeployType(deploy, "google-cloudrun")) {
|
|
12
12
|
// should not happen
|
|
13
13
|
throw new Error("deploy config is wrong");
|
|
@@ -15,7 +15,7 @@ export const getArtifactsRegistryHost = ({
|
|
|
15
15
|
return `${deploy.region}-docker.pkg.dev`;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export const getArtifactsRegistryDockerUrl = (context:
|
|
18
|
+
export const getArtifactsRegistryDockerUrl = (context: ComponentContext) => {
|
|
19
19
|
const deployConfig = context.componentConfig.deploy;
|
|
20
20
|
|
|
21
21
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
@@ -35,7 +35,7 @@ export const getArtifactsRegistryDockerUrl = (context: Context) => {
|
|
|
35
35
|
* lecacyReviewImageName is only temporary. In old versions the images had no reviewslug in review apps, which makes cleanup harder. We delete all those images now, but need the path
|
|
36
36
|
*/
|
|
37
37
|
export const getArtifactsRegistryImageName = (
|
|
38
|
-
context:
|
|
38
|
+
context: ComponentContext,
|
|
39
39
|
lecacyReviewImageName = false,
|
|
40
40
|
) => {
|
|
41
41
|
if (lecacyReviewImageName && context.environment.envType !== "review") {
|
|
@@ -55,14 +55,16 @@ export const getArtifactsRegistryImageName = (
|
|
|
55
55
|
return joinBashExpressions(gcloudImagePath, "/");
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
export const getArtifactsRegistryBuildCacheImage = (
|
|
58
|
+
export const getArtifactsRegistryBuildCacheImage = (
|
|
59
|
+
context: ComponentContext,
|
|
60
|
+
) => {
|
|
59
61
|
const dockerUrl = getArtifactsRegistryDockerUrl(context);
|
|
60
62
|
// does not include env, so that after merge, you might get more cache hits (review-->dev)
|
|
61
63
|
const gcloudImagePath = [dockerUrl, "caches", context.componentName];
|
|
62
64
|
return gcloudImagePath.join("/");
|
|
63
65
|
};
|
|
64
66
|
|
|
65
|
-
export const getArtifactsRegistryImage = (context:
|
|
67
|
+
export const getArtifactsRegistryImage = (context: ComponentContext) =>
|
|
66
68
|
`${getArtifactsRegistryImageName(context)}:$DOCKER_IMAGE_TAG`;
|
|
67
69
|
|
|
68
70
|
const getDeleteImageCommands = (
|
|
@@ -96,7 +98,10 @@ const getDeleteImageCommands = (
|
|
|
96
98
|
* @param keep how many of the newest images to keep
|
|
97
99
|
* @returns
|
|
98
100
|
*/
|
|
99
|
-
export const getDeleteUnusedImagesCommands = (
|
|
101
|
+
export const getDeleteUnusedImagesCommands = (
|
|
102
|
+
context: ComponentContext,
|
|
103
|
+
keep = 0,
|
|
104
|
+
) => {
|
|
100
105
|
const deployConfig = context.componentConfig.deploy;
|
|
101
106
|
if (deployConfig === false) {
|
|
102
107
|
return [];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../types/context";
|
|
2
2
|
import { getDeleteUnusedImagesCommands } from "./artifactsRegistry";
|
|
3
3
|
import { getDeleteUnusedRevisionsCommands } from "./cloudRunRevisions";
|
|
4
4
|
|
|
5
5
|
export const getRemoveOldRevisionsAndImagesCommand = (
|
|
6
|
-
context:
|
|
6
|
+
context: ComponentContext,
|
|
7
7
|
when: "postDeploy" | "onStop",
|
|
8
8
|
) => {
|
|
9
9
|
if (when === "onStop") {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../types/context";
|
|
2
2
|
import { isOfDeployType } from "../types";
|
|
3
3
|
import { createArgsString } from "./utils/createArgsString";
|
|
4
4
|
import { getServiceName } from "./utils/getServiceName";
|
|
5
5
|
import { removeFirstLinesFromCommandOutput } from "./utils/removeFirstLinesFromCommandOutput";
|
|
6
6
|
|
|
7
7
|
const getListRevisionsCommand = (
|
|
8
|
-
context:
|
|
8
|
+
context: ComponentContext,
|
|
9
9
|
args: {
|
|
10
10
|
filter?: string;
|
|
11
11
|
format: string;
|
|
@@ -34,7 +34,7 @@ const getListRevisionsCommand = (
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export const getDeleteUnusedRevisionsCommands = (
|
|
37
|
-
context:
|
|
37
|
+
context: ComponentContext,
|
|
38
38
|
keep: number,
|
|
39
39
|
) => {
|
|
40
40
|
const deployConfig = context.componentConfig.deploy;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../../types/context";
|
|
2
2
|
import { allowFailureInScripts } from "../../../utils/gitlab";
|
|
3
3
|
|
|
4
4
|
import type {
|
|
@@ -24,7 +24,7 @@ import type {
|
|
|
24
24
|
import { ENV_VARS_FILENAME } from "./constants";
|
|
25
25
|
|
|
26
26
|
const getJobRunScriptForJob = (
|
|
27
|
-
context:
|
|
27
|
+
context: ComponentContext,
|
|
28
28
|
jobName: StringOrBashExpression,
|
|
29
29
|
wait: boolean,
|
|
30
30
|
) => {
|
|
@@ -36,7 +36,7 @@ const getJobRunScriptForJob = (
|
|
|
36
36
|
}`;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
export const getDeleteSchedulesScripts = (context:
|
|
39
|
+
export const getDeleteSchedulesScripts = (context: ComponentContext) => {
|
|
40
40
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
41
41
|
const jobsWithSchedule = getCloudRunJobsWithSchedule(context);
|
|
42
42
|
const argsString = createArgsString({
|
|
@@ -52,7 +52,7 @@ export const getDeleteSchedulesScripts = (context: Context) => {
|
|
|
52
52
|
.flat();
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
export const getDeleteJobsScripts = (context:
|
|
55
|
+
export const getDeleteJobsScripts = (context: ComponentContext) => {
|
|
56
56
|
const commonArgs = getCommonCloudRunArgs(context);
|
|
57
57
|
const commonArgsString = createArgsString(commonArgs);
|
|
58
58
|
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
@@ -65,7 +65,7 @@ export const getDeleteJobsScripts = (context: Context) => {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
export const getJobRunScripts = (
|
|
68
|
-
context:
|
|
68
|
+
context: ComponentContext,
|
|
69
69
|
when: DeployConfigCloudRunJob["when"],
|
|
70
70
|
) => {
|
|
71
71
|
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
@@ -81,7 +81,7 @@ export const getJobRunScripts = (
|
|
|
81
81
|
);
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
export const getJobCreateScripts = (context:
|
|
84
|
+
export const getJobCreateScripts = (context: ComponentContext) => {
|
|
85
85
|
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
86
86
|
|
|
87
87
|
return jobsWithNames
|
|
@@ -90,7 +90,7 @@ export const getJobCreateScripts = (context: Context) => {
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
const getJobCreateScriptsForJob = (
|
|
93
|
-
context:
|
|
93
|
+
context: ComponentContext,
|
|
94
94
|
jobName: StringOrBashExpression,
|
|
95
95
|
job: DeployConfigCloudRunJob,
|
|
96
96
|
) => {
|
|
@@ -132,7 +132,7 @@ const getJobCreateScriptsForJob = (
|
|
|
132
132
|
];
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
export const getCreateScheduleScripts = (context:
|
|
135
|
+
export const getCreateScheduleScripts = (context: ComponentContext) => {
|
|
136
136
|
const jobsWithSchedule = getCloudRunJobsWithSchedule(context);
|
|
137
137
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
138
138
|
|
|
@@ -160,7 +160,7 @@ export const getCreateScheduleScripts = (context: Context) => {
|
|
|
160
160
|
.flat();
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
const getCloudRunJobsWithSchedule = (context:
|
|
163
|
+
const getCloudRunJobsWithSchedule = (context: ComponentContext) => {
|
|
164
164
|
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
165
165
|
|
|
166
166
|
return jobsWithNames
|
|
@@ -179,7 +179,7 @@ const getCloudRunJobsWithSchedule = (context: Context) => {
|
|
|
179
179
|
}));
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
-
const getCloudRunJobsWithNames = (context:
|
|
182
|
+
const getCloudRunJobsWithNames = (context: ComponentContext) => {
|
|
183
183
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
184
184
|
|
|
185
185
|
const getFullJobName = (name: string) =>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getLabels } from "../../../context/getLabels";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentContext } from "../../../types/context";
|
|
3
3
|
|
|
4
4
|
import type { DeployConfigCloudRunService } from "../../types/googleCloudRun";
|
|
5
5
|
import { createArgsString } from "../utils/createArgsString";
|
|
@@ -14,7 +14,7 @@ import { ENV_VARS_FILENAME } from "./constants";
|
|
|
14
14
|
import { createVolumeConfig } from "./volumes";
|
|
15
15
|
|
|
16
16
|
export const getServiceDeployScript = (
|
|
17
|
-
context:
|
|
17
|
+
context: ComponentContext,
|
|
18
18
|
service: DeployConfigCloudRunService | true | undefined,
|
|
19
19
|
nameSuffix?: string,
|
|
20
20
|
) => {
|
|
@@ -66,7 +66,7 @@ export const getServiceDeployScript = (
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export const getServiceDeleteScript = (
|
|
69
|
-
context:
|
|
69
|
+
context: ComponentContext,
|
|
70
70
|
serviceSuffix?: string,
|
|
71
71
|
) => {
|
|
72
72
|
const commonArgs = getCommonCloudRunArgs(context);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../../types/context";
|
|
2
2
|
|
|
3
3
|
import { isOfDeployType } from "../../types";
|
|
4
4
|
import type { DeployConfigCloudRun } from "../../types/googleCloudRun";
|
|
@@ -29,7 +29,7 @@ export const makeLabelString = (obj: Record<string, unknown>) =>
|
|
|
29
29
|
.map(([key, value]) => `${key}=${value}`)
|
|
30
30
|
.join(",");
|
|
31
31
|
|
|
32
|
-
export const getCloudRunDeployConfig = (context:
|
|
32
|
+
export const getCloudRunDeployConfig = (context: ComponentContext) => {
|
|
33
33
|
const deployConfig = context.componentConfig.deploy;
|
|
34
34
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
35
35
|
// should not happen
|
|
@@ -38,7 +38,7 @@ export const getCloudRunDeployConfig = (context: Context) => {
|
|
|
38
38
|
return deployConfig;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export function getCommonCloudRunArgs(context:
|
|
41
|
+
export function getCommonCloudRunArgs(context: ComponentContext) {
|
|
42
42
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
43
43
|
return {
|
|
44
44
|
project: deployConfig.projectId,
|
|
@@ -46,7 +46,7 @@ export function getCommonCloudRunArgs(context: Context) {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function getCommonDeployArgs(context:
|
|
49
|
+
export function getCommonDeployArgs(context: ComponentContext) {
|
|
50
50
|
const commonArgs = getCommonCloudRunArgs(context);
|
|
51
51
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
52
52
|
return {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { isNil, omit } from "lodash";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
ComponentContext,
|
|
4
|
+
UnspecifiedEnvVars,
|
|
5
|
+
} from "../../../types/context";
|
|
3
6
|
import { collapseableSection } from "../../../utils/gitlab";
|
|
4
7
|
import { getDependencyTrackUploadScript } from "../../sbom";
|
|
5
8
|
|
|
@@ -25,7 +28,7 @@ import {
|
|
|
25
28
|
yamlBashString,
|
|
26
29
|
} from "../../../bash/bashYaml";
|
|
27
30
|
|
|
28
|
-
export function getCloudRunDeployScripts(context:
|
|
31
|
+
export function getCloudRunDeployScripts(context: ComponentContext) {
|
|
29
32
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
30
33
|
const allEnvVars = omit(
|
|
31
34
|
context.environment.envVars,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../../types/context";
|
|
2
2
|
import { getDependencyTrackDeleteScript } from "../../sbom";
|
|
3
3
|
|
|
4
4
|
import { getRemoveOldRevisionsAndImagesCommand } from "../cleanup";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { getServiceDeleteScript } from "./cloudRunServices";
|
|
13
13
|
import { getCloudRunDeployConfig } from "./common";
|
|
14
14
|
|
|
15
|
-
export function getCloudRunStopScripts(context:
|
|
15
|
+
export function getCloudRunStopScripts(context: ComponentContext) {
|
|
16
16
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
17
17
|
return [
|
|
18
18
|
...gcloudServiceAccountLoginCommands(context),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getRunnerImage } from "../../../runner";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentContext } from "../../../types/context";
|
|
3
3
|
import type { CatladderJob } from "../../../types/jobs";
|
|
4
4
|
import { allowFailureInScripts } from "../../../utils/gitlab";
|
|
5
5
|
import { createDeployementJobs } from "../../base";
|
|
@@ -10,7 +10,7 @@ import { getCloudRunDeployScripts } from "./getCloudRunDeployScripts";
|
|
|
10
10
|
import { getCloudRunStopScripts } from "./getCloudRunStopScripts";
|
|
11
11
|
|
|
12
12
|
export const createGoogleCloudRunDeployJobs = (
|
|
13
|
-
context:
|
|
13
|
+
context: ComponentContext,
|
|
14
14
|
): CatladderJob[] => {
|
|
15
15
|
const deployConfig = context.componentConfig.deploy;
|
|
16
16
|
if (deployConfig === false) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../../../types";
|
|
2
2
|
import { allowFailureInScripts, repeatOnFailure } from "../../../utils/gitlab";
|
|
3
3
|
import type {
|
|
4
4
|
DeployConfigCloudRun,
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
} from "../../types";
|
|
7
7
|
|
|
8
8
|
export const getDatabaseDeleteScript = (
|
|
9
|
-
context:
|
|
9
|
+
context: ComponentContext,
|
|
10
10
|
deployConfig: DeployConfigCloudRun,
|
|
11
11
|
): string[] => {
|
|
12
12
|
if (!deployConfig.cloudSql || !deployConfig.cloudSql.deleteDatabaseOnStop) {
|
|
@@ -35,7 +35,7 @@ export const getDatabaseDeleteScript = (
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
export const getDatabaseCreateScript = (
|
|
38
|
-
context:
|
|
38
|
+
context: ComponentContext,
|
|
39
39
|
deployConfig: DeployConfigCloudRun,
|
|
40
40
|
): string[] => {
|
|
41
41
|
if (!deployConfig.cloudSql) {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { GCLOUD_DEPLOY_CREDENTIALS_KEY } from "..";
|
|
2
2
|
import { getSecretVarNameForContext } from "../../../context";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../../types";
|
|
4
4
|
|
|
5
|
-
export const gcloudServiceAccountLoginCommands = (
|
|
5
|
+
export const gcloudServiceAccountLoginCommands = (
|
|
6
|
+
context: ComponentContext,
|
|
7
|
+
) => [
|
|
6
8
|
`gcloud auth activate-service-account --key-file=<(echo "$${getSecretVarNameForContext(
|
|
7
9
|
context,
|
|
8
10
|
GCLOUD_DEPLOY_CREDENTIALS_KEY,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export const getServiceName = (context:
|
|
1
|
+
import type { ComponentContext } from "../../../types/context";
|
|
2
|
+
export const getServiceName = (context: ComponentContext) =>
|
|
3
3
|
context.environment.fullName.toLowerCase();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getYarnInstall } from "../../build/node/yarn";
|
|
2
2
|
import { getRunnerImage } from "../../runner";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
5
5
|
import { createDeployementJobs } from "../base";
|
|
6
6
|
import {
|
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
} from "../sbom";
|
|
10
10
|
import { isOfDeployType } from "../types";
|
|
11
11
|
|
|
12
|
-
export const createCustomDeployJobs = (
|
|
12
|
+
export const createCustomDeployJobs = (
|
|
13
|
+
context: ComponentContext,
|
|
14
|
+
): CatladderJob[] => {
|
|
13
15
|
const deployConfig = context.componentConfig.deploy;
|
|
14
16
|
if (deployConfig === false) {
|
|
15
17
|
return [];
|
|
@@ -19,7 +21,9 @@ export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
|
|
|
19
21
|
throw new Error("deploy config is not custom");
|
|
20
22
|
}
|
|
21
23
|
// FIXME: custom deploy currently assumes yarn-based project
|
|
22
|
-
const yarnInstall = getYarnInstall(context, {
|
|
24
|
+
const yarnInstall = getYarnInstall(context.buildContext, {
|
|
25
|
+
noCustomPostInstall: true,
|
|
26
|
+
});
|
|
23
27
|
return createDeployementJobs(context, {
|
|
24
28
|
deploy: {
|
|
25
29
|
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { getDockerJobBaseProps, gitlabDockerLogin } from "../../build/docker";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
5
5
|
import { createDeployementJobs } from "../base";
|
|
6
6
|
import { isOfDeployType } from "../types";
|
|
7
7
|
|
|
8
|
-
export const createDockerTagDeployJobs = (
|
|
8
|
+
export const createDockerTagDeployJobs = (
|
|
9
|
+
context: ComponentContext,
|
|
10
|
+
): CatladderJob[] => {
|
|
9
11
|
const deployConfig = context.componentConfig.deploy;
|
|
10
12
|
if (deployConfig === false) {
|
|
11
13
|
return [];
|
package/src/deploy/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SecretEnvVar } from "..";
|
|
2
2
|
import type { BashExpression } from "../bash/BashExpression";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../types/context";
|
|
4
4
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
5
5
|
import type { CatladderJob } from "../types/jobs";
|
|
6
6
|
import type { PartialDeep } from "../types/utils";
|
|
@@ -15,7 +15,7 @@ export * from "./types";
|
|
|
15
15
|
export * from "./utils";
|
|
16
16
|
|
|
17
17
|
export type DeployTypeDefinition<T extends DeployConfigType> = {
|
|
18
|
-
jobs: (context:
|
|
18
|
+
jobs: (context: ComponentContext) => CatladderJob[];
|
|
19
19
|
defaults: (
|
|
20
20
|
envContext: EnvironmentContext<any, T>,
|
|
21
21
|
) => PartialDeep<DeployConfigGeneric<T>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { StringOrBashExpression } from "../../../bash/BashExpression";
|
|
2
2
|
import { getSecretVarNameForContext } from "../../../context";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../../types";
|
|
4
4
|
import { getFullDbName } from "../../cloudSql/utils";
|
|
5
5
|
import { isOfDeployType } from "../../types";
|
|
6
6
|
|
|
7
|
-
export const hasKubernetesCloudSQL = (context:
|
|
7
|
+
export const hasKubernetesCloudSQL = (context: ComponentContext) => {
|
|
8
8
|
if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
9
9
|
return context.componentConfig.deploy.values?.cloudsql?.enabled;
|
|
10
10
|
}
|
|
@@ -20,7 +20,7 @@ type CloudSqlValues = {
|
|
|
20
20
|
dbUser: string;
|
|
21
21
|
};
|
|
22
22
|
export const createKubernetesCloudsqlBaseValues = (
|
|
23
|
-
context:
|
|
23
|
+
context: ComponentContext,
|
|
24
24
|
): {
|
|
25
25
|
cloudsql: CloudSqlValues;
|
|
26
26
|
} => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
|
|
2
2
|
import { getRunnerImage } from "../../runner";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
5
5
|
import { createDeployementJobs } from "../base";
|
|
6
6
|
import {
|
|
@@ -15,7 +15,7 @@ import { collapseableSection } from "../../utils/gitlab";
|
|
|
15
15
|
|
|
16
16
|
const ALL_VALUES_FILE = "__all_values.yml";
|
|
17
17
|
export const createKubernetesDeployJobs = (
|
|
18
|
-
context:
|
|
18
|
+
context: ComponentContext,
|
|
19
19
|
): CatladderJob[] => {
|
|
20
20
|
const deployConfig = context.componentConfig.deploy;
|
|
21
21
|
if (deployConfig === false) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StringOrBashExpression } from "../../bash/BashExpression";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentContext } from "../../types";
|
|
3
3
|
import { isOfDeployType } from "../types";
|
|
4
4
|
|
|
5
5
|
const shouldGoIntoSecrets = (key: string, value: string | undefined) => {
|
|
@@ -14,7 +14,7 @@ const shouldGoIntoSecrets = (key: string, value: string | undefined) => {
|
|
|
14
14
|
* separate by secrets and public.
|
|
15
15
|
* we evalulate the actual values later, but want to store the secrets in kubernetes secrets
|
|
16
16
|
*/
|
|
17
|
-
export const createKubeEnv = (context:
|
|
17
|
+
export const createKubeEnv = (context: ComponentContext) => {
|
|
18
18
|
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
19
19
|
// should not happen
|
|
20
20
|
throw new Error("deploy config is not kubernetes");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { merge } from "lodash";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import { mergeWithMergingArrays } from "../../utils";
|
|
5
5
|
import type { DeployConfigKubernetesValues } from "../types";
|
|
6
6
|
import { isOfDeployType } from "../types";
|
|
@@ -14,7 +14,7 @@ import { createMongodbBaseConfig } from "./mongodb";
|
|
|
14
14
|
import { processSecretsAsFiles } from "./processSecretsAsFiles";
|
|
15
15
|
|
|
16
16
|
const createAppConfig = (
|
|
17
|
-
context:
|
|
17
|
+
context: ComponentContext,
|
|
18
18
|
application: DeployConfigKubernetesValues["application"],
|
|
19
19
|
): DeployConfigKubernetesValues["application"] => {
|
|
20
20
|
if (application === false) {
|
|
@@ -56,7 +56,7 @@ const removeFalsy = <T>(record?: Record<string, false | T>) => {
|
|
|
56
56
|
);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
export const createKubeValues = (context:
|
|
59
|
+
export const createKubeValues = (context: ComponentContext) => {
|
|
60
60
|
const deployConfig = context.componentConfig.deploy;
|
|
61
61
|
if (deployConfig === false) {
|
|
62
62
|
return [];
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { range } from "lodash";
|
|
2
2
|
import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentContext } from "../../types/context";
|
|
4
4
|
import { isOfDeployType } from "../types";
|
|
5
5
|
|
|
6
|
-
const getCredentialString = (context:
|
|
6
|
+
const getCredentialString = (context: ComponentContext) =>
|
|
7
7
|
`root:$${getSecretVarNameForContext(context, "MONGODB_ROOT_PASSWORD")}@`;
|
|
8
|
-
const getMongodbHost = (context:
|
|
8
|
+
const getMongodbHost = (context: ComponentContext, name: string) => {
|
|
9
9
|
const namespace = context.environment.envVars.KUBE_NAMESPACE;
|
|
10
10
|
return `${name}.${namespace}.svc.cluster.local:27017`;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const getMongodbStandaloneHost = (context:
|
|
13
|
+
const getMongodbStandaloneHost = (context: ComponentContext) => {
|
|
14
14
|
const fullAppname = context.environment.envVars.KUBE_APP_NAME;
|
|
15
15
|
return getMongodbHost(context, `${fullAppname}-mongodb`);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const getMongodbReplicasetHost = (context:
|
|
18
|
+
const getMongodbReplicasetHost = (context: ComponentContext, index: number) => {
|
|
19
19
|
const fullAppname = context.environment.envVars.KUBE_APP_NAME;
|
|
20
20
|
return getMongodbHost(
|
|
21
21
|
context,
|
|
22
22
|
`${fullAppname}-mongodb-${index}.${fullAppname}-mongodb-headless`,
|
|
23
23
|
);
|
|
24
24
|
};
|
|
25
|
-
const createMongodbUrl = (context:
|
|
25
|
+
const createMongodbUrl = (context: ComponentContext, dbName: string) => {
|
|
26
26
|
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
27
27
|
throw new Error("can only createMongodbUrl on supported deploys");
|
|
28
28
|
}
|
|
@@ -46,7 +46,7 @@ const createMongodbUrl = (context: Context, dbName: string) => {
|
|
|
46
46
|
queryParams ? `?${queryParams}` : ""
|
|
47
47
|
}`;
|
|
48
48
|
};
|
|
49
|
-
const createMongoBackupDefaultConfig = (context:
|
|
49
|
+
const createMongoBackupDefaultConfig = (context: ComponentContext) => {
|
|
50
50
|
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
51
51
|
throw new Error("can only create mongodb base config on supported deploys");
|
|
52
52
|
}
|
|
@@ -83,7 +83,7 @@ const createMongoBackupDefaultConfig = (context: Context) => {
|
|
|
83
83
|
volumeSnapshotClass: "snapshotclass",
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
-
export const createMongodbBaseConfig = (context:
|
|
86
|
+
export const createMongodbBaseConfig = (context: ComponentContext) => {
|
|
87
87
|
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
88
88
|
throw new Error("can only create mongodb base config on supported deploys");
|
|
89
89
|
}
|
package/src/deploy/sbom.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentContext } from "../types/context";
|
|
2
2
|
import { SBOM_FILE } from "../build/sbom";
|
|
3
3
|
|
|
4
|
-
export const sbomDeactivated = (context:
|
|
4
|
+
export const sbomDeactivated = (context: ComponentContext) =>
|
|
5
5
|
context.componentConfig.build.type === "custom" &&
|
|
6
6
|
context.componentConfig.build.sbom === false;
|
|
7
7
|
|
|
8
|
-
export const getDependencyTrackUploadScript = (
|
|
8
|
+
export const getDependencyTrackUploadScript = (
|
|
9
|
+
context: ComponentContext,
|
|
10
|
+
): string[] => {
|
|
9
11
|
return sbomDeactivated(context)
|
|
10
12
|
? []
|
|
11
13
|
: [
|
|
@@ -14,7 +16,9 @@ export const getDependencyTrackUploadScript = (context: Context): string[] => {
|
|
|
14
16
|
];
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
export const getDependencyTrackDeleteScript = (
|
|
19
|
+
export const getDependencyTrackDeleteScript = (
|
|
20
|
+
context: ComponentContext,
|
|
21
|
+
): string[] => {
|
|
18
22
|
return sbomDeactivated(context)
|
|
19
23
|
? []
|
|
20
24
|
: [
|
package/src/deploy/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config,
|
|
1
|
+
import type { Config, ComponentContext } from "../types";
|
|
2
2
|
import type { DeployConfigKubernetesCluster } from "./types";
|
|
3
3
|
import { isOfDeployType } from "./types";
|
|
4
4
|
|
|
@@ -17,7 +17,7 @@ export const getKubernetesNamespace = (
|
|
|
17
17
|
return `${config.customerName}-${config.appName}-${env}`;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const contextIsStoppable = (context:
|
|
20
|
+
export const contextIsStoppable = (context: ComponentContext) => {
|
|
21
21
|
const deployConfig = context.componentConfig.deploy;
|
|
22
22
|
if (isOfDeployType(deployConfig, "kubernetes")) {
|
|
23
23
|
return true;
|