@catladder/pipeline 0.0.0-node16-ddfae617 → 0.0.0-prettier-cbceeed9
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/bin/catladder-gitlab-dev.js +3 -0
- package/bin/catladder-gitlab.js +1 -1
- package/dist/build/base/createBuildJob.d.ts +2 -2
- package/dist/build/base/createBuildJob.js +15 -30
- package/dist/build/base/writeBuildInfo.d.ts +2 -0
- package/dist/build/base/{getBuildInfo.js → writeBuildInfo.js} +3 -6
- package/dist/build/custom/buildJob.d.ts +3 -0
- package/dist/build/custom/buildJob.js +83 -0
- package/dist/build/custom/index.d.ts +3 -0
- package/dist/build/custom/index.js +40 -0
- package/dist/build/docker.d.ts +33 -9
- package/dist/build/docker.js +51 -54
- package/dist/build/index.d.ts +6 -5
- package/dist/build/index.js +20 -6
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/buildJob.js +3 -25
- package/dist/build/node/cache.d.ts +2 -2
- package/dist/build/node/cache.js +19 -22
- package/dist/build/node/index.d.ts +1 -1
- package/dist/build/node/index.js +3 -16
- package/dist/build/node/meteor.d.ts +1 -1
- package/dist/build/node/meteor.js +9 -20
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +7 -21
- package/dist/build/node/yarn.d.ts +1 -1
- package/dist/build/node/yarn.js +14 -15
- package/dist/build/rails/build.d.ts +3 -0
- package/dist/build/rails/build.js +51 -0
- package/dist/build/rails/index.d.ts +3 -0
- package/dist/build/rails/index.js +41 -0
- package/dist/build/rails/test.d.ts +3 -0
- package/dist/build/rails/test.js +94 -0
- package/dist/build/types.d.ts +84 -9
- package/dist/build/types.js +0 -4
- package/dist/bundles/catladder-gitlab/index.js +32979 -0
- package/dist/catladder-gitlab.js +7 -26
- package/dist/config/{configruedEnvs.test.d.ts → __tests__/configruedEnvs.test.d.ts} +0 -0
- package/dist/config/{configruedEnvs.test.js → __tests__/configruedEnvs.test.js} +10 -12
- package/dist/config/configruedEnvs.d.ts +1 -1
- package/dist/config/configruedEnvs.js +7 -22
- package/dist/config/index.js +0 -4
- package/dist/config/readConfig.d.ts +1 -1
- package/dist/config/readConfig.js +2 -13
- package/dist/constants.js +1 -1
- package/dist/context/{resolveReferences.test.d.ts → __tests__/resolveReferences.test.d.ts} +0 -0
- package/dist/context/__tests__/resolveReferences.test.js +336 -0
- package/dist/context/getEnvConfig.d.ts +2 -0
- package/dist/context/getEnvConfig.js +18 -0
- package/dist/context/getEnvType.d.ts +4 -0
- package/dist/context/getEnvType.js +13 -0
- package/dist/context/getEnvironment.d.ts +3 -0
- package/dist/{pipeline/createChildPipeline.test.js → context/getEnvironment.js} +42 -84
- package/dist/context/getEnvironmentContext.d.ts +4 -0
- package/dist/context/getEnvironmentContext.js +33 -0
- package/dist/context/getEnvironmentVariables.d.ts +10 -0
- package/dist/context/getEnvironmentVariables.js +260 -0
- package/dist/context/getLabels.d.ts +8 -0
- package/dist/context/getLabels.js +38 -0
- package/dist/context/index.d.ts +5 -6
- package/dist/context/index.js +158 -208
- package/dist/context/resolveReferences.d.ts +1 -3
- package/dist/context/resolveReferences.js +213 -52
- package/dist/defaults/index.d.ts +1 -1
- package/dist/deploy/base.d.ts +4 -2
- package/dist/deploy/base.js +38 -33
- package/dist/deploy/cloudRun/deployJob.d.ts +3 -0
- package/dist/deploy/cloudRun/deployJob.js +238 -0
- package/dist/deploy/cloudRun/index.d.ts +4 -0
- package/dist/deploy/cloudRun/index.js +112 -0
- package/dist/deploy/cloudRun/utils/createArgsString.d.ts +11 -0
- package/dist/deploy/cloudRun/utils/createArgsString.js +55 -0
- package/dist/deploy/cloudRun/utils/database.d.ts +4 -0
- package/dist/deploy/cloudRun/utils/database.js +64 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +10 -0
- package/dist/deploy/cloudRun/utils/jobName.d.ts +1 -0
- package/dist/deploy/cloudRun/utils/jobName.js +8 -0
- package/dist/deploy/custom/deployJob.d.ts +2 -2
- package/dist/deploy/custom/deployJob.js +10 -16
- package/dist/deploy/custom/index.d.ts +2 -1
- package/dist/deploy/custom/index.js +14 -19
- package/dist/deploy/dockerTag/deployJob.d.ts +3 -0
- package/dist/deploy/dockerTag/deployJob.js +24 -0
- package/dist/deploy/dockerTag/index.d.ts +2 -0
- package/dist/deploy/dockerTag/index.js +17 -0
- package/dist/deploy/index.d.ts +12 -8
- package/dist/deploy/index.js +7 -20
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +4 -0
- package/dist/deploy/kubernetes/additionalSecretKeys.js +24 -0
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +13 -0
- package/dist/deploy/kubernetes/cloudSql/index.js +30 -0
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/deployJob.js +17 -91
- package/dist/deploy/kubernetes/index.d.ts +3 -1
- package/dist/deploy/kubernetes/index.js +42 -4
- package/dist/deploy/kubernetes/kubeEnv.d.ts +9 -0
- package/dist/deploy/kubernetes/kubeEnv.js +72 -0
- package/dist/deploy/kubernetes/kubeValues.d.ts +97 -0
- package/dist/deploy/kubernetes/kubeValues.js +124 -0
- package/dist/deploy/kubernetes/mongodb.d.ts +18 -5
- package/dist/deploy/kubernetes/mongodb.js +96 -10
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +25 -21
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +2 -10
- package/dist/deploy/types/base.d.ts +14 -0
- package/dist/deploy/types/base.js +3 -0
- package/dist/deploy/types/custom.d.ts +33 -0
- package/dist/deploy/types/custom.js +3 -0
- package/dist/deploy/types/dockerTag.d.ts +10 -0
- package/dist/deploy/types/dockerTag.js +3 -0
- package/dist/deploy/types/googleCloudRun.d.ts +121 -0
- package/dist/deploy/types/googleCloudRun.js +3 -0
- package/dist/deploy/types/index.d.ts +22 -0
- package/dist/deploy/types/index.js +31 -0
- package/dist/deploy/types/kubernetes.d.ts +276 -0
- package/dist/deploy/types/kubernetes.js +3 -0
- package/dist/deploy/utils.d.ts +2 -2
- package/dist/deploy/utils.js +3 -10
- package/dist/index.js +0 -10
- package/dist/pipeline/commitInfo/getBuildId.d.ts +1 -0
- package/dist/pipeline/commitInfo/getBuildId.js +135 -0
- package/dist/pipeline/commitInfo/getCommitInfo.d.ts +2 -0
- package/dist/pipeline/commitInfo/getCommitInfo.js +140 -0
- package/dist/pipeline/createAllJobs.d.ts +8 -0
- package/dist/{build/tests/storybook.test.js → pipeline/createAllJobs.js} +54 -104
- package/dist/pipeline/createChildPipeline.d.ts +2 -2
- package/dist/pipeline/createChildPipeline.js +40 -121
- package/dist/pipeline/createJobsForComponent.d.ts +3 -0
- package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +33 -192
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
- package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.js +1 -5
- package/dist/pipeline/packageManager.d.ts +1 -1
- package/dist/pipeline/packageManager.js +20 -173
- package/dist/pipeline/yarn/yarnUtils.d.ts +4 -0
- package/dist/pipeline/yarn/yarnUtils.js +193 -0
- package/dist/rules/index.d.ts +3 -1
- package/dist/rules/index.js +7 -6
- package/dist/runner/index.d.ts +2 -3
- package/dist/runner/index.js +0 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +19 -25
- package/dist/types/config.js +6 -16
- package/dist/types/context.d.ts +16 -3
- package/dist/types/environmentContext.d.ts +28 -0
- package/dist/types/environmentContext.js +3 -0
- package/dist/types/gitlab-types.d.ts +39 -7
- package/dist/types/index.js +0 -6
- package/dist/types/jobs.d.ts +25 -17
- package/dist/types/jobs.js +1 -1
- package/dist/types/pipeline.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.js +3 -0
- package/dist/utils/gitlab.d.ts +5 -0
- package/dist/utils/gitlab.js +48 -0
- package/dist/utils/index.js +5 -15
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +1560 -0
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +1560 -0
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +1560 -0
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3092 -0
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +3103 -0
- package/examples/__snapshots__/custom-build-job.ts.snap +1162 -0
- package/examples/__snapshots__/custom-envs.ts.snap +261 -0
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +2280 -0
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +4077 -0
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +1626 -0
- package/examples/__utils__/helpers.ts +14 -0
- package/examples/cloud-run-memory-limit.ts +28 -0
- package/examples/cloud-run-no-cpu-throttling.ts +33 -0
- package/examples/cloud-run-non-public.ts +27 -0
- package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
- package/examples/cloud-run-with-sql.ts +61 -0
- package/examples/custom-build-job.ts +28 -0
- package/examples/custom-envs.ts +31 -0
- package/examples/kubernetes-application-customization.ts +57 -0
- package/examples/kubernetes-with-jobs.ts +68 -0
- package/examples/rails-k8s-with-worker.ts +95 -0
- package/examples/wait-for-other-deploy.ts +36 -0
- package/package.json +16 -13
- package/scripts/bundle +2 -0
- package/src/build/base/createBuildJob.ts +12 -5
- package/src/build/base/{getBuildInfo.ts → writeBuildInfo.ts} +2 -2
- package/src/build/custom/buildJob.ts +64 -0
- package/src/build/custom/index.ts +7 -0
- package/src/build/docker.ts +58 -33
- package/src/build/index.ts +24 -5
- package/src/build/node/buildJob.ts +2 -2
- package/src/build/node/cache.ts +19 -8
- package/src/build/node/index.ts +1 -1
- package/src/build/node/meteor.ts +8 -2
- package/src/build/node/testJob.ts +4 -2
- package/src/build/node/yarn.ts +21 -10
- package/src/build/rails/build.ts +38 -0
- package/src/build/rails/index.ts +8 -0
- package/src/build/rails/test.ts +86 -0
- package/src/build/types.ts +97 -2
- package/src/catladder-gitlab.ts +4 -2
- package/src/config/{configruedEnvs.test.ts → __tests__/configruedEnvs.test.ts} +3 -3
- package/src/config/configruedEnvs.ts +2 -7
- package/src/config/readConfig.ts +1 -1
- package/src/context/{resolveReferences.test.ts → __tests__/resolveReferences.test.ts} +23 -38
- package/src/context/getEnvConfig.ts +21 -0
- package/src/context/getEnvType.ts +17 -0
- package/src/context/getEnvironment.ts +40 -0
- package/src/context/getEnvironmentContext.ts +57 -0
- package/src/context/getEnvironmentVariables.ts +155 -0
- package/src/context/getLabels.ts +20 -0
- package/src/context/index.ts +28 -193
- package/src/context/resolveReferences.ts +35 -31
- package/src/defaults/index.ts +1 -1
- package/src/deploy/base.ts +43 -19
- package/src/deploy/cloudRun/deployJob.ts +276 -0
- package/src/deploy/cloudRun/index.ts +95 -0
- package/src/deploy/cloudRun/utils/createArgsString.ts +26 -0
- package/src/deploy/cloudRun/utils/database.ts +55 -0
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +14 -0
- package/src/deploy/cloudRun/utils/jobName.ts +2 -0
- package/src/deploy/custom/deployJob.ts +13 -3
- package/src/deploy/custom/index.ts +9 -1
- package/src/deploy/dockerTag/deployJob.ts +31 -0
- package/src/deploy/dockerTag/index.ts +9 -0
- package/src/deploy/index.ts +26 -17
- package/src/deploy/kubernetes/additionalSecretKeys.ts +23 -0
- package/src/deploy/kubernetes/cloudSql/index.ts +28 -0
- package/src/deploy/kubernetes/deployJob.ts +21 -78
- package/src/deploy/kubernetes/index.ts +42 -1
- package/src/deploy/kubernetes/kubeEnv.ts +48 -0
- package/src/deploy/kubernetes/kubeValues.ts +96 -0
- package/src/deploy/kubernetes/mongodb.ts +104 -7
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +1 -1
- package/src/deploy/types/base.ts +17 -0
- package/src/deploy/types/custom.ts +36 -0
- package/src/deploy/types/dockerTag.ts +12 -0
- package/src/deploy/types/googleCloudRun.ts +179 -0
- package/src/deploy/types/index.ts +28 -0
- package/src/deploy/types/kubernetes.ts +301 -0
- package/src/deploy/utils.ts +6 -2
- package/src/pipeline/commitInfo/getBuildId.ts +6 -0
- package/src/pipeline/commitInfo/getCommitInfo.ts +12 -0
- package/src/pipeline/createAllJobs.ts +38 -0
- package/src/pipeline/createChildPipeline.ts +9 -20
- package/src/pipeline/createJobsForComponent.ts +64 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
- package/src/pipeline/index.ts +1 -1
- package/src/pipeline/packageManager.ts +4 -38
- package/src/pipeline/yarn/yarnUtils.ts +37 -0
- package/src/rules/index.ts +9 -6
- package/src/runner/index.ts +2 -1
- package/src/types/config.ts +26 -13
- package/src/types/context.ts +23 -2
- package/src/types/environmentContext.ts +33 -0
- package/src/types/gitlab-types.ts +36 -6
- package/src/types/jobs.ts +30 -6
- package/src/types/pipeline.ts +1 -1
- package/src/types/utils.ts +7 -0
- package/src/utils/gitlab.ts +23 -0
- package/tsconfig.json +3 -1
- package/dist/build/base/getBuildInfo.d.ts +0 -2
- package/dist/build/tests/storybook.test.d.ts +0 -1
- package/dist/context/resolveReferences.test.js +0 -141
- package/dist/deploy/kubernetes/cloudsql.d.ts +0 -6
- package/dist/deploy/kubernetes/cloudsql.js +0 -16
- package/dist/deploy/types.d.ts +0 -196
- package/dist/deploy/types.js +0 -16
- package/dist/pipeline/createChildPipeline.test.d.ts +0 -1
- package/dist/pipeline/createJobs.d.ts +0 -3
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -8
- package/dist/pipeline/gitlab/makeGitlabJob.js +0 -45
- package/src/build/tests/storybook.test.ts +0 -54
- package/src/deploy/kubernetes/cloudsql.ts +0 -12
- package/src/deploy/types.ts +0 -189
- package/src/pipeline/createChildPipeline.test.ts +0 -49
- package/src/pipeline/createJobs.ts +0 -195
- package/src/pipeline/gitlab/makeGitlabJob.ts +0 -16
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { DeployConfigBase } from "./base";
|
|
2
|
+
|
|
3
|
+
export type Gcloudregion =
|
|
4
|
+
| "asia-east1"
|
|
5
|
+
| "asia-northeast1"
|
|
6
|
+
| "asia-northeast2"
|
|
7
|
+
| "europe-north1"
|
|
8
|
+
| "europe-southwest1"
|
|
9
|
+
| "europe-west1"
|
|
10
|
+
| "europe-west4"
|
|
11
|
+
| "europe-west8"
|
|
12
|
+
| "europe-west9"
|
|
13
|
+
| "me-west1"
|
|
14
|
+
| "us-central1"
|
|
15
|
+
| "us-east1"
|
|
16
|
+
| "us-east4"
|
|
17
|
+
| "us-east5"
|
|
18
|
+
| "us-south1"
|
|
19
|
+
| "us-west1"
|
|
20
|
+
| "asia-east2"
|
|
21
|
+
| "asia-northeast3"
|
|
22
|
+
| "asia-southeast1"
|
|
23
|
+
| "asia-southeast2"
|
|
24
|
+
| "asia-south1"
|
|
25
|
+
| "asia-south2"
|
|
26
|
+
| "australia-southeast1"
|
|
27
|
+
| "australia-southeast2"
|
|
28
|
+
| "europe-central2"
|
|
29
|
+
| "europe-west2"
|
|
30
|
+
| "europe-west3"
|
|
31
|
+
| "europe-west6"
|
|
32
|
+
| "northamerica-northeast1"
|
|
33
|
+
| "northamerica-northeast2"
|
|
34
|
+
| "southamerica-east1"
|
|
35
|
+
| "southamerica-west1"
|
|
36
|
+
| "us-west2"
|
|
37
|
+
| "us-west3"
|
|
38
|
+
| "us-west4";
|
|
39
|
+
|
|
40
|
+
export type DeployConfigCloudRunCloudSql = {
|
|
41
|
+
type: "unmanaged";
|
|
42
|
+
instanceConnectionName: string;
|
|
43
|
+
/**
|
|
44
|
+
* the database username, defaults to "postgres"
|
|
45
|
+
*/
|
|
46
|
+
dbUser?: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* the prefix of the database, the full db name is this plus the environment slug prefix plus the componentName
|
|
50
|
+
*
|
|
51
|
+
* defaults to customerName-appName
|
|
52
|
+
*/
|
|
53
|
+
dbNamePrefix?: string | false;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* the base name of the db, defaults to the componentName
|
|
57
|
+
*/
|
|
58
|
+
dbBaseName?: string;
|
|
59
|
+
/**
|
|
60
|
+
* whether to delete the database if the environment is stopped
|
|
61
|
+
* defaults to true for review envs, to false for every other environment
|
|
62
|
+
*/
|
|
63
|
+
deleteDatabaseOnStop?: boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* add additional query params to the database connection string
|
|
67
|
+
*/
|
|
68
|
+
dbAdditionalQueryParams?: Record<string, string | number> & {
|
|
69
|
+
/**
|
|
70
|
+
* set to 0 for prisma in review or dev apps where you reset the db occasionally without restarting any server
|
|
71
|
+
*/
|
|
72
|
+
statement_cache_size?: number;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
type Memory = `${number}${"M" | "G" | "Mi" | "Gi"}`;
|
|
77
|
+
export type DeployConfigCloudRunService = {
|
|
78
|
+
/**
|
|
79
|
+
* command / entrypoint, fallsback to buildConfig.startcommand
|
|
80
|
+
*/
|
|
81
|
+
command?: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* how many instances to keep around when there are no requests. defaults to 0.
|
|
85
|
+
* Set to 1 for workers
|
|
86
|
+
*/
|
|
87
|
+
minInstances?: number;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* maximum amount of instances. Defaults to 100
|
|
91
|
+
*/
|
|
92
|
+
maxInstances?: number;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* set to true to allways allocate cpu, e.g. for workers. Careful that this is expensive!
|
|
96
|
+
*/
|
|
97
|
+
noCpuThrottling?: true;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* whether to allow public access (defaults to true)
|
|
101
|
+
*/
|
|
102
|
+
allowUnauthenticated?: boolean;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* memory limit. Defaults to 512MB
|
|
106
|
+
*/
|
|
107
|
+
memory?: Memory;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type DeployConfigCloudRunJobBase = {
|
|
111
|
+
/**
|
|
112
|
+
* command
|
|
113
|
+
*/
|
|
114
|
+
command: string;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* memory limit of the job, defaults to 51Mi
|
|
118
|
+
*/
|
|
119
|
+
memory?: `${number}${"M" | "G" | "Mi" | "Gi"}`;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
type Minute = string;
|
|
123
|
+
type Hour = string;
|
|
124
|
+
type DayOfMonth = string;
|
|
125
|
+
type DayOfWeek = string;
|
|
126
|
+
type Month = string;
|
|
127
|
+
export type DeployConfigCloudRunJobWithSchedule =
|
|
128
|
+
DeployConfigCloudRunJobBase & {
|
|
129
|
+
when: "schedule";
|
|
130
|
+
schedule: `${Minute} ${Hour} ${DayOfMonth} ${Month} ${DayOfWeek}`;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export type DeployConfigCloudRunJobNormal = DeployConfigCloudRunJobBase & {
|
|
134
|
+
when: "manual" | "preDeploy" | "postDeploy";
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export type DeployConfigCloudRunJob =
|
|
138
|
+
| DeployConfigCloudRunJobNormal
|
|
139
|
+
| DeployConfigCloudRunJobWithSchedule;
|
|
140
|
+
|
|
141
|
+
export type DeployConfigCloudRun = {
|
|
142
|
+
/**
|
|
143
|
+
* EXPERIMENTAL cloud run deployment.
|
|
144
|
+
*
|
|
145
|
+
* This will deploy a cloud run service.
|
|
146
|
+
*
|
|
147
|
+
* Requires that cloud run is enabled on the project, as well as cloud run api and artifacts registry.
|
|
148
|
+
*/
|
|
149
|
+
type: "google-cloudrun";
|
|
150
|
+
/**
|
|
151
|
+
* the google cloud porject id
|
|
152
|
+
*/
|
|
153
|
+
projectId: string;
|
|
154
|
+
/**
|
|
155
|
+
* the region. Set to europe-west6 for switzerland
|
|
156
|
+
*/
|
|
157
|
+
region: Gcloudregion;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* whether to enable the service, defaults to true
|
|
161
|
+
*/
|
|
162
|
+
service?: boolean | DeployConfigCloudRunService;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* deploy additional services with different entry pointss
|
|
166
|
+
*/
|
|
167
|
+
additionalServices?: {
|
|
168
|
+
[name: string]: DeployConfigCloudRunService;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
jobs?: {
|
|
172
|
+
[name: string]: DeployConfigCloudRunJob | false | null;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* add cloudSql
|
|
177
|
+
*/
|
|
178
|
+
cloudSql?: DeployConfigCloudRunCloudSql | false;
|
|
179
|
+
} & DeployConfigBase;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DeployConfigCustom } from "./custom";
|
|
2
|
+
import type { DeployConfigDockerTag } from "./dockerTag";
|
|
3
|
+
import type { DeployConfigCloudRun } from "./googleCloudRun";
|
|
4
|
+
import type { DeployConfigKubernetes } from "./kubernetes";
|
|
5
|
+
|
|
6
|
+
export * from "./custom";
|
|
7
|
+
export * from "./googleCloudRun";
|
|
8
|
+
export * from "./kubernetes";
|
|
9
|
+
export * from "./dockerTag";
|
|
10
|
+
|
|
11
|
+
export type DeployConfig =
|
|
12
|
+
| DeployConfigKubernetes
|
|
13
|
+
| DeployConfigCustom
|
|
14
|
+
| DeployConfigCloudRun
|
|
15
|
+
| DeployConfigDockerTag;
|
|
16
|
+
|
|
17
|
+
export type DeployConfigType = DeployConfig["type"];
|
|
18
|
+
export type DeployConfigGeneric<T extends DeployConfigType> = Extract<
|
|
19
|
+
DeployConfig,
|
|
20
|
+
{ type: T }
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
export const isOfDeployType = <T extends Array<DeployConfigType>>(
|
|
24
|
+
t: DeployConfig | false,
|
|
25
|
+
...types: T
|
|
26
|
+
): t is Extract<DeployConfig, { type: T[number] }> => {
|
|
27
|
+
return t && types.includes(t.type);
|
|
28
|
+
};
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import type { AllowUnknownProps, DeployConfigBase } from "./base";
|
|
2
|
+
|
|
3
|
+
export type DeployConfigKubernetesClusterGCloud = {
|
|
4
|
+
type: "gcloud";
|
|
5
|
+
/**
|
|
6
|
+
* gcoud name of the cluster
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* google cloud project id
|
|
11
|
+
*/
|
|
12
|
+
projectId: string;
|
|
13
|
+
/**
|
|
14
|
+
* region
|
|
15
|
+
*/
|
|
16
|
+
region: string;
|
|
17
|
+
/**
|
|
18
|
+
* domain of the cluster, for canonical domains without custom host (e.g. review and dev apps)
|
|
19
|
+
*/
|
|
20
|
+
domainCanonical?: string;
|
|
21
|
+
};
|
|
22
|
+
export type DeployConfigKubernetesCluster = DeployConfigKubernetesClusterGCloud; // currently only this
|
|
23
|
+
|
|
24
|
+
export type KubernetesAutoscaleMetricResourceTarget =
|
|
25
|
+
| {
|
|
26
|
+
type: "Utilization";
|
|
27
|
+
averageUtilization: number;
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
type: "AverageValue";
|
|
31
|
+
averageValue: number | string;
|
|
32
|
+
};
|
|
33
|
+
export type KubernetesAutoscaleMetric = {
|
|
34
|
+
type: "Resource";
|
|
35
|
+
resource: {
|
|
36
|
+
name: "cpu" | "memory";
|
|
37
|
+
target: KubernetesAutoscaleMetricResourceTarget;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export type KubernetesAutoscale = {
|
|
41
|
+
minReplicas: number;
|
|
42
|
+
maxReplicas: number;
|
|
43
|
+
/**
|
|
44
|
+
* declare a number of metrics (at least one). Usually you would use cpu as a metric
|
|
45
|
+
*/
|
|
46
|
+
metrics: KubernetesAutoscaleMetric[];
|
|
47
|
+
};
|
|
48
|
+
export type KubernetesResourcesDef = {
|
|
49
|
+
limits?: {
|
|
50
|
+
cpu?: string;
|
|
51
|
+
memory?: string;
|
|
52
|
+
};
|
|
53
|
+
requests?: {
|
|
54
|
+
cpu?: string;
|
|
55
|
+
memory?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
type KubernetesHealthDef = {
|
|
59
|
+
httpGet?: {
|
|
60
|
+
path?: string;
|
|
61
|
+
port?: number;
|
|
62
|
+
httpHeaders?: {
|
|
63
|
+
name: string;
|
|
64
|
+
value: string;
|
|
65
|
+
}[];
|
|
66
|
+
failureThreshold?: number;
|
|
67
|
+
timeoutSeconds?: number;
|
|
68
|
+
periodSeconds?: number;
|
|
69
|
+
successThreshold?: number;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export type KubernetesUpdateStrategy = {
|
|
73
|
+
rollingUpdate: {
|
|
74
|
+
/**
|
|
75
|
+
* how many pods can be created additionally to the target number
|
|
76
|
+
* can be absolute number or percentage.
|
|
77
|
+
* defaults to 1 (kube default is 25%)
|
|
78
|
+
*/
|
|
79
|
+
maxSurge: number | string;
|
|
80
|
+
/**
|
|
81
|
+
* how many pods are allowed to be unavailable
|
|
82
|
+
* can be absolute number or percentage
|
|
83
|
+
* defaults to 0 (kube default is 25%)
|
|
84
|
+
*/
|
|
85
|
+
maxUnavailable: number | string;
|
|
86
|
+
};
|
|
87
|
+
type: "RollingUpdate";
|
|
88
|
+
};
|
|
89
|
+
export type KubernetesWorkerDef = {
|
|
90
|
+
enabled: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* which command to run. defaults to `yarn start`
|
|
93
|
+
*/
|
|
94
|
+
command?: string;
|
|
95
|
+
resources?: KubernetesResourcesDef;
|
|
96
|
+
service?: {
|
|
97
|
+
enabled?: boolean;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type DeployConfigMongodbBase = {
|
|
102
|
+
enabled?: boolean;
|
|
103
|
+
dbName?: string;
|
|
104
|
+
persistence?: {
|
|
105
|
+
/**
|
|
106
|
+
* set premium-rwo for ssd
|
|
107
|
+
*/
|
|
108
|
+
storageClass?: "standard-rwo" | "premium-rwo";
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* size of the volume, defaults to 8Gi
|
|
112
|
+
*/
|
|
113
|
+
size?: string;
|
|
114
|
+
};
|
|
115
|
+
resources?: KubernetesResourcesDef;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type DeployConfigMongodbStandalone = {
|
|
119
|
+
architecture: "standalone";
|
|
120
|
+
};
|
|
121
|
+
export type DeployConfigMongodbReplicaset = {
|
|
122
|
+
architecture: "replicaset";
|
|
123
|
+
/**
|
|
124
|
+
* defaults to 2
|
|
125
|
+
*/
|
|
126
|
+
replicaCount?: number;
|
|
127
|
+
};
|
|
128
|
+
export type DeployConfigMongodb = DeployConfigMongodbBase &
|
|
129
|
+
(DeployConfigMongodbStandalone | DeployConfigMongodbReplicaset);
|
|
130
|
+
|
|
131
|
+
export type DeployConfigKubernetesValues = AllowUnknownProps<{
|
|
132
|
+
/**
|
|
133
|
+
* enable cloudsql db. Currently you have to manually set it up
|
|
134
|
+
*/
|
|
135
|
+
cloudsql?: {
|
|
136
|
+
enabled: boolean;
|
|
137
|
+
instanceId?: string;
|
|
138
|
+
projectId?: string;
|
|
139
|
+
region?: string;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* enable mongodb. The mongodb is deployed using a helm chart.
|
|
143
|
+
* See https://github.com/bitnami/charts/tree/master/bitnami/mongodb
|
|
144
|
+
*/
|
|
145
|
+
mongodb?: DeployConfigMongodb;
|
|
146
|
+
/**
|
|
147
|
+
* enable mailhog. Mailhog is a virtual mail server that catches all outgoing mailsl and show them in a mailbox.
|
|
148
|
+
* This is great for development as it prevents to accidentially send out real emails and helps with debugging outgoing mails.
|
|
149
|
+
*
|
|
150
|
+
* It will automaticaly inject a MAIL_URL env var.
|
|
151
|
+
*
|
|
152
|
+
* Turn it of for production.
|
|
153
|
+
*/
|
|
154
|
+
mailhog?: {
|
|
155
|
+
enabled: boolean;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* post-install/upgrade jobs. These use the app image and have all env vars available.
|
|
159
|
+
* Typically used for migrations and seeds
|
|
160
|
+
*/
|
|
161
|
+
jobs?: Record<
|
|
162
|
+
string,
|
|
163
|
+
| false
|
|
164
|
+
| AllowUnknownProps<{
|
|
165
|
+
/**
|
|
166
|
+
* the command to execute
|
|
167
|
+
*/
|
|
168
|
+
command: string;
|
|
169
|
+
/**
|
|
170
|
+
* comma-separated list of helm hooks, see https://helm.sh/docs/topics/charts_hooks/
|
|
171
|
+
*
|
|
172
|
+
* defaults to post-install,post-upgrade
|
|
173
|
+
*/
|
|
174
|
+
hook?: string;
|
|
175
|
+
}>
|
|
176
|
+
>;
|
|
177
|
+
/**
|
|
178
|
+
* cronjobs that run periodically. These use the app image have all env vars available.
|
|
179
|
+
*/
|
|
180
|
+
cronjobs?: Record<
|
|
181
|
+
string,
|
|
182
|
+
| false
|
|
183
|
+
| AllowUnknownProps<{
|
|
184
|
+
schedule: string;
|
|
185
|
+
command: string;
|
|
186
|
+
concurrencyPolicy?: "Forbid" | "Allow" | "Replace";
|
|
187
|
+
}>
|
|
188
|
+
>;
|
|
189
|
+
/**
|
|
190
|
+
* configuration for the application ("Deployment" in kubernetes)
|
|
191
|
+
*/
|
|
192
|
+
application?:
|
|
193
|
+
| false
|
|
194
|
+
| AllowUnknownProps<{
|
|
195
|
+
/**
|
|
196
|
+
* command to start, defaults to build's startCommand
|
|
197
|
+
*/
|
|
198
|
+
command?: string;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* enable, disable app deployment, defaults to true
|
|
202
|
+
*/
|
|
203
|
+
enabled?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* redirects
|
|
206
|
+
*/
|
|
207
|
+
redirects?: AllowUnknownProps<{ host: string }>[];
|
|
208
|
+
/**
|
|
209
|
+
* Host aliases
|
|
210
|
+
*/
|
|
211
|
+
hostAliases?: string[];
|
|
212
|
+
/**
|
|
213
|
+
* how many pods will be started
|
|
214
|
+
*/
|
|
215
|
+
replicas?: number;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* autoscale the pods horizontally
|
|
219
|
+
*/
|
|
220
|
+
autoscale?: KubernetesAutoscale;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* the update strategy, see https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#rolling-update-deployment
|
|
224
|
+
*/
|
|
225
|
+
updateStrategy?: KubernetesUpdateStrategy;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* kubernetes resources
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
resources?: KubernetesResourcesDef;
|
|
232
|
+
healthRoute?: string;
|
|
233
|
+
startupProbe?: KubernetesHealthDef;
|
|
234
|
+
readinessProbe?: KubernetesHealthDef;
|
|
235
|
+
livenessProbe?: KubernetesHealthDef;
|
|
236
|
+
/**
|
|
237
|
+
* specify a worker. A worker is a separate deployment that runs continously in the background.
|
|
238
|
+
* The worker pod can use the same entry point as the app or a different one (specify command).
|
|
239
|
+
* It has the same environment variables as the application and an additional IS_WORKER="true" variable
|
|
240
|
+
*/
|
|
241
|
+
worker?: KubernetesWorkerDef;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* kubernetes resources for jobs and cronjobs
|
|
245
|
+
*/
|
|
246
|
+
jobDefaults?: {
|
|
247
|
+
resources: KubernetesResourcesDef;
|
|
248
|
+
};
|
|
249
|
+
}>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* load secrets from other components.
|
|
253
|
+
* Use this only in cases where the secret is not known on pipeline-time
|
|
254
|
+
* and only if the component is also in the same cluster.
|
|
255
|
+
*
|
|
256
|
+
* a typical case is reusing mongo_url from other component
|
|
257
|
+
*
|
|
258
|
+
* also make sure that the other component deploys first
|
|
259
|
+
*
|
|
260
|
+
* in all other cases use normal env var handling
|
|
261
|
+
*/
|
|
262
|
+
secretsFromOtherComponent?: {
|
|
263
|
+
[envVar: string]: string;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* map another services internal endpoint into a env var.
|
|
268
|
+
*/
|
|
269
|
+
mapServiceUrlToEnv?: {
|
|
270
|
+
[envVar: string]: string;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Mount secrets as files in the filesystem.
|
|
274
|
+
* These secrets are still available as env vars, but will contain the path of the file instead
|
|
275
|
+
*
|
|
276
|
+
* @deprecated this will be removed in the future, because its very niche and not used
|
|
277
|
+
*/
|
|
278
|
+
secretsAsFile?: string[];
|
|
279
|
+
}>;
|
|
280
|
+
|
|
281
|
+
export type DeployConfigKubernetes = {
|
|
282
|
+
type: "kubernetes";
|
|
283
|
+
/**
|
|
284
|
+
* cluster config to use.
|
|
285
|
+
*/
|
|
286
|
+
cluster: DeployConfigKubernetesCluster;
|
|
287
|
+
/**
|
|
288
|
+
* prints out debug info (helm --debug)
|
|
289
|
+
*/
|
|
290
|
+
debug?: boolean;
|
|
291
|
+
additionalHelmArgs?: string[];
|
|
292
|
+
/**
|
|
293
|
+
* values to configure the app
|
|
294
|
+
*/
|
|
295
|
+
values?: DeployConfigKubernetesValues;
|
|
296
|
+
/**
|
|
297
|
+
* Custom Helm chart location.
|
|
298
|
+
* Not recommended to use.
|
|
299
|
+
*/
|
|
300
|
+
chartName?: string;
|
|
301
|
+
} & DeployConfigBase;
|
package/src/deploy/utils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Config, Context } from "../types";
|
|
2
|
-
import { DeployConfigKubernetesCluster
|
|
1
|
+
import type { Config, Context } from "../types";
|
|
2
|
+
import type { DeployConfigKubernetesCluster } from "./types";
|
|
3
|
+
import { isOfDeployType } from "./types";
|
|
3
4
|
|
|
4
5
|
export const getFullKubernetesClusterName = (
|
|
5
6
|
cluster: DeployConfigKubernetesCluster
|
|
@@ -22,6 +23,9 @@ export const contextIsStoppable = (context: Context) => {
|
|
|
22
23
|
return true;
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
if (isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
25
29
|
if (isOfDeployType(deployConfig, "custom") && deployConfig.stopScript) {
|
|
26
30
|
return true;
|
|
27
31
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommitInfo } from "../../types";
|
|
2
|
+
import { getBuildId } from "./getBuildId";
|
|
3
|
+
export const getBaseCommitInfo = async (): Promise<
|
|
4
|
+
Omit<CommitInfo, "trigger">
|
|
5
|
+
> => ({
|
|
6
|
+
refName: process.env.CI_COMMIT_REF_NAME ?? "unknown",
|
|
7
|
+
reviewSlug: process.env.CI_MERGE_REQUEST_IID
|
|
8
|
+
? `mr${process.env.CI_MERGE_REQUEST_IID}`
|
|
9
|
+
: "unknown",
|
|
10
|
+
buildTime: new Date().toISOString(),
|
|
11
|
+
buildId: await getBuildId(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getAllEnvsByTrigger } from "../config";
|
|
2
|
+
import type { Config, PipelineTrigger } from "../types";
|
|
3
|
+
import type { CatladderJob } from "../types/jobs";
|
|
4
|
+
import { createJobsForComponent } from "./createJobsForComponent";
|
|
5
|
+
|
|
6
|
+
export type AllCatladderJobs = {
|
|
7
|
+
[componentName: string]: {
|
|
8
|
+
[env: string]: Array<CatladderJob>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export const createAllJobs = async (
|
|
12
|
+
config: Config,
|
|
13
|
+
trigger: PipelineTrigger
|
|
14
|
+
): Promise<AllCatladderJobs> => {
|
|
15
|
+
return Object.fromEntries(
|
|
16
|
+
await Promise.all(
|
|
17
|
+
Object.keys(config.components).map(async (componentName) => {
|
|
18
|
+
const envs = getAllEnvsByTrigger(config, componentName, trigger);
|
|
19
|
+
return [
|
|
20
|
+
componentName,
|
|
21
|
+
Object.fromEntries(
|
|
22
|
+
await Promise.all(
|
|
23
|
+
envs.map(async (env) => [
|
|
24
|
+
env,
|
|
25
|
+
await createJobsForComponent(
|
|
26
|
+
config,
|
|
27
|
+
componentName,
|
|
28
|
+
env,
|
|
29
|
+
trigger
|
|
30
|
+
),
|
|
31
|
+
])
|
|
32
|
+
)
|
|
33
|
+
),
|
|
34
|
+
];
|
|
35
|
+
})
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -1,36 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getAllEnvsInAllComponents } from "../config";
|
|
2
2
|
import { RULES_ALWAYS } from "../rules";
|
|
3
3
|
import { getRunnerImage } from "../runner";
|
|
4
|
-
import { GitlabPipeline, Pipeline,
|
|
5
|
-
import { Config, PipelineTrigger } from "../types/config";
|
|
6
|
-
import {
|
|
4
|
+
import type { GitlabPipeline, Pipeline, PipelineType } from "../types";
|
|
5
|
+
import type { Config, PipelineTrigger } from "../types/config";
|
|
6
|
+
import { BASE_STAGES } from "../types/jobs";
|
|
7
|
+
import { createAllJobs } from "./createAllJobs";
|
|
8
|
+
import { createGitlabJobs } from "./gitlab/createGitlabJobs";
|
|
7
9
|
|
|
8
|
-
const baseStages = ["setup", "test", "build", "deploy", "verify", "stop"];
|
|
9
10
|
export const createChildPipeline = async <T extends PipelineType>(
|
|
10
11
|
type: T,
|
|
11
12
|
trigger: PipelineTrigger,
|
|
12
13
|
config: Config
|
|
13
14
|
): Promise<Pipeline<T>> => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
// 2. write the triggering pipeline
|
|
17
|
-
const jobs = await components.reduce<Promise<Record<string, PipelineJob<T>>>>(
|
|
18
|
-
async (acc, componentName) => {
|
|
19
|
-
const envs = getAllEnvsByTrigger(config, componentName, trigger);
|
|
20
|
-
return {
|
|
21
|
-
...(await acc),
|
|
22
|
-
...(await createJobs(type, envs, config, componentName, trigger)),
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
Promise.resolve({})
|
|
26
|
-
);
|
|
15
|
+
const jobs = await createAllJobs(config, trigger);
|
|
27
16
|
|
|
28
17
|
// while technically not required, we group different envs in its own stage
|
|
29
18
|
// each job from `createJobs` that is defined as `envMode: "stagePerEnv"` will have `deploy dev`, etc. instead of just `deploy`
|
|
30
19
|
// this is just so that it looks nicer in gitlab and makes running mutliple manual tasks more easy to use
|
|
31
20
|
|
|
32
21
|
const allEnvs = getAllEnvsInAllComponents(config);
|
|
33
|
-
const stages =
|
|
22
|
+
const stages = BASE_STAGES.reduce<string[]>(
|
|
34
23
|
(acc, baseStage) => [
|
|
35
24
|
...acc,
|
|
36
25
|
baseStage,
|
|
@@ -48,7 +37,7 @@ export const createChildPipeline = async <T extends PipelineType>(
|
|
|
48
37
|
rules: RULES_ALWAYS,
|
|
49
38
|
},
|
|
50
39
|
stages,
|
|
51
|
-
jobs,
|
|
40
|
+
jobs: await createGitlabJobs(jobs),
|
|
52
41
|
};
|
|
53
42
|
return pipeline as Pipeline<T>;
|
|
54
43
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isFunction } from "lodash";
|
|
2
|
+
import { BUILD_TYPES } from "../build";
|
|
3
|
+
import { createContext } from "../context";
|
|
4
|
+
import { DEPLOY_TYPES } from "../deploy";
|
|
5
|
+
import type { Config, PipelineTrigger } from "../types/config";
|
|
6
|
+
import type { CommitInfo, Context } from "../types/context";
|
|
7
|
+
import type { CatladderJob } from "../types/jobs";
|
|
8
|
+
import { getBaseCommitInfo } from "./commitInfo/getCommitInfo";
|
|
9
|
+
import { getPackageManagerInfo } from "./packageManager";
|
|
10
|
+
|
|
11
|
+
const injectDefaultVarsInCustomJobs = (
|
|
12
|
+
context: Context,
|
|
13
|
+
jobs: CatladderJob[]
|
|
14
|
+
) =>
|
|
15
|
+
jobs.map(({ variables, ...job }) => ({
|
|
16
|
+
variables: {
|
|
17
|
+
...(context.environment.envVars ?? {}),
|
|
18
|
+
...(variables ?? {}),
|
|
19
|
+
},
|
|
20
|
+
...job,
|
|
21
|
+
}));
|
|
22
|
+
const getCustomJobs = (context: Context) => {
|
|
23
|
+
if (!context.componentConfig.customJobs) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const rawJobs = isFunction(context.componentConfig.customJobs)
|
|
27
|
+
? context.componentConfig.customJobs(context)
|
|
28
|
+
: context.componentConfig.customJobs;
|
|
29
|
+
return injectDefaultVarsInCustomJobs(context, rawJobs);
|
|
30
|
+
};
|
|
31
|
+
const createRawJobs = (context: Context): CatladderJob[] => {
|
|
32
|
+
if (context.componentConfig.deploy === false) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const buildJobs =
|
|
36
|
+
BUILD_TYPES[context.componentConfig.build.type].jobs(context);
|
|
37
|
+
const deployJobs =
|
|
38
|
+
DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context);
|
|
39
|
+
|
|
40
|
+
const customJobs = getCustomJobs(context);
|
|
41
|
+
return [...buildJobs, ...deployJobs, ...customJobs];
|
|
42
|
+
};
|
|
43
|
+
export const createJobsForComponent = async (
|
|
44
|
+
config: Config,
|
|
45
|
+
componentName: string,
|
|
46
|
+
env: string,
|
|
47
|
+
trigger: PipelineTrigger
|
|
48
|
+
): Promise<Array<CatladderJob>> => {
|
|
49
|
+
const commitInfo: CommitInfo = {
|
|
50
|
+
...(await getBaseCommitInfo()),
|
|
51
|
+
trigger,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const packageManagerInfo = await getPackageManagerInfo(config, componentName);
|
|
55
|
+
|
|
56
|
+
const context = await createContext(
|
|
57
|
+
config,
|
|
58
|
+
componentName,
|
|
59
|
+
env,
|
|
60
|
+
commitInfo,
|
|
61
|
+
packageManagerInfo
|
|
62
|
+
);
|
|
63
|
+
return createRawJobs(context);
|
|
64
|
+
};
|