@catladder/pipeline 1.144.0 → 1.145.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/bash/BashExpression.d.ts +40 -0
- package/dist/bash/BashExpression.js +124 -0
- package/dist/bash/bashExpressionPerPipelineType.d.ts +6 -0
- package/dist/bash/bashExpressionPerPipelineType.js +11 -0
- package/dist/bash/bashYaml.d.ts +10 -0
- package/dist/bash/bashYaml.js +46 -0
- package/dist/bash/getInjectVarsScript.d.ts +2 -0
- package/dist/bash/getInjectVarsScript.js +45 -0
- package/dist/bash/replaceAsync.d.ts +2 -0
- package/dist/{pipeline/commitInfo/getCommitInfo.js → bash/replaceAsync.js} +49 -21
- package/dist/build/base/__tests__/createArtifactsConfig.test.js +3 -1
- package/dist/build/base/constants.js +3 -1
- package/dist/build/base/createAppBuildJob.d.ts +2 -1
- package/dist/build/base/createAppBuildJob.js +10 -6
- package/dist/build/base/createArtifactsConfig.d.ts +1 -1
- package/dist/build/base/createArtifactsConfig.js +3 -1
- package/dist/build/base/index.js +3 -1
- package/dist/build/base/writeBuildInfo.js +4 -3
- package/dist/build/base/writeDotEnv.js +12 -3
- package/dist/build/custom/__tests__/testJob.test.js +3 -1
- package/dist/build/custom/buildJob.js +4 -12
- package/dist/build/custom/index.js +3 -1
- package/dist/build/custom/testJob.d.ts +1 -1
- package/dist/build/custom/testJob.js +18 -14
- package/dist/build/docker.d.ts +5 -31
- package/dist/build/docker.js +16 -9
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +13 -7
- package/dist/build/node/buildJob.js +4 -12
- package/dist/build/node/cache.js +6 -3
- package/dist/build/node/constants.js +3 -1
- package/dist/build/node/index.js +3 -1
- package/dist/build/node/meteor.js +5 -2
- package/dist/build/node/testJob.js +18 -14
- package/dist/build/node/yarn.d.ts +3 -2
- package/dist/build/node/yarn.js +6 -3
- package/dist/build/rails/build.js +3 -1
- package/dist/build/rails/index.js +3 -1
- package/dist/build/rails/test.js +15 -11
- package/dist/build/sbom.js +3 -1
- package/dist/build/types.d.ts +24 -18
- package/dist/build/types.js +3 -1
- package/dist/bundles/catladder-gitlab/index.js +3 -3
- package/dist/catladder-gitlab.js +10 -54
- package/dist/config/__tests__/configruedEnvs.test.js +3 -1
- package/dist/config/configruedEnvs.js +3 -1
- package/dist/config/index.js +13 -7
- package/dist/config/readConfig.js +6 -5
- package/dist/constants.js +5 -3
- package/dist/context/__tests__/resolveReferences.test.js +40 -8
- package/dist/context/getBuildInfoVariables.d.ts +7 -0
- package/dist/context/getBuildInfoVariables.js +29 -0
- package/dist/context/getEnvConfig.js +3 -1
- package/dist/context/getEnvType.js +3 -1
- package/dist/context/getEnvironment.d.ts +3 -3
- package/dist/context/getEnvironment.js +10 -14
- package/dist/context/getEnvironmentContext.d.ts +7 -3
- package/dist/context/getEnvironmentContext.js +21 -11
- package/dist/context/getEnvironmentVariables.d.ts +26 -5
- package/dist/context/getEnvironmentVariables.js +41 -25
- package/dist/context/getLabels.js +4 -2
- package/dist/context/getReviewSlug.d.ts +4 -0
- package/dist/context/getReviewSlug.js +22 -0
- package/dist/context/index.d.ts +12 -3
- package/dist/context/index.js +21 -15
- package/dist/context/resolveReferences.d.ts +3 -1
- package/dist/context/resolveReferences.js +53 -21
- package/dist/context/transformJobOnlyVars.d.ts +5 -2
- package/dist/context/transformJobOnlyVars.js +4 -2
- package/dist/context/utils/envVars.d.ts +1 -1
- package/dist/context/utils/envVars.js +5 -2
- package/dist/defaults/index.js +3 -1
- package/dist/deploy/base/deploy.d.ts +1 -1
- package/dist/deploy/base/deploy.js +12 -11
- package/dist/deploy/base/index.js +3 -1
- package/dist/deploy/base/rollback.d.ts +1 -1
- package/dist/deploy/base/rollback.js +13 -9
- package/dist/deploy/base/stop.d.ts +1 -1
- package/dist/deploy/base/stop.js +16 -11
- package/dist/deploy/base/types.d.ts +1 -1
- package/dist/deploy/base/types.js +3 -1
- package/dist/deploy/base/variables.js +3 -1
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +2 -1
- package/dist/deploy/cloudRun/artifactsRegistry.js +6 -4
- package/dist/deploy/cloudRun/cleanup.js +3 -1
- package/dist/deploy/cloudRun/cloudRunRevisions.js +3 -1
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +8 -5
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +6 -3
- package/dist/deploy/cloudRun/createJobs/common.d.ts +3 -3
- package/dist/deploy/cloudRun/createJobs/common.js +3 -1
- package/dist/deploy/cloudRun/createJobs/constants.d.ts +1 -0
- package/dist/deploy/cloudRun/createJobs/constants.js +7 -0
- package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +9 -2
- package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +3 -1
- package/dist/deploy/cloudRun/createJobs/index.js +25 -8
- package/dist/deploy/cloudRun/createJobs/volumes.js +3 -1
- package/dist/deploy/cloudRun/index.js +5 -3
- package/dist/deploy/cloudRun/utils/createArgsString.d.ts +2 -1
- package/dist/deploy/cloudRun/utils/createArgsString.js +3 -1
- package/dist/deploy/cloudRun/utils/database.js +13 -13
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +3 -1
- package/dist/deploy/cloudRun/utils/getServiceName.d.ts +1 -1
- package/dist/deploy/cloudRun/utils/getServiceName.js +3 -1
- package/dist/deploy/cloudRun/utils/jobName.d.ts +2 -1
- package/dist/deploy/cloudRun/utils/jobName.js +4 -2
- package/dist/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.js +3 -1
- package/dist/deploy/cloudSql/utils.d.ts +2 -1
- package/dist/deploy/cloudSql/utils.js +7 -2
- package/dist/deploy/custom/deployJob.js +3 -1
- package/dist/deploy/custom/index.js +3 -1
- package/dist/deploy/dockerTag/deployJob.js +3 -1
- package/dist/deploy/dockerTag/index.js +3 -1
- package/dist/deploy/index.d.ts +4 -3
- package/dist/deploy/index.js +13 -7
- package/dist/deploy/kubernetes/additionalSecretKeys.js +3 -1
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -2
- package/dist/deploy/kubernetes/cloudSql/index.js +6 -4
- package/dist/deploy/kubernetes/deployJob.js +22 -15
- package/dist/deploy/kubernetes/index.js +51 -14
- package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -2
- package/dist/deploy/kubernetes/kubeEnv.js +7 -4
- package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeValues.js +3 -2
- package/dist/deploy/kubernetes/mongodb.js +3 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +2 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +3 -1
- package/dist/deploy/sbom.js +3 -1
- package/dist/deploy/types/base.d.ts +8 -2
- package/dist/deploy/types/base.js +3 -1
- package/dist/deploy/types/custom.d.ts +1 -1
- package/dist/deploy/types/custom.js +3 -1
- package/dist/deploy/types/dockerTag.d.ts +1 -1
- package/dist/deploy/types/dockerTag.js +3 -1
- package/dist/deploy/types/googleCloudRun.d.ts +19 -18
- package/dist/deploy/types/googleCloudRun.js +3 -1
- package/dist/deploy/types/index.d.ts +6 -6
- package/dist/deploy/types/index.js +13 -7
- package/dist/deploy/types/kubernetes.d.ts +22 -22
- package/dist/deploy/types/kubernetes.js +3 -1
- package/dist/deploy/utils.js +3 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +16 -9
- package/dist/packageInfos.d.ts +2 -0
- package/dist/packageInfos.js +14 -0
- package/dist/pipeline/createAllJobs.d.ts +13 -5
- package/dist/pipeline/createAllJobs.js +21 -10
- package/dist/pipeline/createChildPipeline.d.ts +1 -1
- package/dist/pipeline/createChildPipeline.js +24 -7
- package/dist/pipeline/createJobsForComponent.d.ts +3 -3
- package/dist/pipeline/createJobsForComponent.js +19 -18
- package/dist/pipeline/createMainPipeline.d.ts +3 -0
- package/dist/pipeline/createMainPipeline.js +248 -0
- package/dist/pipeline/generatePipelineFiles.d.ts +2 -0
- package/dist/pipeline/generatePipelineFiles.js +178 -0
- package/dist/pipeline/getPipelineStages.js +3 -1
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +15 -5
- package/dist/pipeline/gitlab/createGitlabJobs.js +98 -25
- package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +7 -2
- package/dist/pipeline/gitlab/createGitlabPipeline.js +34 -17
- package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.d.ts +1 -0
- package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.js +29 -0
- package/dist/pipeline/gitlab/gitlabReleaseJobs.d.ts +33 -0
- package/dist/pipeline/gitlab/gitlabReleaseJobs.js +24 -0
- package/dist/pipeline/index.d.ts +3 -1
- package/dist/pipeline/index.js +16 -8
- package/dist/pipeline/packageManager.js +4 -2
- package/dist/pipeline/yarn/yarnUtils.js +6 -4
- package/dist/rules/index.d.ts +4 -1
- package/dist/rules/index.js +25 -18
- package/dist/runner/index.d.ts +1 -1
- package/dist/runner/index.js +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +18 -15
- package/dist/types/config.js +5 -2
- package/dist/types/context.d.ts +37 -32
- package/dist/types/context.js +3 -1
- package/dist/types/environmentContext.d.ts +11 -7
- package/dist/types/environmentContext.js +3 -1
- package/dist/types/gitlab-ci-yml.d.ts +30 -30
- package/dist/types/gitlab-ci-yml.js +3 -2
- package/dist/types/gitlab-types.d.ts +4 -6
- package/dist/types/gitlab-types.js +3 -1
- package/dist/types/index.js +13 -7
- package/dist/types/jobs.d.ts +23 -6
- package/dist/types/jobs.js +3 -1
- package/dist/types/pipeline.d.ts +4 -3
- package/dist/types/pipeline.js +3 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/utils.js +3 -1
- package/dist/utils/gitlab.js +3 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/writeFiles.d.ts +7 -0
- package/dist/{pipeline/commitInfo/getBuildId.js → utils/writeFiles.js} +39 -22
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +462 -366
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-no-service.ts.snap +501 -393
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +489 -392
- package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +501 -401
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +1155 -915
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +1116 -888
- package/examples/__snapshots__/cloud-run-with-worker.ts.snap +482 -386
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +452 -356
- package/examples/__snapshots__/custom-build-job.ts.snap +434 -350
- package/examples/__snapshots__/custom-deploy.ts.snap +319 -223
- package/examples/__snapshots__/custom-envs.ts.snap +123 -81
- package/examples/__snapshots__/custom-sbom-java.ts.snap +434 -350
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +846 -969
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +886 -957
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +894 -969
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +1626 -1728
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +974 -1137
- package/examples/__snapshots__/local-dot-env.ts.snap +480 -384
- package/examples/__snapshots__/meteor-kubernetes.ts.snap +906 -1069
- package/examples/__snapshots__/multiline-var.ts.snap +4500 -0
- package/examples/__snapshots__/native-app.ts.snap +706 -578
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +480 -384
- package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +488 -384
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1656 -1942
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +287 -231
- package/examples/custom-deploy.ts +7 -7
- package/examples/multiline-var.ts +64 -0
- package/package.json +5 -8
- package/src/bash/BashExpression.ts +81 -0
- package/src/bash/bashExpressionPerPipelineType.ts +16 -0
- package/src/bash/bashYaml.ts +46 -0
- package/src/bash/getInjectVarsScript.ts +12 -0
- package/src/bash/replaceAsync.ts +50 -0
- package/src/build/base/createAppBuildJob.ts +6 -2
- package/src/build/base/writeBuildInfo.ts +1 -1
- package/src/build/base/writeDotEnv.ts +6 -1
- package/src/build/custom/buildJob.ts +2 -4
- package/src/build/custom/testJob.ts +3 -2
- package/src/build/docker.ts +15 -7
- package/src/build/node/buildJob.ts +1 -3
- package/src/build/node/testJob.ts +3 -2
- package/src/build/node/yarn.ts +9 -4
- package/src/build/rails/test.ts +2 -1
- package/src/build/types.ts +8 -1
- package/src/catladder-gitlab.ts +8 -55
- package/src/config/readConfig.ts +2 -3
- package/src/constants.ts +5 -2
- package/src/context/__tests__/resolveReferences.test.ts +11 -6
- package/src/context/getBuildInfoVariables.ts +40 -0
- package/src/context/getEnvironment.ts +7 -30
- package/src/context/getEnvironmentContext.ts +25 -29
- package/src/context/getEnvironmentVariables.ts +61 -36
- package/src/context/getReviewSlug.ts +27 -0
- package/src/context/index.ts +24 -23
- package/src/context/resolveReferences.ts +28 -8
- package/src/context/transformJobOnlyVars.ts +5 -2
- package/src/context/utils/envVars.ts +2 -1
- package/src/deploy/base/deploy.ts +20 -18
- package/src/deploy/base/rollback.ts +8 -10
- package/src/deploy/base/stop.ts +8 -9
- package/src/deploy/cloudRun/artifactsRegistry.ts +9 -4
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +12 -7
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +3 -2
- package/src/deploy/cloudRun/createJobs/constants.ts +1 -0
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +20 -2
- package/src/deploy/cloudRun/createJobs/index.ts +17 -8
- package/src/deploy/cloudRun/index.ts +14 -6
- package/src/deploy/cloudRun/utils/createArgsString.ts +2 -1
- package/src/deploy/cloudRun/utils/database.ts +2 -2
- package/src/deploy/cloudRun/utils/jobName.ts +7 -2
- package/src/deploy/cloudSql/utils.ts +12 -9
- package/src/deploy/index.ts +2 -1
- package/src/deploy/kubernetes/cloudSql/index.ts +3 -2
- package/src/deploy/kubernetes/deployJob.ts +24 -10
- package/src/deploy/kubernetes/index.ts +15 -8
- package/src/deploy/kubernetes/kubeEnv.ts +8 -6
- package/src/deploy/kubernetes/kubeValues.ts +0 -1
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +2 -1
- package/src/deploy/types/base.ts +6 -0
- package/src/deploy/types/googleCloudRun.ts +2 -0
- package/src/index.ts +2 -1
- package/src/packageInfos.ts +10 -0
- package/src/pipeline/createAllJobs.ts +24 -10
- package/src/pipeline/createChildPipeline.ts +19 -8
- package/src/pipeline/createJobsForComponent.ts +14 -22
- package/src/pipeline/createMainPipeline.ts +88 -0
- package/src/pipeline/generatePipelineFiles.ts +29 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +174 -51
- package/src/pipeline/gitlab/createGitlabPipeline.ts +16 -14
- package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +46 -0
- package/src/pipeline/gitlab/gitlabReleaseJobs.ts +20 -0
- package/src/pipeline/index.ts +2 -0
- package/src/rules/index.ts +15 -9
- package/src/types/config.ts +11 -2
- package/src/types/context.ts +39 -26
- package/src/types/environmentContext.ts +12 -6
- package/src/types/gitlab-ci-yml.ts +0 -1
- package/src/types/gitlab-types.ts +5 -4
- package/src/types/jobs.ts +28 -3
- package/src/types/pipeline.ts +4 -0
- package/src/utils/writeFiles.ts +40 -0
- package/dist/deploy/cloudRun/createJobs/variables.d.ts +0 -5
- package/dist/deploy/cloudRun/createJobs/variables.js +0 -19
- package/dist/pipeline/commitInfo/getBuildId.d.ts +0 -6
- package/dist/pipeline/commitInfo/getCommitInfo.d.ts +0 -2
- package/src/deploy/cloudRun/createJobs/variables.ts +0 -21
- package/src/pipeline/commitInfo/getBuildId.ts +0 -17
- package/src/pipeline/commitInfo/getCommitInfo.ts +0 -15
|
@@ -15,7 +15,13 @@ export const DEPLOY_JOB_NAME = "🚀 Deploy";
|
|
|
15
15
|
|
|
16
16
|
export type DeployJobDefinition = Pick<
|
|
17
17
|
CatladderJob,
|
|
18
|
-
|
|
18
|
+
| "script"
|
|
19
|
+
| "variables"
|
|
20
|
+
| "image"
|
|
21
|
+
| "cache"
|
|
22
|
+
| "artifacts"
|
|
23
|
+
| "services"
|
|
24
|
+
| "runnerVariables"
|
|
19
25
|
>;
|
|
20
26
|
export const createDeployJob = (
|
|
21
27
|
context: Context,
|
|
@@ -77,19 +83,11 @@ export const createDeployJob = (
|
|
|
77
83
|
artifacts: false,
|
|
78
84
|
},
|
|
79
85
|
], // workaround for https://gitlab.com/gitlab-org/gitlab/-/issues/220758
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
? {
|
|
83
|
-
when: "on_success",
|
|
84
|
-
}
|
|
85
|
-
: {
|
|
86
|
-
when: "manual",
|
|
87
|
-
},
|
|
88
|
-
],
|
|
86
|
+
when: whenDeploy === "auto" ? "on_success" : "manual",
|
|
87
|
+
|
|
89
88
|
allow_failure: whenDeploy === "manual" ? true : false,
|
|
90
89
|
stage: "deploy",
|
|
91
90
|
variables: {
|
|
92
|
-
...DEPLOY_RUNNER_VARIABLES,
|
|
93
91
|
...context.environment.envVars,
|
|
94
92
|
...(hasDocker ? getDockerImageVariables(context) : {}),
|
|
95
93
|
...context.environment.jobOnlyVars.deploy.envVars,
|
|
@@ -98,15 +96,19 @@ export const createDeployJob = (
|
|
|
98
96
|
: {}),
|
|
99
97
|
...jobDefinition.variables,
|
|
100
98
|
},
|
|
101
|
-
|
|
102
|
-
...
|
|
103
|
-
...(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
auto_stop_in: autoStop,
|
|
107
|
-
}
|
|
99
|
+
runnerVariables: {
|
|
100
|
+
...DEPLOY_RUNNER_VARIABLES,
|
|
101
|
+
...(jobDefinition.runnerVariables ?? {}),
|
|
102
|
+
...(context.componentConfig.deploy
|
|
103
|
+
? context.componentConfig.deploy.runnerVariables ?? {}
|
|
108
104
|
: {}),
|
|
109
105
|
},
|
|
106
|
+
environment: isStoppable
|
|
107
|
+
? {
|
|
108
|
+
on_stop: STOP_JOB_NAME,
|
|
109
|
+
auto_stop_in: autoStop,
|
|
110
|
+
}
|
|
111
|
+
: undefined,
|
|
110
112
|
jobTags: context.componentConfig.deploy
|
|
111
113
|
? context.componentConfig.deploy.jobTags
|
|
112
114
|
: undefined,
|
|
@@ -6,7 +6,7 @@ export const ROLLBACK_JOB_NAME = "↩️ Rollback ⚠️";
|
|
|
6
6
|
|
|
7
7
|
export type RollbackJobDefinition = Pick<
|
|
8
8
|
CatladderJob,
|
|
9
|
-
"script" | "variables" | "image"
|
|
9
|
+
"script" | "variables" | "runnerVariables" | "image"
|
|
10
10
|
>;
|
|
11
11
|
export const createRollbackJob = (
|
|
12
12
|
context: Context,
|
|
@@ -17,21 +17,19 @@ export const createRollbackJob = (
|
|
|
17
17
|
image: jobDefinition.image,
|
|
18
18
|
envMode: "stagePerEnv", // makes it easier to run manual tasks er env
|
|
19
19
|
needs: [], // can be executed even if the deploy job failed
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
when: "manual",
|
|
23
|
-
allow_failure: true,
|
|
24
|
-
},
|
|
25
|
-
],
|
|
20
|
+
allow_failure: true,
|
|
21
|
+
when: "manual",
|
|
26
22
|
variables: {
|
|
27
|
-
...DEPLOY_RUNNER_VARIABLES,
|
|
28
23
|
...context.environment.jobOnlyVars.deploy.envVars,
|
|
29
|
-
GIT_STRATEGY: "none",
|
|
30
24
|
...jobDefinition.variables,
|
|
31
25
|
},
|
|
26
|
+
runnerVariables: {
|
|
27
|
+
...DEPLOY_RUNNER_VARIABLES,
|
|
28
|
+
GIT_STRATEGY: "none",
|
|
29
|
+
...(jobDefinition.runnerVariables ?? {}),
|
|
30
|
+
},
|
|
32
31
|
stage: "rollback",
|
|
33
32
|
environment: {
|
|
34
|
-
...context.environment.gitlabEnvironment,
|
|
35
33
|
action: "access",
|
|
36
34
|
},
|
|
37
35
|
|
package/src/deploy/base/stop.ts
CHANGED
|
@@ -6,7 +6,7 @@ export const STOP_JOB_NAME = "🛑 Stop ⚠️";
|
|
|
6
6
|
|
|
7
7
|
export type StopJobDefinition = Pick<
|
|
8
8
|
CatladderJob,
|
|
9
|
-
"script" | "variables" | "image"
|
|
9
|
+
"script" | "variables" | "image" | "runnerVariables"
|
|
10
10
|
>;
|
|
11
11
|
export const createStopJob = (
|
|
12
12
|
context: Context,
|
|
@@ -17,26 +17,25 @@ export const createStopJob = (
|
|
|
17
17
|
image: jobDefinition.image,
|
|
18
18
|
envMode: "stagePerEnv", // makes it easier to run manual tasks er env
|
|
19
19
|
needs: [], // can be executed even if the deploy job failed
|
|
20
|
+
allow_failure: true,
|
|
21
|
+
when: "manual", // stop is always manual
|
|
20
22
|
rules: [
|
|
21
23
|
{
|
|
22
24
|
if: "$CI_COMMIT_BRANCH =~ /^[0-9]+\\.([0-9]+|x)\\.x$/", // automatic on hotfix branches
|
|
23
25
|
when: "on_success",
|
|
24
|
-
allow_failure: true,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
when: "manual",
|
|
28
|
-
allow_failure: true,
|
|
29
26
|
},
|
|
30
27
|
],
|
|
31
28
|
variables: {
|
|
32
|
-
...DEPLOY_RUNNER_VARIABLES,
|
|
33
29
|
...context.environment.jobOnlyVars.deploy.envVars,
|
|
34
|
-
GIT_STRATEGY: "none",
|
|
35
30
|
...jobDefinition.variables,
|
|
36
31
|
},
|
|
32
|
+
runnerVariables: {
|
|
33
|
+
...DEPLOY_RUNNER_VARIABLES,
|
|
34
|
+
GIT_STRATEGY: "none",
|
|
35
|
+
...jobDefinition.runnerVariables,
|
|
36
|
+
},
|
|
37
37
|
stage: "stop",
|
|
38
38
|
environment: {
|
|
39
|
-
...context.environment.gitlabEnvironment,
|
|
40
39
|
action: "stop",
|
|
41
40
|
},
|
|
42
41
|
script: jobDefinition.script,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { StringOrBashExpression } from "../../bash/BashExpression";
|
|
2
|
+
import { joinBashExpressions } from "../../bash/BashExpression";
|
|
1
3
|
import type { Context } from "../../types/context";
|
|
2
4
|
import { allowFailureInScripts } from "../../utils/gitlab";
|
|
3
5
|
import { isOfDeployType } from "../types";
|
|
@@ -46,11 +48,11 @@ export const getArtifactsRegistryImageName = (
|
|
|
46
48
|
context.environment.shortName,
|
|
47
49
|
context.componentName,
|
|
48
50
|
|
|
49
|
-
...(context.environment.
|
|
50
|
-
? [context.
|
|
51
|
+
...(context.environment.reviewSlug && !lecacyReviewImageName
|
|
52
|
+
? [context.environment.reviewSlug]
|
|
51
53
|
: []),
|
|
52
54
|
];
|
|
53
|
-
return gcloudImagePath
|
|
55
|
+
return joinBashExpressions(gcloudImagePath, "/");
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
export const getArtifactsRegistryBuildCacheImage = (context: Context) => {
|
|
@@ -63,7 +65,10 @@ export const getArtifactsRegistryBuildCacheImage = (context: Context) => {
|
|
|
63
65
|
export const getArtifactsRegistryImage = (context: Context) =>
|
|
64
66
|
`${getArtifactsRegistryImageName(context)}:$DOCKER_IMAGE_TAG`;
|
|
65
67
|
|
|
66
|
-
const getDeleteImageCommands = (
|
|
68
|
+
const getDeleteImageCommands = (
|
|
69
|
+
fullImageName: StringOrBashExpression,
|
|
70
|
+
keepNewest = 0
|
|
71
|
+
) => {
|
|
67
72
|
if (keepNewest === 0) {
|
|
68
73
|
// no need to list tags, we delete the whole thing
|
|
69
74
|
return [
|
|
@@ -17,16 +17,21 @@ import {
|
|
|
17
17
|
} from "./common";
|
|
18
18
|
import { getLabels } from "../../../context/getLabels";
|
|
19
19
|
import { createVolumeConfig } from "./volumes";
|
|
20
|
+
import type {
|
|
21
|
+
BashExpression,
|
|
22
|
+
StringOrBashExpression,
|
|
23
|
+
} from "../../../bash/BashExpression";
|
|
24
|
+
import { ENV_VARS_FILENAME } from "./constants";
|
|
20
25
|
|
|
21
26
|
const getJobRunScriptForJob = (
|
|
22
27
|
context: Context,
|
|
23
|
-
jobName:
|
|
28
|
+
jobName: StringOrBashExpression,
|
|
24
29
|
wait: boolean
|
|
25
30
|
) => {
|
|
26
31
|
const commonArgs = getCommonCloudRunArgs(context);
|
|
27
32
|
|
|
28
33
|
const commonArgsString = createArgsString(commonArgs);
|
|
29
|
-
return `${gcloudRunCmd()} jobs execute ${jobName} ${commonArgsString}${
|
|
34
|
+
return `${gcloudRunCmd()} jobs execute ${jobName.toString()} ${commonArgsString}${
|
|
30
35
|
wait ? " --wait" : ""
|
|
31
36
|
}`;
|
|
32
37
|
};
|
|
@@ -86,7 +91,7 @@ export const getJobCreateScripts = (context: Context) => {
|
|
|
86
91
|
|
|
87
92
|
const getJobCreateScriptsForJob = (
|
|
88
93
|
context: Context,
|
|
89
|
-
jobName:
|
|
94
|
+
jobName: StringOrBashExpression,
|
|
90
95
|
job: DeployConfigCloudRunJob
|
|
91
96
|
) => {
|
|
92
97
|
const commonDeployArgs = getCommonDeployArgs(context);
|
|
@@ -103,14 +108,14 @@ const getJobCreateScriptsForJob = (
|
|
|
103
108
|
...commonDeployArgs,
|
|
104
109
|
labels: makeLabelString({
|
|
105
110
|
...getLabels(context),
|
|
106
|
-
"cloud-run-job-name": jobName,
|
|
111
|
+
"cloud-run-job-name": jobName.toString(),
|
|
107
112
|
}),
|
|
108
113
|
image: job.image || commonDeployArgs.image,
|
|
109
114
|
cpu: job?.cpu,
|
|
110
115
|
memory: job.memory || "512Mi",
|
|
111
116
|
"task-timeout": job.timeout || "10m",
|
|
112
117
|
parallelism: job.parallelism || 1,
|
|
113
|
-
"env-vars-file":
|
|
118
|
+
"env-vars-file": ENV_VARS_FILENAME,
|
|
114
119
|
"max-retries": 0,
|
|
115
120
|
});
|
|
116
121
|
|
|
@@ -163,14 +168,14 @@ const getCloudRunJobsWithSchedule = (context: Context) => {
|
|
|
163
168
|
(
|
|
164
169
|
entry
|
|
165
170
|
): entry is {
|
|
166
|
-
jobName:
|
|
171
|
+
jobName: BashExpression;
|
|
167
172
|
job: DeployConfigCloudRunJobWithSchedule;
|
|
168
173
|
} => entry.job.when === "schedule"
|
|
169
174
|
)
|
|
170
175
|
.map(({ job, jobName }) => ({
|
|
171
176
|
job,
|
|
172
177
|
jobName,
|
|
173
|
-
schedulerName: jobName
|
|
178
|
+
schedulerName: jobName.concat("-scheduler"),
|
|
174
179
|
}));
|
|
175
180
|
};
|
|
176
181
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
getCommonDeployArgs,
|
|
11
11
|
makeLabelString,
|
|
12
12
|
} from "./common";
|
|
13
|
+
import { ENV_VARS_FILENAME } from "./constants";
|
|
13
14
|
import { createVolumeConfig } from "./volumes";
|
|
14
15
|
|
|
15
16
|
export const getServiceDeployScript = (
|
|
@@ -32,7 +33,7 @@ export const getServiceDeployScript = (
|
|
|
32
33
|
? command
|
|
33
34
|
: command.split(" ")
|
|
34
35
|
: undefined;
|
|
35
|
-
const fullServiceName =
|
|
36
|
+
const fullServiceName = serviceName.concat(nameSuffix ?? "");
|
|
36
37
|
const argsString = createArgsString(
|
|
37
38
|
{
|
|
38
39
|
// command as empty string resets it to default (uses the image's entrypoint)
|
|
@@ -42,7 +43,7 @@ export const getServiceDeployScript = (
|
|
|
42
43
|
...getLabels(context),
|
|
43
44
|
"cloud-run-service-name": fullServiceName,
|
|
44
45
|
}),
|
|
45
|
-
"env-vars-file":
|
|
46
|
+
"env-vars-file": ENV_VARS_FILENAME,
|
|
46
47
|
"min-instances": customConfig?.minInstances ?? 0,
|
|
47
48
|
"max-instances": customConfig?.maxInstances ?? 100,
|
|
48
49
|
"cpu-throttling": customConfig?.noCpuThrottling !== true,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ENV_VARS_FILENAME = "____envvars.yaml";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isNil, omit } from "lodash";
|
|
2
|
+
import type { Context, UnspecifiedEnvVars } from "../../../types/context";
|
|
2
3
|
import { collapseableSection } from "../../../utils/gitlab";
|
|
3
4
|
import { getDependencyTrackUploadScript } from "../../sbom";
|
|
4
5
|
|
|
@@ -15,9 +16,22 @@ import {
|
|
|
15
16
|
getCloudRunDeployConfig,
|
|
16
17
|
setGoogleProjectNumberScript,
|
|
17
18
|
} from "./common";
|
|
19
|
+
import { GCLOUD_DEPLOY_CREDENTIALS_KEY } from "..";
|
|
20
|
+
import type { StringOrBashExpression } from "../../../bash/BashExpression";
|
|
21
|
+
import { BashExpression, bashEscape } from "../../../bash/BashExpression";
|
|
22
|
+
import { ENV_VARS_FILENAME } from "./constants";
|
|
23
|
+
import {
|
|
24
|
+
writeBashYamlToFileScript,
|
|
25
|
+
yamlBashString,
|
|
26
|
+
} from "../../../bash/bashYaml";
|
|
18
27
|
|
|
19
28
|
export function getCloudRunDeployScripts(context: Context) {
|
|
20
29
|
const deployConfig = getCloudRunDeployConfig(context);
|
|
30
|
+
const allEnvVars = omit(
|
|
31
|
+
context.environment.envVars,
|
|
32
|
+
GCLOUD_DEPLOY_CREDENTIALS_KEY
|
|
33
|
+
);
|
|
34
|
+
|
|
21
35
|
return [
|
|
22
36
|
...collapseableSection(
|
|
23
37
|
"prepare",
|
|
@@ -26,11 +40,15 @@ export function getCloudRunDeployScripts(context: Context) {
|
|
|
26
40
|
...gcloudServiceAccountLoginCommands(context),
|
|
27
41
|
...setGoogleProjectNumberScript(deployConfig),
|
|
28
42
|
]),
|
|
43
|
+
...collapseableSection(
|
|
44
|
+
"writeenvvars",
|
|
45
|
+
"Write env vars to file"
|
|
46
|
+
)(writeBashYamlToFileScript(allEnvVars, ENV_VARS_FILENAME)),
|
|
47
|
+
|
|
29
48
|
...collapseableSection(
|
|
30
49
|
"deploy",
|
|
31
50
|
"Deploy to cloud run"
|
|
32
51
|
)([
|
|
33
|
-
`echo "$ENV_VARS" > ____envvars.yaml`, // TODO: split secrets out
|
|
34
52
|
...(deployConfig.cloudSql
|
|
35
53
|
? getDatabaseCreateScript(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
36
54
|
: []),
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { merge } from "lodash";
|
|
2
|
-
|
|
3
|
-
import { getDockerJobBaseProps } from "../../../build/docker";
|
|
4
1
|
import { getRunnerImage } from "../../../runner";
|
|
5
2
|
import type { Context } from "../../../types/context";
|
|
6
3
|
import type { CatladderJob } from "../../../types/jobs";
|
|
@@ -8,7 +5,7 @@ import { allowFailureInScripts } from "../../../utils/gitlab";
|
|
|
8
5
|
import { createDeployementJobs } from "../../base";
|
|
9
6
|
|
|
10
7
|
import { isOfDeployType } from "../../types";
|
|
11
|
-
import {
|
|
8
|
+
import { ENV_VARS_FILENAME } from "./constants";
|
|
12
9
|
import { getCloudRunDeployScripts } from "./getCloudRunDeployScripts";
|
|
13
10
|
import { getCloudRunStopScripts } from "./getCloudRunStopScripts";
|
|
14
11
|
|
|
@@ -28,12 +25,24 @@ export const createGoogleCloudRunDeployJobs = (
|
|
|
28
25
|
const stopScripts = getCloudRunStopScripts(context);
|
|
29
26
|
|
|
30
27
|
return createDeployementJobs(context, {
|
|
31
|
-
deploy:
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
deploy: {
|
|
29
|
+
variables: {
|
|
30
|
+
CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
|
|
31
|
+
},
|
|
32
|
+
...(deployConfig.debug
|
|
33
|
+
? {
|
|
34
|
+
artifacts: {
|
|
35
|
+
paths: [
|
|
36
|
+
ENV_VARS_FILENAME, // debug
|
|
37
|
+
],
|
|
38
|
+
when: "always",
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
: {}),
|
|
42
|
+
|
|
34
43
|
image: getRunnerImage("gcloud"),
|
|
35
44
|
script: deployScripts,
|
|
36
|
-
}
|
|
45
|
+
},
|
|
37
46
|
stop: {
|
|
38
47
|
image: getRunnerImage("gcloud"),
|
|
39
48
|
variables: {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { DeployTypeDefinition } from "..";
|
|
2
|
+
import {
|
|
3
|
+
BashExpression,
|
|
4
|
+
getBashVariable,
|
|
5
|
+
joinBashExpressions,
|
|
6
|
+
} from "../../bash/BashExpression";
|
|
2
7
|
import { getSecretVarName } from "../../context";
|
|
3
8
|
import type { EnvironmentContext } from "../../types/environmentContext";
|
|
4
9
|
import { sanitizeForBashVariable } from "../../utils/gitlab";
|
|
@@ -78,13 +83,16 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun"> = {
|
|
|
78
83
|
],
|
|
79
84
|
getAdditionalEnvVars: (ctx) => {
|
|
80
85
|
const { fullName, env, componentName, deployConfigRaw } = ctx;
|
|
81
|
-
const HOST_INTERNAL =
|
|
82
|
-
fullName.toLowerCase() +
|
|
83
|
-
"-" +
|
|
84
|
-
(process.env[
|
|
85
|
-
getSecretVarName(env, componentName, GCLOUD_RUN_CANONICAL_HOST_SUFFIX)
|
|
86
|
-
] ?? "unknown-host.example.com");
|
|
87
86
|
|
|
87
|
+
const HOST_INTERNAL = joinBashExpressions(
|
|
88
|
+
[
|
|
89
|
+
fullName,
|
|
90
|
+
getBashVariable(
|
|
91
|
+
getSecretVarName(env, componentName, GCLOUD_RUN_CANONICAL_HOST_SUFFIX)
|
|
92
|
+
),
|
|
93
|
+
],
|
|
94
|
+
"-"
|
|
95
|
+
).toLowerCase();
|
|
88
96
|
const jobTriggers =
|
|
89
97
|
deployConfigRaw && deployConfigRaw.jobs
|
|
90
98
|
? Object.fromEntries(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isNil } from "lodash";
|
|
2
|
+
import type { BashExpression } from "../../../bash/BashExpression";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* creates arguments string:
|
|
@@ -29,5 +30,5 @@ export const createArgsString = (...args: keyValuesArg[]) =>
|
|
|
29
30
|
|
|
30
31
|
export type keyValuesArg = Record<
|
|
31
32
|
string,
|
|
32
|
-
string | number | true | false | undefined
|
|
33
|
+
string | number | true | false | undefined | BashExpression
|
|
33
34
|
>;
|
|
@@ -12,8 +12,8 @@ export const getDatabaseDeleteScript = (
|
|
|
12
12
|
if (!deployConfig.cloudSql || !deployConfig.cloudSql.deleteDatabaseOnStop) {
|
|
13
13
|
throw new Error("not possible");
|
|
14
14
|
}
|
|
15
|
+
const DB_NAME = context.environment.envVars["DB_NAME"];
|
|
15
16
|
|
|
16
|
-
const { DB_NAME } = context.environment.envVars ?? {};
|
|
17
17
|
if (!DB_NAME) {
|
|
18
18
|
throw new Error("error: env vars did not specify DB_NAME");
|
|
19
19
|
}
|
|
@@ -42,7 +42,7 @@ export const getDatabaseCreateScript = (
|
|
|
42
42
|
throw new Error("not possible");
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const DB_NAME = context.environment.envVars["DB_NAME"];
|
|
46
46
|
|
|
47
47
|
if (!DB_NAME) {
|
|
48
48
|
throw new Error("error: env vars did not specify DB_NAME");
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { StringOrBashExpression } from "../../../bash/BashExpression";
|
|
2
|
+
|
|
3
|
+
export const getCloudRunJobName = (
|
|
4
|
+
fullAppName: StringOrBashExpression,
|
|
5
|
+
jobName: string
|
|
6
|
+
): StringOrBashExpression =>
|
|
7
|
+
fullAppName.toLowerCase().concat("-" + jobName.toLowerCase());
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Config } from "../..";
|
|
2
|
+
import type { StringOrBashExpression } from "../../bash/BashExpression";
|
|
3
|
+
import { joinBashExpressions } from "../../bash/BashExpression";
|
|
2
4
|
import type {
|
|
3
5
|
DeployConfigCloudRunCloudSql,
|
|
4
6
|
DeployConfigKubernetesValuesCloudSQLUnmanaged,
|
|
@@ -9,15 +11,16 @@ export const getFullDbName = (
|
|
|
9
11
|
| DeployConfigCloudRunCloudSql
|
|
10
12
|
| DeployConfigKubernetesValuesCloudSQLUnmanaged,
|
|
11
13
|
fullConfig: Config<never>,
|
|
12
|
-
environmentSlugPrefix:
|
|
14
|
+
environmentSlugPrefix: StringOrBashExpression,
|
|
13
15
|
componentName: string
|
|
14
16
|
) => {
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.
|
|
22
|
-
|
|
17
|
+
return joinBashExpressions(
|
|
18
|
+
[
|
|
19
|
+
cloudSqlConfig.dbNamePrefix ??
|
|
20
|
+
`${fullConfig.customerName}-${fullConfig.appName}`,
|
|
21
|
+
environmentSlugPrefix,
|
|
22
|
+
cloudSqlConfig.dbBaseName ?? componentName,
|
|
23
|
+
].flatMap((part) => (part ? [part] : [])),
|
|
24
|
+
"-"
|
|
25
|
+
);
|
|
23
26
|
};
|
package/src/deploy/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SecretEnvVar } from "..";
|
|
2
|
+
import type { BashExpression } from "../bash/BashExpression";
|
|
2
3
|
import type { Context } from "../types/context";
|
|
3
4
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
4
5
|
import type { CatladderJob } from "../types/jobs";
|
|
@@ -23,7 +24,7 @@ export type DeployTypeDefinition<T extends DeployConfigType> = {
|
|
|
23
24
|
) => SecretEnvVar[];
|
|
24
25
|
getAdditionalEnvVars: (
|
|
25
26
|
envContext: EnvironmentContext<any, T>
|
|
26
|
-
) => Record<string, string | undefined | null>;
|
|
27
|
+
) => Record<string, string | BashExpression | undefined | null>;
|
|
27
28
|
};
|
|
28
29
|
export type DeployTypes = {
|
|
29
30
|
[T in DeployConfigType]: DeployTypeDefinition<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StringOrBashExpression } from "../../../bash/BashExpression";
|
|
1
2
|
import { getSecretVarNameForContext } from "../../../context";
|
|
2
3
|
import type { Context } from "../../../types";
|
|
3
4
|
import { getFullDbName } from "../../cloudSql/utils";
|
|
@@ -15,7 +16,7 @@ type CloudSqlValues = {
|
|
|
15
16
|
proxyCredentials: string;
|
|
16
17
|
|
|
17
18
|
instanceConnectionName: string;
|
|
18
|
-
fullDbName:
|
|
19
|
+
fullDbName: StringOrBashExpression;
|
|
19
20
|
dbUser: string;
|
|
20
21
|
};
|
|
21
22
|
export const createKubernetesCloudsqlBaseValues = (
|
|
@@ -48,7 +49,7 @@ export const createKubernetesCloudsqlBaseValues = (
|
|
|
48
49
|
dbUser: "postgres",
|
|
49
50
|
instanceConnectionName,
|
|
50
51
|
proxyCredentials,
|
|
51
|
-
fullDbName: context.environment.envVars.KUBE_APP_NAME,
|
|
52
|
+
fullDbName: context.environment.envVars.KUBE_APP_NAME ?? "",
|
|
52
53
|
},
|
|
53
54
|
};
|
|
54
55
|
} else if (config.type === "unmanaged") {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
|
|
2
2
|
import { getRunnerImage } from "../../runner";
|
|
3
3
|
import type { Context } from "../../types/context";
|
|
4
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
@@ -9,8 +9,11 @@ import {
|
|
|
9
9
|
} from "../sbom";
|
|
10
10
|
import { isOfDeployType } from "../types";
|
|
11
11
|
import { createKubeValues } from "./kubeValues";
|
|
12
|
-
import { getSecretVarNameForContext } from "../../context/getEnvironmentVariables";
|
|
13
12
|
|
|
13
|
+
import { writeBashYamlToFileScript } from "../../bash/bashYaml";
|
|
14
|
+
import { collapseableSection } from "../../utils/gitlab";
|
|
15
|
+
|
|
16
|
+
const ALL_VALUES_FILE = "__all_values.yml";
|
|
14
17
|
export const createKubernetesDeployJobs = (
|
|
15
18
|
context: Context
|
|
16
19
|
): CatladderJob[] => {
|
|
@@ -23,19 +26,23 @@ export const createKubernetesDeployJobs = (
|
|
|
23
26
|
throw new Error("deploy config is not kubernetes");
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
const
|
|
27
|
-
const shared: Pick<CatladderJob, "image" | "variables"> = {
|
|
29
|
+
const shared: Pick<CatladderJob, "image" | "variables" | "artifacts"> = {
|
|
28
30
|
image: getRunnerImage("kubernetes"),
|
|
31
|
+
...(deployConfig.debug
|
|
32
|
+
? {
|
|
33
|
+
artifacts: {
|
|
34
|
+
paths: [
|
|
35
|
+
ALL_VALUES_FILE, // debug
|
|
36
|
+
],
|
|
37
|
+
when: "always",
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
: {}),
|
|
29
41
|
variables: {
|
|
30
42
|
...context.environment.envVars,
|
|
31
43
|
RELEASE_NAME: context.environment.fullName,
|
|
32
44
|
HELM_EXPERIMENTAL_OCI: "1",
|
|
33
45
|
KUBE_DOCKER_IMAGE_PULL_SECRET: `gitlab-registry-${context.componentName}`,
|
|
34
|
-
KUBE_VALUES: dump(kubeValues, {
|
|
35
|
-
lineWidth: -1,
|
|
36
|
-
quotingType: "'",
|
|
37
|
-
forceQuotes: true,
|
|
38
|
-
}),
|
|
39
46
|
HELM_GITLAB_CHART_NAME:
|
|
40
47
|
deployConfig.chartName ?? "/helm-charts/the-panter-chart",
|
|
41
48
|
HELM_ARGS: [
|
|
@@ -43,7 +50,8 @@ export const createKubernetesDeployJobs = (
|
|
|
43
50
|
...(deployConfig.additionalHelmArgs ?? []),
|
|
44
51
|
].join(" "),
|
|
45
52
|
COMPONENT_NAME: context.componentName,
|
|
46
|
-
|
|
53
|
+
/** @deprecated */
|
|
54
|
+
BUILD_ID: context.environment.envVars.BUILD_INFO_BUILD_ID,
|
|
47
55
|
},
|
|
48
56
|
};
|
|
49
57
|
|
|
@@ -69,6 +77,12 @@ export const createKubernetesDeployJobs = (
|
|
|
69
77
|
...shared,
|
|
70
78
|
script: [
|
|
71
79
|
...connectContext,
|
|
80
|
+
...collapseableSection(
|
|
81
|
+
"writeallvalues",
|
|
82
|
+
"Write " + ALL_VALUES_FILE + " for helm deployment"
|
|
83
|
+
)(
|
|
84
|
+
writeBashYamlToFileScript(createKubeValues(context), ALL_VALUES_FILE)
|
|
85
|
+
),
|
|
72
86
|
"kubernetesCreateSecret",
|
|
73
87
|
"kubernetesDeploy",
|
|
74
88
|
...getDependencyTrackUploadScript(context),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import slugify from "slugify";
|
|
2
2
|
import type { DeployTypeDefinition } from "..";
|
|
3
3
|
import { getKubernetesNamespace } from "..";
|
|
4
|
+
import { joinBashExpressions } from "../../bash/BashExpression";
|
|
4
5
|
import { additionalKubernetesSecretKeys } from "./additionalSecretKeys";
|
|
5
6
|
import { createKubernetesDeployJobs } from "./deployJob";
|
|
6
7
|
export * from "./cloudSql";
|
|
@@ -13,25 +14,31 @@ export const KUBERNETES_DEPLOY_TYPE: DeployTypeDefinition<"kubernetes"> = {
|
|
|
13
14
|
fullConfig,
|
|
14
15
|
deployConfigRaw,
|
|
15
16
|
env,
|
|
17
|
+
reviewSlug,
|
|
16
18
|
envType,
|
|
17
|
-
commitInfo,
|
|
18
19
|
}) => {
|
|
19
20
|
const KUBE_APP_NAME_PREFIX =
|
|
20
|
-
envType === "review" &&
|
|
21
|
-
const KUBE_APP_NAME =
|
|
21
|
+
envType === "review" && reviewSlug ? reviewSlug.concat("-") : "";
|
|
22
|
+
const KUBE_APP_NAME = KUBE_APP_NAME_PREFIX.concat(componentName);
|
|
22
23
|
const KUBE_NAMESPACE = getKubernetesNamespace(fullConfig, env);
|
|
23
24
|
const componentSlug = slugify(componentName);
|
|
24
|
-
const envInUrl =
|
|
25
|
-
envType === "review" && commitInfo
|
|
26
|
-
? `${commitInfo.reviewSlug}.${env}`
|
|
27
|
-
: env;
|
|
28
25
|
|
|
29
26
|
const domainCanonical =
|
|
30
27
|
(deployConfigRaw && deployConfigRaw.cluster?.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
|
|
31
28
|
fullConfig.domainCanonical ||
|
|
32
29
|
"panter.cloud";
|
|
33
|
-
const HOST_INTERNAL = `${componentSlug}.${envInUrl}.${fullConfig.appName}.${fullConfig.customerName}.${domainCanonical}`; // default for kubernetes and rest
|
|
34
30
|
|
|
31
|
+
const HOST_INTERNAL = joinBashExpressions(
|
|
32
|
+
[
|
|
33
|
+
componentSlug,
|
|
34
|
+
...(envType === "review" && reviewSlug ? [reviewSlug] : []),
|
|
35
|
+
env,
|
|
36
|
+
fullConfig.appName,
|
|
37
|
+
fullConfig.customerName,
|
|
38
|
+
domainCanonical,
|
|
39
|
+
],
|
|
40
|
+
"."
|
|
41
|
+
); // default for kubernetes and rest
|
|
35
42
|
return {
|
|
36
43
|
KUBE_NAMESPACE,
|
|
37
44
|
KUBE_APP_NAME,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { StringOrBashExpression } from "../../bash/BashExpression";
|
|
1
2
|
import type { Context } from "../../types";
|
|
2
3
|
import { isOfDeployType } from "../types";
|
|
3
4
|
|
|
4
|
-
const shouldGoIntoSecrets = (key: string, value: string) => {
|
|
5
|
+
const shouldGoIntoSecrets = (key: string, value: string | undefined) => {
|
|
6
|
+
if (!value) return false;
|
|
5
7
|
if (String(value)?.includes("$CL_")) {
|
|
6
8
|
return true;
|
|
7
9
|
}
|
|
@@ -21,20 +23,20 @@ export const createKubeEnv = (context: Context) => {
|
|
|
21
23
|
const allEnvVars = context.environment.envVars;
|
|
22
24
|
|
|
23
25
|
const env = Object.entries(allEnvVars).reduce<{
|
|
24
|
-
secret: Record<string,
|
|
25
|
-
public: Record<string,
|
|
26
|
+
secret: Record<string, StringOrBashExpression>;
|
|
27
|
+
public: Record<string, StringOrBashExpression>;
|
|
26
28
|
}>(
|
|
27
29
|
(acc, [key, value]) => {
|
|
28
|
-
if (shouldGoIntoSecrets(key, value)) {
|
|
30
|
+
if (shouldGoIntoSecrets(key, value?.toString())) {
|
|
29
31
|
acc.secret = {
|
|
30
32
|
...acc.secret,
|
|
31
|
-
[key]: value,
|
|
33
|
+
[key]: value ?? "",
|
|
32
34
|
};
|
|
33
35
|
return acc;
|
|
34
36
|
}
|
|
35
37
|
acc.public = {
|
|
36
38
|
...acc.public,
|
|
37
|
-
[key]: value,
|
|
39
|
+
[key]: value ?? "",
|
|
38
40
|
};
|
|
39
41
|
return acc;
|
|
40
42
|
},
|