@catladder/pipeline 0.0.0-refactor-cloud-run-825d7e86 â 0.0.0-refactor-docker-9fda97e9
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 +11 -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 +6 -14
- 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 +28 -33
- package/dist/build/docker.js +39 -14
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +13 -7
- package/dist/build/node/buildJob.js +5 -13
- 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 +6 -3
- 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 +4 -2
- 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 +57 -43
- package/dist/build/types.js +3 -1
- package/dist/bundles/catladder-gitlab/index.js +31112 -25265
- 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 -10
- 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 +54 -22
- 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 +20 -11
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +47 -8
- package/dist/deploy/cloudRun/createJobs/common.d.ts +3 -0
- package/dist/deploy/cloudRun/createJobs/common.js +17 -3
- 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.d.ts +3 -0
- package/dist/deploy/cloudRun/createJobs/volumes.js +58 -0
- package/dist/deploy/cloudRun/index.js +13 -7
- package/dist/deploy/cloudRun/utils/createArgsString.d.ts +3 -1
- package/dist/deploy/cloudRun/utils/createArgsString.js +25 -17
- package/dist/deploy/cloudRun/utils/database.d.ts +4 -2
- package/dist/deploy/cloudRun/utils/database.js +28 -15
- 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 +74 -17
- 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 +30 -63
- 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.d.ts +8 -0
- package/dist/pipeline/getPipelineStages.js +55 -0
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +15 -6
- package/dist/pipeline/gitlab/createGitlabJobs.js +98 -25
- package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +8 -0
- package/dist/pipeline/gitlab/createGitlabPipeline.js +38 -0
- 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 +7 -2
- package/dist/rules/index.js +34 -16
- 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 +31 -18
- 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 +495 -363
- package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +474 -342
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +492 -360
- package/examples/__snapshots__/cloud-run-no-service.ts.snap +2023 -0
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +492 -360
- package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +501 -368
- package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +1971 -0
- package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +2015 -0
- package/examples/__snapshots__/cloud-run-with-ngnix.ts.snap +1971 -0
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +1167 -867
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +1155 -867
- package/examples/__snapshots__/cloud-run-with-worker.ts.snap +494 -362
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +464 -332
- package/examples/__snapshots__/custom-build-job.ts.snap +446 -326
- package/examples/__snapshots__/custom-deploy.ts.snap +331 -223
- package/examples/__snapshots__/custom-envs.ts.snap +135 -81
- package/examples/__snapshots__/custom-sbom-java.ts.snap +446 -326
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +858 -969
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +898 -957
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +906 -969
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +1638 -1728
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +986 -1137
- package/examples/__snapshots__/local-dot-env.ts.snap +1971 -0
- package/examples/__snapshots__/meteor-kubernetes.ts.snap +918 -1069
- package/examples/__snapshots__/multiline-var.ts.snap +4500 -0
- package/examples/__snapshots__/native-app.ts.snap +718 -554
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +492 -360
- package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +500 -360
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1689 -1947
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +299 -231
- package/examples/cloud-run-memory-limit.ts +4 -1
- package/examples/cloud-run-no-service.ts +32 -0
- package/examples/cloud-run-service-gen2.ts +27 -0
- package/examples/cloud-run-service-with-volumes.ts +54 -0
- package/examples/cloud-run-with-ngnix.ts +24 -0
- package/examples/custom-deploy.ts +7 -7
- package/examples/local-dot-env.ts +25 -0
- package/examples/multiline-var.ts +64 -0
- package/package.json +5 -7
- 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 +11 -5
- package/src/build/base/index.ts +1 -1
- package/src/build/base/writeBuildInfo.ts +1 -1
- package/src/build/base/writeDotEnv.ts +6 -1
- package/src/build/custom/buildJob.ts +4 -9
- package/src/build/custom/testJob.ts +3 -2
- package/src/build/docker.ts +62 -17
- package/src/build/node/buildJob.ts +5 -9
- package/src/build/node/meteor.ts +3 -3
- package/src/build/node/testJob.ts +3 -2
- package/src/build/node/yarn.ts +9 -4
- package/src/build/rails/build.ts +1 -0
- package/src/build/rails/test.ts +2 -1
- package/src/build/types.ts +61 -39
- 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 -23
- 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 +29 -9
- 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 +35 -15
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +35 -20
- package/src/deploy/cloudRun/createJobs/common.ts +14 -1
- 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/createJobs/volumes.ts +23 -0
- package/src/deploy/cloudRun/index.ts +28 -8
- package/src/deploy/cloudRun/utils/createArgsString.ts +21 -13
- package/src/deploy/cloudRun/utils/database.ts +25 -3
- 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 +73 -4
- 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 -30
- package/src/pipeline/createJobsForComponent.ts +14 -22
- package/src/pipeline/createMainPipeline.ts +88 -0
- package/src/pipeline/generatePipelineFiles.ts +29 -0
- package/src/pipeline/getPipelineStages.ts +22 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +174 -51
- package/src/pipeline/gitlab/createGitlabPipeline.ts +24 -0
- 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 +36 -9
- package/src/types/config.ts +24 -4
- 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
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreateContextContext } from "..";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { Environment } from "../types/context";
|
|
4
4
|
import { getEnvironmentContext } from "./getEnvironmentContext";
|
|
5
5
|
import { getEnvironmentVariables } from "./getEnvironmentVariables";
|
|
6
6
|
|
|
7
7
|
export const getEnvironment = async (
|
|
8
|
-
|
|
9
|
-
componentName: string,
|
|
10
|
-
env: string,
|
|
11
|
-
commitInfo?: CommitInfo
|
|
8
|
+
ctx: CreateContextContext
|
|
12
9
|
): Promise<Environment> => {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
componentName,
|
|
16
|
-
env,
|
|
17
|
-
commitInfo
|
|
18
|
-
);
|
|
10
|
+
const { env } = ctx;
|
|
11
|
+
const variables = await getEnvironmentVariables(ctx);
|
|
19
12
|
|
|
20
|
-
const envContext = getEnvironmentContext(
|
|
21
|
-
config,
|
|
22
|
-
env,
|
|
23
|
-
componentName,
|
|
24
|
-
commitInfo
|
|
25
|
-
);
|
|
13
|
+
const envContext = getEnvironmentContext(ctx);
|
|
26
14
|
|
|
27
15
|
const envType = envContext.envType;
|
|
28
16
|
|
|
29
17
|
return {
|
|
30
18
|
envType,
|
|
31
|
-
|
|
32
|
-
gitlabEnvironment: {
|
|
33
|
-
name: envContext.gitlabEnvironmentName,
|
|
34
|
-
url: variables.url,
|
|
35
|
-
},
|
|
36
19
|
fullName: envContext.fullName,
|
|
37
20
|
slugPrefix: envContext.environmentSlugPrefix,
|
|
21
|
+
reviewSlug: envContext.reviewSlug,
|
|
38
22
|
slug: envContext.environmentSlug,
|
|
39
23
|
shortName: env,
|
|
40
24
|
...variables,
|
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreateContextContext } from "..";
|
|
2
|
+
import type { StringOrBashExpression } from "../bash/BashExpression";
|
|
3
|
+
import { joinBashExpressions } from "../bash/BashExpression";
|
|
2
4
|
|
|
3
|
-
import type { CommitInfo } from "../types/context";
|
|
4
5
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
5
6
|
import { getEnvConfig } from "./getEnvConfig";
|
|
6
7
|
import { getEnvType } from "./getEnvType";
|
|
8
|
+
import { getReviewSlug } from "./getReviewSlug";
|
|
7
9
|
|
|
8
10
|
const getEnvironmentSlugPrefix = (
|
|
9
|
-
envConfig: EnvConfigWithComponent,
|
|
10
11
|
env: string,
|
|
11
|
-
|
|
12
|
-
) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
: `${env}`;
|
|
12
|
+
reviewSlug: StringOrBashExpression | null
|
|
13
|
+
): StringOrBashExpression => {
|
|
14
|
+
if (reviewSlug) {
|
|
15
|
+
return joinBashExpressions([env, reviewSlug], "-");
|
|
16
|
+
}
|
|
17
|
+
return env;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const getEnvironmentContext = (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
): EnvironmentContext<any, any> => {
|
|
20
|
+
export const getEnvironmentContext = ({
|
|
21
|
+
env,
|
|
22
|
+
componentName,
|
|
23
|
+
config,
|
|
24
|
+
pipelineType,
|
|
25
|
+
}: CreateContextContext): EnvironmentContext<any, any> => {
|
|
26
26
|
const envConfigRaw = getEnvConfig(config, componentName, env);
|
|
27
27
|
const envType = getEnvType(env, envConfigRaw);
|
|
28
|
+
const reviewSlug = getReviewSlug(envConfigRaw, env, pipelineType);
|
|
28
29
|
|
|
29
|
-
const environmentSlugPrefix = getEnvironmentSlugPrefix(
|
|
30
|
-
envConfigRaw,
|
|
31
|
-
env,
|
|
32
|
-
commitInfo
|
|
33
|
-
);
|
|
30
|
+
const environmentSlugPrefix = getEnvironmentSlugPrefix(env, reviewSlug);
|
|
34
31
|
|
|
35
|
-
const environmentSlug =
|
|
36
|
-
const gitlabEnvironmentName =
|
|
37
|
-
envType === "review" && commitInfo
|
|
38
|
-
? `${env}/${commitInfo.refName}/${componentName}`
|
|
39
|
-
: `${env}/${componentName}`;
|
|
32
|
+
const environmentSlug = environmentSlugPrefix.concat(`-${componentName}`);
|
|
40
33
|
|
|
41
|
-
const fullName =
|
|
34
|
+
const fullName = joinBashExpressions(
|
|
35
|
+
[config.customerName, config.appName, environmentSlug],
|
|
36
|
+
"-"
|
|
37
|
+
);
|
|
42
38
|
|
|
43
39
|
return {
|
|
44
40
|
envConfigRaw,
|
|
@@ -46,10 +42,10 @@ export const getEnvironmentContext = (
|
|
|
46
42
|
buildConfigRaw: envConfigRaw.build,
|
|
47
43
|
environmentSlugPrefix,
|
|
48
44
|
environmentSlug,
|
|
49
|
-
|
|
45
|
+
reviewSlug,
|
|
46
|
+
pipelineType,
|
|
50
47
|
fullName,
|
|
51
48
|
envType,
|
|
52
|
-
commitInfo,
|
|
53
49
|
componentName,
|
|
54
50
|
env,
|
|
55
51
|
fullConfig: config,
|
|
@@ -1,67 +1,86 @@
|
|
|
1
1
|
import { merge } from "lodash";
|
|
2
2
|
import { DEPLOY_TYPES } from "../deploy";
|
|
3
3
|
import type {
|
|
4
|
-
CommitInfo,
|
|
5
4
|
Context,
|
|
6
5
|
EnvironmentEnvVarPart as EnvironmentVariables,
|
|
7
6
|
} from "../types";
|
|
8
|
-
import type {
|
|
7
|
+
import type { DevLocalEnvConfig } from "../types/config";
|
|
9
8
|
|
|
9
|
+
import type { CreateContextContext, UnspecifiedEnvVars } from "..";
|
|
10
|
+
import type { StringOrBashExpression } from "../bash/BashExpression";
|
|
11
|
+
import { getBashVariable, joinBashExpressions } from "../bash/BashExpression";
|
|
12
|
+
import type { EnvironmentContext } from "../types/environmentContext";
|
|
13
|
+
import { getBuildInfoVariables } from "./getBuildInfoVariables";
|
|
10
14
|
import { getEnvironmentContext } from "./getEnvironmentContext";
|
|
11
15
|
import {
|
|
12
16
|
resolveReferences,
|
|
13
17
|
translateLegacyFromComponents,
|
|
14
18
|
} from "./resolveReferences";
|
|
19
|
+
import { transformJobOnlyVars } from "./transformJobOnlyVars";
|
|
15
20
|
import {
|
|
16
|
-
stringListToSecreteEnvVarList,
|
|
17
21
|
makeSecretEnvVarMapping,
|
|
22
|
+
stringListToSecreteEnvVarList,
|
|
18
23
|
stringifyValues,
|
|
19
24
|
} from "./utils/envVars";
|
|
20
|
-
import { transformJobOnlyVars } from "./transformJobOnlyVars";
|
|
21
25
|
|
|
22
26
|
export type SecretEnvVar = {
|
|
23
27
|
key: string;
|
|
24
28
|
// hidden env vars are not shown in config-secrets
|
|
25
29
|
hidden?: boolean;
|
|
26
30
|
};
|
|
31
|
+
|
|
32
|
+
const getBasePredefinedVariables = (ctx: EnvironmentContext<any, any>) => {
|
|
33
|
+
return {
|
|
34
|
+
ENV_SHORT: ctx.env,
|
|
35
|
+
APP_DIR: ctx.envConfigRaw.dir,
|
|
36
|
+
ENV_TYPE: ctx.envType,
|
|
37
|
+
...(ctx.envType !== "local" ? getBuildInfoVariables(ctx) : {}),
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type BasePredefinedVariables = ReturnType<typeof getBasePredefinedVariables>;
|
|
42
|
+
|
|
43
|
+
// we export so that we have later nice autocomplete
|
|
44
|
+
export type PredefinedVariables = BasePredefinedVariables & {
|
|
45
|
+
/**
|
|
46
|
+
* undefined in rails, Rails before 6.1 (mis)uses the `HOST` environment variable to specify the IP to bind to
|
|
47
|
+
*/
|
|
48
|
+
HOST?: StringOrBashExpression;
|
|
49
|
+
ROOT_URL: StringOrBashExpression;
|
|
50
|
+
HOST_INTERNAL: StringOrBashExpression;
|
|
51
|
+
ROOT_URL_INTERNAL: StringOrBashExpression;
|
|
52
|
+
};
|
|
53
|
+
|
|
27
54
|
export const getEnvironmentVariables = async (
|
|
28
|
-
|
|
29
|
-
componentName: string,
|
|
30
|
-
env: string,
|
|
31
|
-
commitInfo?: CommitInfo,
|
|
55
|
+
ctx: CreateContextContext,
|
|
32
56
|
alreadyVisited: Record<string, Record<string, boolean>> = {} // to prevent endless loop
|
|
33
57
|
): Promise<EnvironmentVariables> => {
|
|
34
|
-
const environmentContext = getEnvironmentContext(
|
|
35
|
-
config,
|
|
36
|
-
env,
|
|
37
|
-
componentName,
|
|
38
|
-
commitInfo
|
|
39
|
-
);
|
|
58
|
+
const environmentContext = getEnvironmentContext(ctx);
|
|
40
59
|
|
|
60
|
+
const { config, env, componentName } = ctx;
|
|
41
61
|
const { envConfigRaw, deployConfigRaw, buildConfigRaw, envType } =
|
|
42
62
|
environmentContext;
|
|
43
63
|
|
|
44
|
-
const basePredefinedVariables =
|
|
45
|
-
|
|
46
|
-
APP_DIR: envConfigRaw.dir,
|
|
47
|
-
ENV_TYPE: envType,
|
|
48
|
-
BUILD_INFO_ID: commitInfo?.buildId,
|
|
49
|
-
BUILD_INFO_BUILD_TIME: commitInfo?.buildTime,
|
|
50
|
-
BUILD_INFO_CURRENT_VERSION: commitInfo?.currentVersion,
|
|
51
|
-
};
|
|
64
|
+
const basePredefinedVariables =
|
|
65
|
+
getBasePredefinedVariables(environmentContext);
|
|
52
66
|
|
|
53
|
-
let predefinedVariables:
|
|
54
|
-
let host:
|
|
55
|
-
let url:
|
|
67
|
+
let predefinedVariables: PredefinedVariables & UnspecifiedEnvVars;
|
|
68
|
+
let host: StringOrBashExpression;
|
|
69
|
+
let url: StringOrBashExpression;
|
|
56
70
|
|
|
57
71
|
if (envType === "local") {
|
|
58
72
|
const devLocalConfig: DevLocalEnvConfig = envConfigRaw;
|
|
59
73
|
const port = devLocalConfig.port ?? 3000;
|
|
60
|
-
host = "localhost:" + port;
|
|
74
|
+
host = "localhost:" + port.toString();
|
|
61
75
|
url = "http://" + host;
|
|
62
76
|
predefinedVariables = {
|
|
77
|
+
...basePredefinedVariables,
|
|
63
78
|
ENV_SHORT: "local",
|
|
64
79
|
ROOT_URL: url,
|
|
80
|
+
// Rails before 6.1 (mis)uses the `HOST` environment variable to specify the IP to bind to
|
|
81
|
+
...(config.components[componentName].build.type === "rails"
|
|
82
|
+
? {}
|
|
83
|
+
: { HOST: host }),
|
|
65
84
|
HOST_INTERNAL: host,
|
|
66
85
|
ROOT_URL_INTERNAL: "http://" + host,
|
|
67
86
|
PORT: port.toString(),
|
|
@@ -72,10 +91,12 @@ export const getEnvironmentVariables = async (
|
|
|
72
91
|
environmentContext as never
|
|
73
92
|
)
|
|
74
93
|
: {};
|
|
94
|
+
|
|
75
95
|
const HOST_INTERNAL =
|
|
76
96
|
additionalEnvVars.HOST_INTERNAL ?? "unknown-host.example.com";
|
|
97
|
+
|
|
77
98
|
host = envConfigRaw?.host ?? HOST_INTERNAL;
|
|
78
|
-
url =
|
|
99
|
+
url = joinBashExpressions(["https://", host]);
|
|
79
100
|
|
|
80
101
|
predefinedVariables = {
|
|
81
102
|
...basePredefinedVariables,
|
|
@@ -84,8 +105,10 @@ export const getEnvironmentVariables = async (
|
|
|
84
105
|
? {}
|
|
85
106
|
: { HOST: host }),
|
|
86
107
|
ROOT_URL: url,
|
|
87
|
-
|
|
88
|
-
|
|
108
|
+
HOST_INTERNAL,
|
|
109
|
+
/**@deprecated */
|
|
110
|
+
HOST_CANONICAL: HOST_INTERNAL, // legacy alias for HOST_INTERNAL
|
|
111
|
+
ROOT_URL_INTERNAL: joinBashExpressions(["https://", HOST_INTERNAL]),
|
|
89
112
|
...additionalEnvVars,
|
|
90
113
|
};
|
|
91
114
|
}
|
|
@@ -124,20 +147,20 @@ export const getEnvironmentVariables = async (
|
|
|
124
147
|
...publicEnvVarsRawSanitized,
|
|
125
148
|
});
|
|
126
149
|
|
|
127
|
-
const envVars = await resolveReferences(
|
|
150
|
+
const envVars = (await resolveReferences(
|
|
128
151
|
envVarsRaw,
|
|
129
152
|
async (otherComponentName, alreadyVisited) => {
|
|
130
153
|
const { envVars: otherEnvVars } = await getEnvironmentVariables(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
154
|
+
{
|
|
155
|
+
...ctx,
|
|
156
|
+
componentName: otherComponentName,
|
|
157
|
+
},
|
|
135
158
|
alreadyVisited
|
|
136
159
|
);
|
|
137
160
|
return otherEnvVars;
|
|
138
161
|
},
|
|
139
162
|
alreadyVisited
|
|
140
|
-
);
|
|
163
|
+
)) as typeof envVarsRaw;
|
|
141
164
|
|
|
142
165
|
return {
|
|
143
166
|
envVars,
|
|
@@ -168,7 +191,9 @@ export const getSecretVarName = (
|
|
|
168
191
|
key: string
|
|
169
192
|
) => `CL_${sanitizeForEnVar(env)}_${sanitizeForEnVar(componentName)}_${key}`; // remove dash from component name
|
|
170
193
|
|
|
171
|
-
const addIndexVar =
|
|
194
|
+
const addIndexVar = <V extends Record<string, unknown>>(
|
|
195
|
+
vars: V
|
|
196
|
+
): V & { _ALL_ENV_VAR_KEYS: string } => ({
|
|
172
197
|
...vars,
|
|
173
198
|
_ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars)),
|
|
174
199
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BashExpression,
|
|
3
|
+
type StringOrBashExpression,
|
|
4
|
+
} from "../bash/BashExpression";
|
|
5
|
+
import type { BashExpressionPerPipelineType } from "../bash/bashExpressionPerPipelineType";
|
|
6
|
+
import { getBashExpressionPerPipelineType } from "../bash/bashExpressionPerPipelineType";
|
|
7
|
+
import type { PipelineType } from "../types";
|
|
8
|
+
import type { EnvConfigWithComponent } from "../types/config";
|
|
9
|
+
import { getEnvType } from "./getEnvType";
|
|
10
|
+
const REVIEW_SLUG: BashExpressionPerPipelineType = {
|
|
11
|
+
default: "unknown-review-slug",
|
|
12
|
+
gitlab: new BashExpression(
|
|
13
|
+
`$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })`
|
|
14
|
+
),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getReviewSlug = (
|
|
18
|
+
envConfig: EnvConfigWithComponent,
|
|
19
|
+
env: string,
|
|
20
|
+
pipelineType?: PipelineType
|
|
21
|
+
): StringOrBashExpression | null => {
|
|
22
|
+
const envType = getEnvType(env, envConfig);
|
|
23
|
+
if (envType === "review") {
|
|
24
|
+
return getBashExpressionPerPipelineType(REVIEW_SLUG, pipelineType);
|
|
25
|
+
}
|
|
26
|
+
return null; // not a review app;
|
|
27
|
+
};
|
package/src/context/index.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { BUILD_TYPES } from "../build";
|
|
|
2
2
|
import type { BuildConfig, BuildConfigType } from "../build/types";
|
|
3
3
|
import { DEPLOY_TYPES } from "../deploy";
|
|
4
4
|
import type { DeployConfig, DeployConfigType } from "../deploy/types";
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
5
|
+
import type { PipelineType } from "../types";
|
|
6
|
+
import type { Config, PipelineTrigger } from "../types/config";
|
|
7
|
+
import type { Context, PackageManagerInfo } from "../types/context";
|
|
7
8
|
import type { PartialDeep } from "../types/utils";
|
|
8
9
|
import { mergeWithMergingArrays } from "../utils";
|
|
9
10
|
import { getEnvironment } from "./getEnvironment";
|
|
@@ -12,25 +13,25 @@ import { getEnvironmentContext } from "./getEnvironmentContext";
|
|
|
12
13
|
export * from "./getEnvironment";
|
|
13
14
|
export * from "./getEnvironmentVariables";
|
|
14
15
|
|
|
16
|
+
export type CreateContextContext = {
|
|
17
|
+
config: Config;
|
|
18
|
+
componentName: string;
|
|
19
|
+
env: string;
|
|
20
|
+
pipelineType?: PipelineType;
|
|
21
|
+
trigger?: PipelineTrigger;
|
|
22
|
+
packageManagerInfo?: PackageManagerInfo;
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
export const createContext = async (
|
|
16
|
-
|
|
17
|
-
componentName: string,
|
|
18
|
-
env: string,
|
|
19
|
-
commitInfo?: CommitInfo,
|
|
20
|
-
packageManagerInfo?: PackageManagerInfo
|
|
26
|
+
ctx: CreateContextContext
|
|
21
27
|
): Promise<Context> => {
|
|
22
|
-
if (!/^[a-z0-9-]+$/.test(componentName)) {
|
|
28
|
+
if (!/^[a-z0-9-]+$/.test(ctx.componentName)) {
|
|
23
29
|
throw new Error(
|
|
24
30
|
"componentName may only contain lower case letters, numbers and -"
|
|
25
31
|
);
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
const envContext = getEnvironmentContext(
|
|
29
|
-
config,
|
|
30
|
-
env,
|
|
31
|
-
componentName,
|
|
32
|
-
commitInfo
|
|
33
|
-
);
|
|
34
|
+
const envContext = getEnvironmentContext(ctx);
|
|
34
35
|
|
|
35
36
|
const componentConfigWithoutDefaults = envContext.envConfigRaw;
|
|
36
37
|
const defaults: {
|
|
@@ -42,10 +43,9 @@ export const createContext = async (
|
|
|
42
43
|
BUILD_TYPES[
|
|
43
44
|
componentConfigWithoutDefaults.build.type as BuildConfigType
|
|
44
45
|
].defaults(envContext),
|
|
45
|
-
deploy:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
].defaults(envContext),
|
|
46
|
+
deploy: DEPLOY_TYPES[
|
|
47
|
+
componentConfigWithoutDefaults.deploy.type as DeployConfigType
|
|
48
|
+
].defaults(envContext as any),
|
|
49
49
|
}
|
|
50
50
|
: {
|
|
51
51
|
build: {},
|
|
@@ -57,11 +57,12 @@ export const createContext = async (
|
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
return {
|
|
60
|
-
fullConfig: config,
|
|
60
|
+
fullConfig: ctx.config,
|
|
61
61
|
componentConfig,
|
|
62
|
-
componentName,
|
|
63
|
-
environment: await getEnvironment(
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
componentName: ctx.componentName,
|
|
63
|
+
environment: await getEnvironment(ctx),
|
|
64
|
+
packageManagerInfo: ctx.packageManagerInfo,
|
|
65
|
+
pipelineType: ctx.pipelineType,
|
|
66
|
+
trigger: ctx.trigger,
|
|
66
67
|
};
|
|
67
68
|
};
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
import { merge } from "lodash";
|
|
2
|
-
import replaceAsync from "string-replace-async";
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import type { BashExpression } from "../bash/BashExpression";
|
|
4
|
+
import replaceAsync from "../bash/replaceAsync";
|
|
5
|
+
import type { UnspecifiedEnvVars } from "..";
|
|
6
|
+
|
|
7
|
+
// regex to resolve references in catladder variables
|
|
8
|
+
// those expressions have the pattern ${componentName:variableName}
|
|
9
|
+
const REGEX = /\$\{(([^:}]+):)?([^}]+)}/gm;
|
|
5
10
|
|
|
6
11
|
export const resolveReferences = async (
|
|
7
|
-
vars: Record<string, string>,
|
|
12
|
+
vars: Record<string, string | BashExpression | undefined | null>,
|
|
8
13
|
getOtherVariables?: (
|
|
9
14
|
componentName: string,
|
|
10
15
|
alreadyVisited: Record<string, Record<string, boolean>>
|
|
11
|
-
) => Promise<
|
|
16
|
+
) => Promise<UnspecifiedEnvVars>,
|
|
12
17
|
alreadyVisitedBase: Record<string, Record<string, boolean>> = {}
|
|
13
18
|
) => {
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* replace referenced variables with their values in a value string
|
|
22
|
+
*/
|
|
14
23
|
const replaceSingleValue = async (
|
|
15
|
-
value: string,
|
|
24
|
+
value: string | BashExpression,
|
|
16
25
|
alreadyVisited: Record<string, Record<string, boolean>> = alreadyVisitedBase
|
|
17
|
-
): Promise<string> => {
|
|
18
|
-
if (REGEX.test(value)) {
|
|
26
|
+
): Promise<string | BashExpression> => {
|
|
27
|
+
if (REGEX.test(value.toString())) {
|
|
28
|
+
// we consider variables that got references in it BashExpressions, because the replacement may be one
|
|
29
|
+
|
|
19
30
|
return await replaceAsync(
|
|
20
31
|
value,
|
|
21
32
|
REGEX,
|
|
@@ -50,10 +61,19 @@ export const resolveReferences = async (
|
|
|
50
61
|
return Object.fromEntries(
|
|
51
62
|
await Promise.all(
|
|
52
63
|
Object.entries(vars).map(async ([key, value]) => {
|
|
53
|
-
|
|
64
|
+
if (value === null || value === undefined) {
|
|
65
|
+
return [key, null];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return [
|
|
69
|
+
key,
|
|
70
|
+
value !== null && value !== undefined
|
|
71
|
+
? await replaceSingleValue(value)
|
|
72
|
+
: null,
|
|
73
|
+
];
|
|
54
74
|
})
|
|
55
75
|
)
|
|
56
|
-
) as Record<string,
|
|
76
|
+
) as Record<string, BashExpression>;
|
|
57
77
|
};
|
|
58
78
|
|
|
59
79
|
export const translateLegacyFromComponents = (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SecretEnvVar, UnspecifiedEnvVars } from "..";
|
|
2
2
|
import type { EnvVars } from "../types/config";
|
|
3
3
|
import {
|
|
4
4
|
makeSecretEnvVarMapping,
|
|
@@ -17,7 +17,10 @@ export const transformJobOnlyVars = async (
|
|
|
17
17
|
env: string,
|
|
18
18
|
componentName: string,
|
|
19
19
|
vars: EnvVars | null
|
|
20
|
-
): Promise<
|
|
20
|
+
): Promise<{
|
|
21
|
+
envVars: UnspecifiedEnvVars;
|
|
22
|
+
secretEnvVarKeys: SecretEnvVar[];
|
|
23
|
+
}> => {
|
|
21
24
|
if (!vars) {
|
|
22
25
|
return {
|
|
23
26
|
envVars: {},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isObject } from "lodash";
|
|
2
2
|
import type { SecretEnvVar } from "../getEnvironmentVariables";
|
|
3
3
|
import { getSecretVarName } from "../getEnvironmentVariables";
|
|
4
|
+
import { getBashVariable } from "../../bash/BashExpression";
|
|
4
5
|
|
|
5
6
|
export const stringifyValues = (obj: Record<string, unknown>) =>
|
|
6
7
|
Object.fromEntries(
|
|
@@ -20,7 +21,7 @@ export const makeSecretEnvVarMapping = (
|
|
|
20
21
|
return Object.fromEntries(
|
|
21
22
|
secretEnvVars.map(({ key }) => [
|
|
22
23
|
key,
|
|
23
|
-
|
|
24
|
+
getBashVariable(getSecretVarName(env, componentName, key)),
|
|
24
25
|
])
|
|
25
26
|
);
|
|
26
27
|
};
|
|
@@ -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,
|