@catladder/pipeline 1.144.1 → 1.146.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 +40 -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 +10 -4
- 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 +4 -5
- 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/__utils__/helpers.ts +2 -2
- package/examples/custom-deploy.ts +7 -7
- package/examples/multiline-var.ts +64 -0
- package/package.json +5 -8
- package/scripts/generate-gitlab-ci-types.ts +2 -2
- 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/__tests__/createArtifactsConfig.test.ts +3 -3
- package/src/build/base/createAppBuildJob.ts +8 -4
- package/src/build/base/createArtifactsConfig.ts +2 -2
- 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/__tests__/testJob.test.ts +1 -1
- package/src/build/custom/buildJob.ts +4 -6
- package/src/build/custom/testJob.ts +6 -5
- package/src/build/docker.ts +21 -13
- package/src/build/index.ts +1 -1
- package/src/build/node/buildJob.ts +3 -5
- package/src/build/node/cache.ts +4 -4
- package/src/build/node/meteor.ts +1 -1
- package/src/build/node/testJob.ts +6 -5
- package/src/build/node/yarn.ts +14 -9
- 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/configruedEnvs.ts +6 -6
- package/src/config/readConfig.ts +4 -5
- 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/getEnvConfig.ts +1 -1
- package/src/context/getEnvType.ts +1 -1
- package/src/context/getEnvironment.ts +7 -30
- package/src/context/getEnvironmentContext.ts +25 -29
- package/src/context/getEnvironmentVariables.ts +72 -47
- package/src/context/getReviewSlug.ts +27 -0
- package/src/context/index.ts +26 -25
- package/src/context/resolveReferences.ts +40 -17
- package/src/context/transformJobOnlyVars.ts +6 -3
- package/src/context/utils/envVars.ts +5 -4
- package/src/deploy/base/deploy.ts +25 -23
- package/src/deploy/base/index.ts +1 -1
- package/src/deploy/base/rollback.ts +9 -11
- package/src/deploy/base/stop.ts +9 -10
- package/src/deploy/cloudRun/artifactsRegistry.ts +13 -8
- package/src/deploy/cloudRun/cleanup.ts +3 -3
- package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -3
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +22 -17
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +7 -6
- package/src/deploy/cloudRun/createJobs/common.ts +1 -1
- package/src/deploy/cloudRun/createJobs/constants.ts +1 -0
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +25 -7
- package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +1 -1
- package/src/deploy/cloudRun/createJobs/index.ts +18 -9
- package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
- package/src/deploy/cloudRun/index.ts +22 -10
- package/src/deploy/cloudRun/utils/createArgsString.ts +3 -2
- package/src/deploy/cloudRun/utils/database.ts +7 -7
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +1 -1
- package/src/deploy/cloudRun/utils/jobName.ts +7 -2
- package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
- package/src/deploy/cloudSql/utils.ts +13 -10
- package/src/deploy/index.ts +5 -4
- package/src/deploy/kubernetes/cloudSql/index.ts +6 -5
- package/src/deploy/kubernetes/deployJob.ts +28 -14
- package/src/deploy/kubernetes/index.ts +15 -8
- package/src/deploy/kubernetes/kubeEnv.ts +9 -7
- package/src/deploy/kubernetes/kubeValues.ts +5 -6
- package/src/deploy/kubernetes/mongodb.ts +1 -1
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +5 -4
- package/src/deploy/types/base.ts +6 -0
- package/src/deploy/types/googleCloudRun.ts +2 -0
- package/src/deploy/utils.ts +2 -2
- package/src/index.ts +2 -1
- package/src/packageInfos.ts +10 -0
- package/src/pipeline/createAllJobs.ts +28 -14
- package/src/pipeline/createChildPipeline.ts +20 -9
- package/src/pipeline/createJobsForComponent.ts +15 -23
- package/src/pipeline/createMainPipeline.ts +91 -0
- package/src/pipeline/generatePipelineFiles.ts +29 -0
- package/src/pipeline/getPipelineStages.ts +1 -1
- package/src/pipeline/gitlab/createGitlabJobs.ts +182 -59
- 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/pipeline/packageManager.ts +2 -2
- package/src/pipeline/yarn/yarnUtils.ts +7 -7
- package/src/rules/index.ts +15 -9
- package/src/types/config.ts +12 -3
- package/src/types/context.ts +39 -26
- package/src/types/environmentContext.ts +13 -7
- package/src/types/gitlab-ci-yml.ts +0 -1
- package/src/types/gitlab-types.ts +5 -4
- package/src/types/jobs.ts +29 -4
- package/src/types/pipeline.ts +4 -0
- package/src/types/utils.ts +4 -4
- package/src/utils/gitlab.ts +1 -1
- package/src/utils/index.ts +2 -2
- 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,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";
|
|
@@ -28,11 +33,11 @@ const getCloudSqlVariables = ({
|
|
|
28
33
|
deployConfigRaw.cloudSql,
|
|
29
34
|
fullConfig,
|
|
30
35
|
environmentSlugPrefix,
|
|
31
|
-
componentName
|
|
36
|
+
componentName,
|
|
32
37
|
);
|
|
33
38
|
|
|
34
39
|
const additionalQueryParamsString = Object.entries(
|
|
35
|
-
deployConfigRaw.cloudSql.dbAdditionalQueryParams ?? {}
|
|
40
|
+
deployConfigRaw.cloudSql.dbAdditionalQueryParams ?? {},
|
|
36
41
|
)
|
|
37
42
|
.map(([key, value]) => `&${key}=${value}`)
|
|
38
43
|
.join("");
|
|
@@ -44,7 +49,7 @@ const getCloudSqlVariables = ({
|
|
|
44
49
|
DB_USER: deployConfigRaw.cloudSql.dbUser ?? "postgres",
|
|
45
50
|
DB_PASSWORD: "$" + getSecretVarName(env, componentName, "DB_PASSWORD"),
|
|
46
51
|
DATABASE_URL: `${getDatabaseConnectionString(
|
|
47
|
-
deployConfigRaw.cloudSql
|
|
52
|
+
deployConfigRaw.cloudSql,
|
|
48
53
|
)}${additionalQueryParamsString}`,
|
|
49
54
|
DATABASE_JDBC_URL: DATABASE_JDBC_URL,
|
|
50
55
|
};
|
|
@@ -78,13 +83,20 @@ 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(
|
|
92
|
+
env,
|
|
93
|
+
componentName,
|
|
94
|
+
GCLOUD_RUN_CANONICAL_HOST_SUFFIX,
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
|
+
],
|
|
98
|
+
"-",
|
|
99
|
+
).toLowerCase();
|
|
88
100
|
const jobTriggers =
|
|
89
101
|
deployConfigRaw && deployConfigRaw.jobs
|
|
90
102
|
? Object.fromEntries(
|
|
@@ -95,7 +107,7 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun"> = {
|
|
|
95
107
|
}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${
|
|
96
108
|
deployConfigRaw.projectId
|
|
97
109
|
}/jobs/${getCloudRunJobName(fullName, name)}:run`,
|
|
98
|
-
])
|
|
110
|
+
]),
|
|
99
111
|
)
|
|
100
112
|
: {};
|
|
101
113
|
|
|
@@ -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:
|
|
@@ -22,12 +23,12 @@ export const createArgsString = (...args: keyValuesArg[]) =>
|
|
|
22
23
|
return `--no-${key}`;
|
|
23
24
|
}
|
|
24
25
|
return `--${key}=${value}`;
|
|
25
|
-
})
|
|
26
|
+
}),
|
|
26
27
|
)
|
|
27
28
|
.flat()
|
|
28
29
|
.join(" ");
|
|
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
|
>;
|
|
@@ -7,13 +7,13 @@ import type {
|
|
|
7
7
|
|
|
8
8
|
export const getDatabaseDeleteScript = (
|
|
9
9
|
context: Context,
|
|
10
|
-
deployConfig: DeployConfigCloudRun
|
|
10
|
+
deployConfig: DeployConfigCloudRun,
|
|
11
11
|
): string[] => {
|
|
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
|
}
|
|
@@ -29,20 +29,20 @@ export const getDatabaseDeleteScript = (
|
|
|
29
29
|
`gcloud sql databases delete ${DB_NAME} --instance=${instanceId} --project ${projectId}`,
|
|
30
30
|
{
|
|
31
31
|
pauseInSeconds: 10,
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
),
|
|
34
34
|
];
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
export const getDatabaseCreateScript = (
|
|
38
38
|
context: Context,
|
|
39
|
-
deployConfig: DeployConfigCloudRun
|
|
39
|
+
deployConfig: DeployConfigCloudRun,
|
|
40
40
|
): string[] => {
|
|
41
41
|
if (!deployConfig.cloudSql) {
|
|
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");
|
|
@@ -61,14 +61,14 @@ export const DATABASE_JDBC_URL =
|
|
|
61
61
|
"jdbc:postgresql:///$DB_NAME?cloudSqlInstance=$CLOUD_SQL_INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=$DB_USER&password=$DB_PASSWORD";
|
|
62
62
|
|
|
63
63
|
export const getDatabaseConnectionString = (
|
|
64
|
-
config: DeployConfigCloudRunCloudSql
|
|
64
|
+
config: DeployConfigCloudRunCloudSql,
|
|
65
65
|
): string => {
|
|
66
66
|
switch (config.dbConnectionStringFormat) {
|
|
67
67
|
case "jdbc":
|
|
68
68
|
return DATABASE_JDBC_URL;
|
|
69
69
|
case "rails":
|
|
70
70
|
return `postgresql://$DB_USER:$DB_PASSWORD@${encodeURIComponent(
|
|
71
|
-
`/cloudsql/${config.instanceConnectionName}
|
|
71
|
+
`/cloudsql/${config.instanceConnectionName}`,
|
|
72
72
|
)}/$DB_NAME?`;
|
|
73
73
|
default:
|
|
74
74
|
// prisma
|
|
@@ -5,6 +5,6 @@ import type { Context } from "../../../types";
|
|
|
5
5
|
export const gcloudServiceAccountLoginCommands = (context: Context) => [
|
|
6
6
|
`gcloud auth activate-service-account --key-file=<(echo "$${getSecretVarNameForContext(
|
|
7
7
|
context,
|
|
8
|
-
GCLOUD_DEPLOY_CREDENTIALS_KEY
|
|
8
|
+
GCLOUD_DEPLOY_CREDENTIALS_KEY,
|
|
9
9
|
)}")`,
|
|
10
10
|
];
|
|
@@ -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:
|
|
13
|
-
componentName: string
|
|
14
|
+
environmentSlugPrefix: StringOrBashExpression,
|
|
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";
|
|
@@ -16,14 +17,14 @@ export * from "./utils";
|
|
|
16
17
|
export type DeployTypeDefinition<T extends DeployConfigType> = {
|
|
17
18
|
jobs: (context: Context) => CatladderJob[];
|
|
18
19
|
defaults: (
|
|
19
|
-
envContext: EnvironmentContext<any, T
|
|
20
|
+
envContext: EnvironmentContext<any, T>,
|
|
20
21
|
) => PartialDeep<DeployConfigGeneric<T>>;
|
|
21
22
|
additionalSecretKeys: (
|
|
22
|
-
envContext: EnvironmentContext<any, T
|
|
23
|
+
envContext: EnvironmentContext<any, T>,
|
|
23
24
|
) => SecretEnvVar[];
|
|
24
25
|
getAdditionalEnvVars: (
|
|
25
|
-
envContext: EnvironmentContext<any, T
|
|
26
|
-
) => Record<string, string | undefined | null>;
|
|
26
|
+
envContext: EnvironmentContext<any, T>,
|
|
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,11 +16,11 @@ 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 = (
|
|
22
|
-
context: Context
|
|
23
|
+
context: Context,
|
|
23
24
|
): {
|
|
24
25
|
cloudsql: CloudSqlValues;
|
|
25
26
|
} => {
|
|
@@ -35,7 +36,7 @@ export const createKubernetesCloudsqlBaseValues = (
|
|
|
35
36
|
|
|
36
37
|
const proxyCredentials = `$${getSecretVarNameForContext(
|
|
37
38
|
context,
|
|
38
|
-
"cloudsqlProxyCredentials"
|
|
39
|
+
"cloudsqlProxyCredentials",
|
|
39
40
|
)}`;
|
|
40
41
|
if (config?.type !== "unmanaged") {
|
|
41
42
|
const instanceConnectionName = `${config.projectId ?? "skynet-164509"}:${
|
|
@@ -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") {
|
|
@@ -62,7 +63,7 @@ export const createKubernetesCloudsqlBaseValues = (
|
|
|
62
63
|
config,
|
|
63
64
|
context.fullConfig,
|
|
64
65
|
context.environment.slugPrefix,
|
|
65
|
-
context.componentName
|
|
66
|
+
context.componentName,
|
|
66
67
|
),
|
|
67
68
|
},
|
|
68
69
|
};
|
|
@@ -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,10 +9,13 @@ 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
|
-
context: Context
|
|
18
|
+
context: Context,
|
|
16
19
|
): CatladderJob[] => {
|
|
17
20
|
const deployConfig = context.componentConfig.deploy;
|
|
18
21
|
if (deployConfig === false) {
|
|
@@ -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
|
|
|
@@ -51,14 +59,14 @@ export const createKubernetesDeployJobs = (
|
|
|
51
59
|
const connectContext = [
|
|
52
60
|
`kubectl config set-cluster "${clusterName}" --server="$${getSecretVarNameForContext(
|
|
53
61
|
context,
|
|
54
|
-
"KUBE_URL"
|
|
62
|
+
"KUBE_URL",
|
|
55
63
|
)}" --certificate-authority <(echo $${getSecretVarNameForContext(
|
|
56
64
|
context,
|
|
57
|
-
"KUBE_CA_PEM"
|
|
65
|
+
"KUBE_CA_PEM",
|
|
58
66
|
)} | base64 -d) --embed-certs=true`,
|
|
59
67
|
`kubectl config set-credentials "${clusterName}" --token="$${getSecretVarNameForContext(
|
|
60
68
|
context,
|
|
61
|
-
"KUBE_TOKEN"
|
|
69
|
+
"KUBE_TOKEN",
|
|
62
70
|
)}"`,
|
|
63
71
|
`kubectl config set-context "${clusterName}" --cluster="${clusterName}" --user="${clusterName}" --namespace="${context.environment.envVars.KUBE_NAMESPACE}"`,
|
|
64
72
|
`kubectl config use-context "${clusterName}"`,
|
|
@@ -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,27 +23,27 @@ 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
|
},
|
|
41
43
|
{
|
|
42
44
|
secret: {},
|
|
43
45
|
public: {},
|
|
44
|
-
}
|
|
46
|
+
},
|
|
45
47
|
);
|
|
46
48
|
|
|
47
49
|
return env;
|
|
@@ -15,7 +15,7 @@ import { processSecretsAsFiles } from "./processSecretsAsFiles";
|
|
|
15
15
|
|
|
16
16
|
const createAppConfig = (
|
|
17
17
|
context: Context,
|
|
18
|
-
application: DeployConfigKubernetesValues["application"]
|
|
18
|
+
application: DeployConfigKubernetesValues["application"],
|
|
19
19
|
): DeployConfigKubernetesValues["application"] => {
|
|
20
20
|
if (application === false) {
|
|
21
21
|
return {
|
|
@@ -45,14 +45,14 @@ const createAppConfig = (
|
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
}, // default
|
|
48
|
-
rest // merge rest in
|
|
48
|
+
rest, // merge rest in
|
|
49
49
|
);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const removeFalsy = <T>(record?: Record<string, false | T>) => {
|
|
53
53
|
if (!record) return undefined;
|
|
54
54
|
return Object.fromEntries(
|
|
55
|
-
Object.entries(record).filter(([, value]) => value !== false)
|
|
55
|
+
Object.entries(record).filter(([, value]) => value !== false),
|
|
56
56
|
);
|
|
57
57
|
};
|
|
58
58
|
|
|
@@ -70,7 +70,6 @@ export const createKubeValues = (context: Context) => {
|
|
|
70
70
|
|
|
71
71
|
// we remove the application config because it can be just the value `false` which is a convenience feature, but not supported in the helm chart
|
|
72
72
|
// we only merge the rest of the values in
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
73
|
const { application, jobs, cronjobs, ...rest } = values ?? {};
|
|
75
74
|
|
|
76
75
|
const env = createKubeEnv(context);
|
|
@@ -85,7 +84,7 @@ export const createKubeValues = (context: Context) => {
|
|
|
85
84
|
: {},
|
|
86
85
|
deployConfig.values?.mongodb?.enabled
|
|
87
86
|
? createMongodbBaseConfig(context)
|
|
88
|
-
: {}
|
|
87
|
+
: {},
|
|
89
88
|
);
|
|
90
89
|
|
|
91
90
|
const kubeValues = processSecretsAsFiles(
|
|
@@ -94,7 +93,7 @@ export const createKubeValues = (context: Context) => {
|
|
|
94
93
|
cronjobs: removeFalsy(cronjobs),
|
|
95
94
|
|
|
96
95
|
...rest,
|
|
97
|
-
})
|
|
96
|
+
}),
|
|
98
97
|
);
|
|
99
98
|
|
|
100
99
|
return kubeValues;
|
|
@@ -19,7 +19,7 @@ const getMongodbReplicasetHost = (context: Context, index: number) => {
|
|
|
19
19
|
const fullAppname = context.environment.envVars.KUBE_APP_NAME;
|
|
20
20
|
return getMongodbHost(
|
|
21
21
|
context,
|
|
22
|
-
`${fullAppname}-mongodb-${index}.${fullAppname}-mongodb-headless
|
|
22
|
+
`${fullAppname}-mongodb-${index}.${fullAppname}-mongodb-headless`,
|
|
23
23
|
);
|
|
24
24
|
};
|
|
25
25
|
const createMongodbUrl = (context: Context, dbName: string) => {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { omit } from "lodash";
|
|
2
2
|
import type { DeployConfigKubernetesValues } from "../types";
|
|
3
|
+
import type { StringOrBashExpression } from "../../bash/BashExpression";
|
|
3
4
|
|
|
4
5
|
export const processSecretsAsFiles = <
|
|
5
6
|
T extends {
|
|
6
7
|
env: {
|
|
7
|
-
secret: Record<string,
|
|
8
|
+
secret: Record<string, StringOrBashExpression>;
|
|
8
9
|
};
|
|
9
|
-
} & DeployConfigKubernetesValues
|
|
10
|
+
} & DeployConfigKubernetesValues,
|
|
10
11
|
>(
|
|
11
|
-
values: T
|
|
12
|
+
values: T,
|
|
12
13
|
): T => {
|
|
13
14
|
if (!values.secretsAsFile || values.secretsAsFile.length === 0) {
|
|
14
15
|
return values;
|
|
@@ -26,7 +27,7 @@ export const processSecretsAsFiles = <
|
|
|
26
27
|
values.secretsAsFile.map((key) => [
|
|
27
28
|
key + "_content",
|
|
28
29
|
values.env.secret[key],
|
|
29
|
-
])
|
|
30
|
+
]),
|
|
30
31
|
),
|
|
31
32
|
},
|
|
32
33
|
},
|
package/src/deploy/types/base.ts
CHANGED
|
@@ -31,6 +31,12 @@ export type DeployConfigBase = {
|
|
|
31
31
|
* @deprecated use deploy.jobVars for deploy job specific variables
|
|
32
32
|
*/
|
|
33
33
|
extraVars?: Record<string, string>;
|
|
34
|
+
/**
|
|
35
|
+
* additional vars only for the runner.
|
|
36
|
+
* Also if you use services: that require env vars, you need to set them here.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
runnerVariables?: Record<string, string>;
|
|
34
40
|
};
|
|
35
41
|
|
|
36
42
|
export type AllowUnknownProps<T extends Record<string, unknown>> = T &
|
package/src/deploy/utils.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { DeployConfigKubernetesCluster } from "./types";
|
|
|
3
3
|
import { isOfDeployType } from "./types";
|
|
4
4
|
|
|
5
5
|
export const getFullKubernetesClusterName = (
|
|
6
|
-
cluster: DeployConfigKubernetesCluster
|
|
6
|
+
cluster: DeployConfigKubernetesCluster,
|
|
7
7
|
) => {
|
|
8
8
|
if (cluster.type === "gcloud") {
|
|
9
9
|
return `gke_${cluster.projectId}_${cluster.region}_${cluster.name}`;
|
|
@@ -12,7 +12,7 @@ export const getFullKubernetesClusterName = (
|
|
|
12
12
|
|
|
13
13
|
export const getKubernetesNamespace = (
|
|
14
14
|
config: Pick<Config, "customerName" | "appName">,
|
|
15
|
-
env: string
|
|
15
|
+
env: string,
|
|
16
16
|
) => {
|
|
17
17
|
return `${config.customerName}-${config.appName}-${env}`;
|
|
18
18
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./pipeline
|
|
1
|
+
export * from "./pipeline";
|
|
2
2
|
export * from "./types";
|
|
3
3
|
export * from "./rules";
|
|
4
4
|
export * from "./runner";
|
|
@@ -6,3 +6,4 @@ export * from "./config";
|
|
|
6
6
|
export * from "./context";
|
|
7
7
|
export * from "./build";
|
|
8
8
|
export * from "./deploy";
|
|
9
|
+
export * from "./utils/writeFiles";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// we can't import the package.json directly, because the bundling process will inline it
|
|
2
|
+
// but the version is only set during deployement, when its already bundled
|
|
3
|
+
// instead we need to use require.main.path to get the path of the main module, which is actually the file in the bin
|
|
4
|
+
// this will point to the root package.json
|
|
5
|
+
|
|
6
|
+
const path = require.main?.path + "/../package.json";
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8
|
+
const ownPkg = require(path);
|
|
9
|
+
|
|
10
|
+
export default ownPkg;
|