@catladder/pipeline 0.0.0-refactor-docker-c24f8608 → 0.0.0-refactor-cache-b38c122b
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/README.md +15 -1
- package/dist/build/artifacts/createBuildJobArtifact.d.ts +3 -0
- package/dist/build/artifacts/createBuildJobArtifact.js +97 -0
- package/dist/build/base/constants.js +1 -1
- package/dist/build/base/createAppBuildJob.d.ts +4 -3
- package/dist/build/base/createAppBuildJob.js +14 -16
- package/dist/build/base/createBuildJobDefinition.d.ts +6 -0
- package/dist/build/base/createBuildJobDefinition.js +58 -0
- package/dist/build/base/index.d.ts +7 -4
- package/dist/build/base/index.js +14 -5
- package/dist/build/base/writeBuildInfo.js +1 -1
- package/dist/build/base/writeDotEnv.d.ts +2 -1
- package/dist/build/base/writeDotEnv.js +17 -3
- package/dist/build/cache/createJobCache.d.ts +7 -0
- package/dist/build/cache/createJobCache.js +109 -0
- package/dist/build/cache/getAllCacheConfigsFromConfig.d.ts +3 -0
- package/dist/build/cache/getAllCacheConfigsFromConfig.js +62 -0
- package/dist/build/cache/transformLegacyJobCache.d.ts +3 -0
- package/dist/build/cache/transformLegacyJobCache.js +29 -0
- package/dist/build/custom/__tests__/testJob.test.js +12 -15
- package/dist/build/custom/buildJob.js +4 -54
- package/dist/build/custom/testJob.d.ts +1 -1
- package/dist/build/custom/testJob.js +16 -15
- package/dist/build/docker.d.ts +9 -13
- package/dist/build/docker.js +25 -18
- package/dist/build/index.d.ts +13 -6
- package/dist/build/index.js +29 -7
- package/dist/build/node/buildJob.d.ts +6 -2
- package/dist/build/node/buildJob.js +37 -42
- package/dist/build/node/cache.d.ts +7 -6
- package/dist/build/node/cache.js +30 -18
- package/dist/build/node/constants.js +2 -2
- package/dist/build/node/index.d.ts +2 -2
- package/dist/build/node/meteor.js +7 -11
- package/dist/build/node/testJob.d.ts +3 -2
- package/dist/build/node/testJob.js +23 -17
- package/dist/build/node/yarn.d.ts +4 -4
- package/dist/build/node/yarn.js +5 -9
- package/dist/build/rails/build.d.ts +1 -1
- package/dist/build/rails/build.js +10 -5
- package/dist/build/rails/test.d.ts +1 -1
- package/dist/build/rails/test.js +9 -4
- package/dist/build/sbom.js +6 -5
- package/dist/build/types.d.ts +107 -6
- package/dist/build/types.js +7 -1
- package/dist/bundles/catladder-gitlab/index.js +3192 -1681
- package/dist/catladder-gitlab.js +131 -6
- package/dist/config/__tests__/getAllEnvs.test.d.ts +1 -0
- package/dist/config/__tests__/getAllEnvs.test.js +79 -0
- package/dist/config/__tests__/getAllEnvsInAllComponents.test.d.ts +1 -0
- package/dist/config/__tests__/getAllEnvsInAllComponents.test.js +73 -0
- package/dist/config/readConfig.d.ts +2 -2
- package/dist/config/readConfig.js +188 -37
- package/dist/constants.js +1 -1
- package/dist/context/createAllComponentsContext.d.ts +12 -0
- package/dist/context/createAllComponentsContext.js +159 -0
- package/dist/context/createComponentContext.d.ts +11 -0
- package/dist/context/createComponentContext.js +256 -0
- package/dist/context/createWorkspaceContext.d.ts +16 -0
- package/dist/context/createWorkspaceContext.js +173 -0
- package/dist/context/getBuildInfoVariables.d.ts +3 -4
- package/dist/context/getBuildInfoVariables.js +43 -17
- package/dist/context/getEnvironmentContext.d.ts +1 -1
- package/dist/context/getEnvironmentVariables.d.ts +2 -5
- package/dist/context/getEnvironmentVariables.js +5 -4
- package/dist/context/getLabels.js +5 -5
- package/dist/context/index.d.ts +2 -17
- package/dist/context/index.js +2 -164
- package/dist/deploy/base/deploy.d.ts +2 -2
- package/dist/deploy/base/deploy.js +29 -14
- package/dist/deploy/base/index.d.ts +1 -3
- package/dist/deploy/base/rollback.d.ts +1 -1
- package/dist/deploy/base/stop.d.ts +1 -1
- package/dist/deploy/base/variables.js +1 -1
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +1 -5
- package/dist/deploy/cloudRun/artifactsRegistry.js +10 -11
- package/dist/deploy/cloudRun/cloudRunRevisions.js +4 -5
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +76 -50
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +5 -1
- package/dist/deploy/cloudRun/createJobs/common.js +3 -2
- package/dist/deploy/cloudRun/createJobs/index.js +2 -4
- package/dist/deploy/cloudRun/index.d.ts +2 -2
- package/dist/deploy/custom/deployJob.js +8 -9
- package/dist/deploy/custom/index.d.ts +2 -2
- package/dist/deploy/dockerTag/deployJob.js +3 -5
- package/dist/deploy/dockerTag/index.d.ts +2 -2
- package/dist/deploy/index.d.ts +7 -7
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
- package/dist/deploy/kubernetes/cloudSql/index.js +12 -10
- package/dist/deploy/kubernetes/deployJob.js +6 -9
- package/dist/deploy/kubernetes/index.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeEnv.js +2 -1
- package/dist/deploy/kubernetes/kubeValues.js +10 -10
- package/dist/deploy/kubernetes/mongodb.js +11 -11
- package/dist/deploy/sbom.d.ts +1 -1
- package/dist/deploy/sbom.js +4 -3
- package/dist/deploy/types/custom.d.ts +2 -6
- package/dist/deploy/types/googleCloudRun.d.ts +26 -0
- package/dist/deploy/types/index.d.ts +3 -3
- package/dist/deploy/types/index.js +1 -1
- package/dist/deploy/utils.js +2 -1
- package/dist/packageInfos.d.ts +3 -1
- package/dist/packageInfos.js +13 -7
- package/dist/pipeline/__tests__/getPipelineStages.test.d.ts +1 -0
- package/dist/pipeline/__tests__/getPipelineStages.test.js +73 -0
- package/dist/pipeline/createAllJobs.d.ts +12 -10
- package/dist/pipeline/createAllJobs.js +85 -24
- package/dist/pipeline/createChildPipeline.js +2 -1
- package/dist/pipeline/createJobsForComponent.d.ts +3 -3
- package/dist/pipeline/createJobsForComponent.js +6 -147
- package/dist/pipeline/createJobsForWorkspace.d.ts +3 -0
- package/dist/pipeline/createJobsForWorkspace.js +12 -0
- package/dist/pipeline/createMainPipeline.js +28 -7
- package/dist/pipeline/generatePipelineFiles.d.ts +38 -0
- package/dist/pipeline/generatePipelineFiles.js +79 -27
- package/dist/pipeline/getPipelineStages.d.ts +3 -4
- package/dist/pipeline/getPipelineStages.js +6 -5
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +4 -18
- package/dist/pipeline/gitlab/createGitlabJobs.js +206 -93
- package/dist/pipeline/gitlab/createGitlabPipeline.js +3 -0
- package/dist/pipeline/gitlab/gitlabReleaseJobs.d.ts +2 -0
- package/dist/pipeline/gitlab/gitlabReleaseJobs.js +3 -0
- package/dist/pipeline/gitlab/sortGitLabJobDefProps.d.ts +7 -0
- package/dist/pipeline/gitlab/sortGitLabJobDefProps.js +27 -0
- package/dist/pipeline/packageManager.d.ts +3 -2
- package/dist/pipeline/packageManager.js +44 -16
- package/dist/pipeline/yarn/yarnUtils.d.ts +2 -2
- package/dist/pipeline/yarn/yarnUtils.js +12 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +10 -5
- package/dist/types/context.d.ts +91 -19
- package/dist/types/context.js +10 -1
- package/dist/types/environmentContext.d.ts +5 -6
- package/dist/types/gitlab-types.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/jobDefinition.d.ts +11 -0
- package/dist/types/jobDefinition.js +5 -0
- package/dist/types/jobs.d.ts +8 -2
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +7 -2
- package/dist/utils/jsonParse.d.ts +1 -0
- package/dist/utils/jsonParse.js +14 -0
- package/dist/utils/removeUndefined.d.ts +1 -0
- package/dist/utils/removeUndefined.js +36 -0
- package/dist/utils/writeFiles.d.ts +5 -1
- package/dist/utils/writeFiles.js +10 -2
- package/examples/.test-gen-ignore +1 -0
- package/examples/__snapshots__/cloud-run-http2.test.ts.snap +1342 -0
- package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +1342 -0
- package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +1326 -0
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +1342 -0
- package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +1446 -0
- package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +1342 -0
- package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +1359 -0
- package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +1342 -0
- package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +1342 -0
- package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +1342 -0
- package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +1410 -0
- package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +1226 -0
- package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +1342 -0
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +2826 -0
- package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +1737 -0
- package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +1350 -0
- package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +1193 -0
- package/examples/__snapshots__/custom-build-job.test.ts.snap +1082 -0
- package/examples/__snapshots__/custom-deploy.test.ts.snap +1100 -0
- package/examples/__snapshots__/custom-envs.test.ts.snap +710 -0
- package/examples/__snapshots__/custom-sbom-java.test.ts.snap +1090 -0
- package/examples/__snapshots__/git-submodule.test.ts.snap +1343 -0
- package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +1779 -0
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +1791 -0
- package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +1799 -0
- package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +3353 -0
- package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +1903 -0
- package/examples/__snapshots__/local-dot-env.test.ts.snap +1342 -0
- package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +1840 -0
- package/examples/__snapshots__/multiline-var.test.ts.snap +3377 -0
- package/examples/__snapshots__/native-app.test.ts.snap +2158 -0
- package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +1342 -0
- package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +1350 -0
- package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +1487 -0
- package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +1471 -0
- package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +1268 -0
- package/examples/__snapshots__/workspace-api-www-custom-cache.test.ts.snap +2374 -0
- package/examples/__snapshots__/workspace-api-www.test.ts.snap +2354 -0
- package/examples/__utils__/helpers.ts +14 -1
- package/examples/cloud-run-http2.test.ts +11 -0
- package/examples/cloud-run-http2.ts +29 -0
- package/examples/cloud-run-memory-limit.test.ts +11 -0
- package/examples/cloud-run-memory-limit.ts +6 -4
- package/examples/cloud-run-meteor-with-worker.test.ts +11 -0
- package/examples/cloud-run-meteor-with-worker.ts +6 -4
- package/examples/cloud-run-no-cpu-throttling.test.ts +11 -0
- package/examples/cloud-run-no-cpu-throttling.ts +6 -4
- package/examples/cloud-run-no-service.test.ts +11 -0
- package/examples/cloud-run-no-service.ts +5 -4
- package/examples/cloud-run-non-public.test.ts +11 -0
- package/examples/cloud-run-non-public.ts +5 -4
- package/examples/cloud-run-post-stop-job.test.ts +11 -0
- package/examples/cloud-run-post-stop-job.ts +6 -4
- package/examples/cloud-run-service-custom-vpc.test.ts +11 -0
- package/examples/cloud-run-service-custom-vpc.ts +30 -0
- package/examples/cloud-run-service-gen2.test.ts +11 -0
- package/examples/cloud-run-service-gen2.ts +6 -4
- package/examples/cloud-run-service-increase-timout.test.ts +11 -0
- package/examples/cloud-run-service-increase-timout.ts +29 -0
- package/examples/cloud-run-service-with-volumes.test.ts +11 -0
- package/examples/cloud-run-service-with-volumes.ts +6 -4
- package/examples/cloud-run-storybook.test.ts +11 -0
- package/examples/cloud-run-storybook.ts +14 -5
- package/examples/cloud-run-with-ngnix.test.ts +11 -0
- package/examples/cloud-run-with-ngnix.ts +10 -5
- package/examples/cloud-run-with-sql-reuse-db.test.ts +11 -0
- package/examples/cloud-run-with-sql-reuse-db.ts +5 -4
- package/examples/cloud-run-with-sql.test.ts +11 -0
- package/examples/cloud-run-with-sql.ts +7 -20
- package/examples/cloud-run-with-worker.test.ts +11 -0
- package/examples/cloud-run-with-worker.ts +6 -4
- package/examples/custom-build-job-with-tests.test.ts +11 -0
- package/examples/custom-build-job-with-tests.ts +5 -4
- package/examples/custom-build-job.test.ts +11 -0
- package/examples/custom-build-job.ts +5 -4
- package/examples/custom-deploy.test.ts +11 -0
- package/examples/custom-deploy.ts +5 -4
- package/examples/custom-envs.test.ts +11 -0
- package/examples/custom-envs.ts +5 -4
- package/examples/custom-sbom-java.test.ts +11 -0
- package/examples/custom-sbom-java.ts +10 -6
- package/examples/git-submodule.test.ts +11 -0
- package/examples/git-submodule.ts +30 -0
- package/examples/kubernetes-application-customization.test.ts +11 -0
- package/examples/kubernetes-application-customization.ts +6 -4
- package/examples/kubernetes-with-cloud-sql-legacy.test.ts +11 -0
- package/examples/kubernetes-with-cloud-sql-legacy.ts +6 -4
- package/examples/kubernetes-with-cloud-sql.test.ts +11 -0
- package/examples/kubernetes-with-cloud-sql.ts +6 -4
- package/examples/kubernetes-with-jobs.test.ts +11 -0
- package/examples/kubernetes-with-jobs.ts +6 -4
- package/examples/kubernetes-with-mongodb.test.ts +11 -0
- package/examples/kubernetes-with-mongodb.ts +6 -4
- package/examples/local-dot-env.test.ts +11 -0
- package/examples/local-dot-env.ts +6 -4
- package/examples/meteor-kubernetes.test.ts +11 -0
- package/examples/meteor-kubernetes.ts +3 -4
- package/examples/multiline-var.test.ts +11 -0
- package/examples/multiline-var.ts +5 -4
- package/examples/native-app.test.ts +11 -0
- package/examples/native-app.ts +12 -10
- package/examples/node-build-with-custom-image.test.ts +11 -0
- package/examples/node-build-with-custom-image.ts +5 -4
- package/examples/node-build-with-docker-additions.test.ts +11 -0
- package/examples/node-build-with-docker-additions.ts +5 -4
- package/examples/rails-k8s-with-worker-dockerfile.test.ts +9 -0
- package/examples/rails-k8s-with-worker.test.ts +11 -0
- package/examples/rails-k8s-with-worker.ts +4 -10
- package/examples/wait-for-other-deploy.test.ts +11 -0
- package/examples/wait-for-other-deploy.ts +5 -4
- package/examples/workspace-api-www-custom-cache.test.ts +11 -0
- package/examples/workspace-api-www-custom-cache.ts +51 -0
- package/examples/workspace-api-www.test.ts +11 -0
- package/examples/workspace-api-www.ts +45 -0
- package/package.json +10 -6
- package/scripts/bundle +1 -1
- package/scripts/generate-examples-test.ts +91 -0
- package/scripts/tsconfig.json +7 -0
- package/src/build/artifacts/createBuildJobArtifact.ts +61 -0
- package/src/build/base/constants.ts +1 -1
- package/src/build/base/createAppBuildJob.ts +37 -26
- package/src/build/base/createBuildJobDefinition.ts +37 -0
- package/src/build/base/index.ts +35 -6
- package/src/build/base/writeBuildInfo.ts +1 -1
- package/src/build/base/writeDotEnv.ts +17 -3
- package/src/build/cache/createJobCache.ts +82 -0
- package/src/build/cache/getAllCacheConfigsFromConfig.ts +26 -0
- package/src/build/cache/transformLegacyJobCache.ts +14 -0
- package/src/build/custom/__tests__/testJob.test.ts +9 -12
- package/src/build/custom/buildJob.ts +5 -28
- package/src/build/custom/testJob.ts +14 -13
- package/src/build/docker.ts +40 -28
- package/src/build/index.ts +39 -7
- package/src/build/node/buildJob.ts +62 -68
- package/src/build/node/cache.ts +55 -32
- package/src/build/node/constants.ts +2 -2
- package/src/build/node/index.ts +4 -2
- package/src/build/node/meteor.ts +12 -25
- package/src/build/node/testJob.ts +40 -24
- package/src/build/node/yarn.ts +12 -10
- package/src/build/rails/build.ts +17 -7
- package/src/build/rails/test.ts +17 -9
- package/src/build/sbom.ts +12 -7
- package/src/build/types.ts +140 -6
- package/src/catladder-gitlab.ts +11 -6
- package/src/config/__tests__/__snapshots__/getAllEnvs.test.ts.snap +31 -0
- package/src/config/__tests__/__snapshots__/getAllEnvsInAllComponents.test.ts.snap +15 -0
- package/src/config/__tests__/getAllEnvs.test.ts +71 -0
- package/src/config/__tests__/getAllEnvsInAllComponents.test.ts +63 -0
- package/src/config/readConfig.ts +12 -17
- package/src/context/createAllComponentsContext.ts +31 -0
- package/src/context/createComponentContext.ts +135 -0
- package/src/context/createWorkspaceContext.ts +56 -0
- package/src/context/getBuildInfoVariables.ts +26 -30
- package/src/context/getEnvironmentContext.ts +2 -2
- package/src/context/getEnvironmentVariables.ts +12 -7
- package/src/context/getLabels.ts +3 -3
- package/src/context/index.ts +1 -76
- package/src/deploy/base/deploy.ts +46 -32
- package/src/deploy/base/index.ts +8 -3
- package/src/deploy/base/rollback.ts +1 -4
- package/src/deploy/base/stop.ts +1 -4
- package/src/deploy/base/variables.ts +1 -1
- package/src/deploy/cloudRun/artifactsRegistry.ts +8 -14
- package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -5
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +109 -74
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +5 -1
- package/src/deploy/cloudRun/createJobs/common.ts +2 -2
- package/src/deploy/cloudRun/createJobs/index.ts +1 -4
- package/src/deploy/cloudRun/index.ts +68 -67
- package/src/deploy/custom/deployJob.ts +9 -8
- package/src/deploy/custom/index.ts +2 -2
- package/src/deploy/dockerTag/deployJob.ts +2 -5
- package/src/deploy/dockerTag/index.ts +8 -7
- package/src/deploy/index.ts +11 -9
- package/src/deploy/kubernetes/additionalSecretKeys.ts +3 -1
- package/src/deploy/kubernetes/cloudSql/index.ts +8 -5
- package/src/deploy/kubernetes/deployJob.ts +3 -6
- package/src/deploy/kubernetes/index.ts +42 -41
- package/src/deploy/kubernetes/kubeEnv.ts +1 -1
- package/src/deploy/kubernetes/kubeValues.ts +3 -3
- package/src/deploy/kubernetes/mongodb.ts +6 -6
- package/src/deploy/sbom.ts +11 -7
- package/src/deploy/types/custom.ts +3 -7
- package/src/deploy/types/googleCloudRun.ts +29 -0
- package/src/deploy/types/index.ts +2 -2
- package/src/deploy/utils.ts +1 -1
- package/src/packageInfos.ts +7 -3
- package/src/pipeline/__tests__/__snapshots__/getPipelineStages.test.ts.snap +69 -0
- package/src/pipeline/__tests__/getPipelineStages.test.ts +63 -0
- package/src/pipeline/createAllJobs.ts +61 -41
- package/src/pipeline/createChildPipeline.ts +2 -0
- package/src/pipeline/createJobsForComponent.ts +7 -31
- package/src/pipeline/createJobsForWorkspace.ts +12 -0
- package/src/pipeline/createMainPipeline.ts +43 -23
- package/src/pipeline/generatePipelineFiles.ts +63 -25
- package/src/pipeline/getPipelineStages.ts +6 -5
- package/src/pipeline/gitlab/createGitlabJobs.ts +276 -116
- package/src/pipeline/gitlab/createGitlabPipeline.ts +5 -1
- package/src/pipeline/gitlab/gitlabReleaseJobs.ts +5 -0
- package/src/pipeline/gitlab/sortGitLabJobDefProps.ts +59 -0
- package/src/pipeline/packageManager.ts +27 -11
- package/src/pipeline/yarn/yarnUtils.ts +9 -6
- package/src/types/config.ts +12 -2
- package/src/types/context.ts +124 -20
- package/src/types/environmentContext.ts +6 -7
- package/src/types/gitlab-types.ts +2 -2
- package/src/types/index.ts +1 -0
- package/src/types/jobDefinition.ts +34 -0
- package/src/types/jobs.ts +8 -9
- package/src/utils/index.ts +4 -1
- package/src/utils/jsonParse.ts +7 -0
- package/src/utils/removeUndefined.ts +4 -0
- package/src/utils/writeFiles.ts +14 -1
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +0 -1971
- package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +0 -1939
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +0 -1971
- package/examples/__snapshots__/cloud-run-no-service.ts.snap +0 -2023
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +0 -1971
- package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +0 -1982
- package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +0 -1971
- package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +0 -2015
- package/examples/__snapshots__/cloud-run-storybook.ts.snap +0 -1687
- package/examples/__snapshots__/cloud-run-with-ngnix.ts.snap +0 -1971
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +0 -3947
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +0 -3946
- package/examples/__snapshots__/cloud-run-with-worker.ts.snap +0 -1979
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +0 -1795
- package/examples/__snapshots__/custom-build-job.ts.snap +0 -1495
- package/examples/__snapshots__/custom-deploy.ts.snap +0 -1733
- package/examples/__snapshots__/custom-envs.ts.snap +0 -1181
- package/examples/__snapshots__/custom-sbom-java.ts.snap +0 -1503
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +0 -2462
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +0 -2474
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +0 -2482
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +0 -4570
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +0 -2586
- package/examples/__snapshots__/local-dot-env.ts.snap +0 -1971
- package/examples/__snapshots__/meteor-kubernetes.ts.snap +0 -2507
- package/examples/__snapshots__/multiline-var.ts.snap +0 -4500
- package/examples/__snapshots__/native-app.ts.snap +0 -3171
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +0 -1971
- package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +0 -1979
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +0 -4029
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +0 -2117
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ComponentContext } from "../../../types/context";
|
|
2
|
-
import { allowFailureInScripts } from "../../../utils/gitlab";
|
|
3
2
|
|
|
4
3
|
import type {
|
|
5
4
|
DeployConfigCloudRunJob,
|
|
@@ -22,6 +21,7 @@ import type {
|
|
|
22
21
|
StringOrBashExpression,
|
|
23
22
|
} from "../../../bash/BashExpression";
|
|
24
23
|
import { ENV_VARS_FILENAME } from "./constants";
|
|
24
|
+
import { notNil } from "../../../utils";
|
|
25
25
|
|
|
26
26
|
const getJobRunScriptForJob = (
|
|
27
27
|
context: ComponentContext,
|
|
@@ -81,83 +81,115 @@ export const getJobRunScripts = (
|
|
|
81
81
|
);
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
export const getJobCreateScripts = (context: ComponentContext) =>
|
|
85
|
-
|
|
84
|
+
export const getJobCreateScripts = (context: ComponentContext): string[] =>
|
|
85
|
+
getCloudRunJobsWithNames(context).map(
|
|
86
|
+
(
|
|
87
|
+
{
|
|
88
|
+
job: {
|
|
89
|
+
command,
|
|
90
|
+
image,
|
|
91
|
+
cpu,
|
|
92
|
+
memory = "512Mi",
|
|
93
|
+
timeout = "10m",
|
|
94
|
+
parallelism = 1,
|
|
95
|
+
volumes,
|
|
96
|
+
},
|
|
97
|
+
jobName,
|
|
98
|
+
},
|
|
99
|
+
jobIndex,
|
|
100
|
+
): string => {
|
|
101
|
+
const commandArray = Array.isArray(command)
|
|
102
|
+
? command
|
|
103
|
+
: command.split(" ");
|
|
104
|
+
|
|
105
|
+
const {
|
|
106
|
+
image: commonImage,
|
|
107
|
+
project,
|
|
108
|
+
region,
|
|
109
|
+
...deployArgs
|
|
110
|
+
} = getCommonDeployArgs(context);
|
|
111
|
+
const commonDeployArgsString = createArgsString({
|
|
112
|
+
command: `"${commandArray.join(",")}"`,
|
|
113
|
+
labels: `"${makeLabelString(getLabels(context))},cloud-run-job-name=$current_job_name"`,
|
|
114
|
+
image: `"${image ?? commonImage}"`,
|
|
115
|
+
project,
|
|
116
|
+
region,
|
|
117
|
+
cpu,
|
|
118
|
+
memory,
|
|
119
|
+
parallelism,
|
|
120
|
+
"task-timeout": timeout,
|
|
121
|
+
"env-vars-file": ENV_VARS_FILENAME,
|
|
122
|
+
"max-retries": 0,
|
|
123
|
+
...deployArgs,
|
|
124
|
+
});
|
|
86
125
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
126
|
+
// due to some oversight from google, jobs create does not yet accept `--add-volume` 🤦
|
|
127
|
+
// lucky, update on the other hand accepts it... so let's just imediatly update it
|
|
128
|
+
// we cannot upsert a job, so we have to create it and catch the error and then update
|
|
129
|
+
const hasVolumes = Object.keys(volumes || {}).length > 0;
|
|
130
|
+
const needsBeta = hasVolumes ? "beta" : undefined;
|
|
131
|
+
const volumeArgs = hasVolumes
|
|
132
|
+
? createArgsString(...createVolumeConfig(volumes, "job"))
|
|
133
|
+
: "";
|
|
91
134
|
|
|
92
|
-
|
|
135
|
+
return [
|
|
136
|
+
jobIndex === 0
|
|
137
|
+
? `exist_job_names="$(\n ${gcloudRunCmd()} jobs list --filter='metadata.name ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --project='${project}' --region='${region}'\n)"`
|
|
138
|
+
: null,
|
|
139
|
+
`current_job_name="${jobName}"`,
|
|
140
|
+
'if grep "$current_job_name" <<<"$exist_job_names" >/dev/null; then',
|
|
141
|
+
` ${gcloudRunCmd(needsBeta)} jobs update "$current_job_name" ${commonDeployArgsString} ${volumeArgs}`,
|
|
142
|
+
"else",
|
|
143
|
+
` ${gcloudRunCmd()} jobs create "$current_job_name" ${commonDeployArgsString}`,
|
|
144
|
+
"fi",
|
|
145
|
+
]
|
|
146
|
+
.filter(notNil)
|
|
147
|
+
.join("\n");
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
export const getCreateScheduleScripts = (
|
|
93
152
|
context: ComponentContext,
|
|
94
|
-
|
|
95
|
-
job: DeployConfigCloudRunJob,
|
|
96
|
-
) => {
|
|
97
|
-
const commonDeployArgs = getCommonDeployArgs(context);
|
|
98
|
-
|
|
99
|
-
// due to some oversight from google, jobs create does not yet accept `--add-volume` 🤦
|
|
100
|
-
// lucky, update on the other hand accepts it... so let's just imediatly update it
|
|
101
|
-
// we cannot upsert a job, so we have to create it and catch the error and then update
|
|
102
|
-
const commandArray = Array.isArray(job.command)
|
|
103
|
-
? job.command
|
|
104
|
-
: job.command.split(" ");
|
|
105
|
-
|
|
106
|
-
const commonDeployArgsString = createArgsString({
|
|
107
|
-
command: '"' + commandArray.join(",") + '"',
|
|
108
|
-
...commonDeployArgs,
|
|
109
|
-
labels: makeLabelString({
|
|
110
|
-
...getLabels(context),
|
|
111
|
-
"cloud-run-job-name": jobName.toString(),
|
|
112
|
-
}),
|
|
113
|
-
image: job.image || commonDeployArgs.image,
|
|
114
|
-
cpu: job?.cpu,
|
|
115
|
-
memory: job.memory || "512Mi",
|
|
116
|
-
"task-timeout": job.timeout || "10m",
|
|
117
|
-
parallelism: job.parallelism || 1,
|
|
118
|
-
"env-vars-file": ENV_VARS_FILENAME,
|
|
119
|
-
"max-retries": 0,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const requiresBeta = job?.volumes && Object.keys(job?.volumes).length > 0;
|
|
123
|
-
|
|
124
|
-
const argsString = `${jobName} ${commonDeployArgsString}`;
|
|
125
|
-
return [
|
|
126
|
-
...allowFailureInScripts([`${gcloudRunCmd()} jobs create ${argsString}`]),
|
|
127
|
-
`${gcloudRunCmd(
|
|
128
|
-
requiresBeta ? "beta" : undefined,
|
|
129
|
-
)} jobs update ${argsString} ${createArgsString(
|
|
130
|
-
...createVolumeConfig(job?.volumes, "job"),
|
|
131
|
-
)}`,
|
|
132
|
-
];
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export const getCreateScheduleScripts = (context: ComponentContext) => {
|
|
153
|
+
): string[] => {
|
|
136
154
|
const jobsWithSchedule = getCloudRunJobsWithSchedule(context);
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
155
|
+
const { region: location, projectId: project } =
|
|
156
|
+
getCloudRunDeployConfig(context);
|
|
157
|
+
|
|
158
|
+
const uriBase = `https://${location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${project}/jobs`;
|
|
159
|
+
const gcloudArgs = {
|
|
160
|
+
project,
|
|
161
|
+
location,
|
|
162
|
+
uri: `"$current_job_uri"`,
|
|
163
|
+
"http-method": "POST",
|
|
164
|
+
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
return jobsWithSchedule.map(
|
|
168
|
+
(
|
|
169
|
+
{ job: { maxRetryAttempts, schedule }, jobName, schedulerName },
|
|
170
|
+
jobIndex,
|
|
171
|
+
): string => {
|
|
141
172
|
const argsString = createArgsString({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
"max-retry-attempts": job.maxRetryAttempts ?? 0,
|
|
146
|
-
|
|
147
|
-
uri: `"https://${deployConfig.region}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${deployConfig.projectId}/jobs/${jobName}:run"`,
|
|
148
|
-
"http-method": "POST",
|
|
149
|
-
"oauth-service-account-email":
|
|
150
|
-
"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com",
|
|
173
|
+
...gcloudArgs,
|
|
174
|
+
schedule: `"${schedule}"`,
|
|
175
|
+
"max-retry-attempts": maxRetryAttempts ?? 0,
|
|
151
176
|
});
|
|
152
|
-
const commonArgs = `http ${schedulerName} ${argsString}`;
|
|
153
177
|
return [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
178
|
+
jobIndex === 0
|
|
179
|
+
? `exist_scheduler_names="$(\n ${gcloudSchedulerCmd()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"`
|
|
180
|
+
: null,
|
|
181
|
+
`current_job_uri="${uriBase}/${jobName}:run"`,
|
|
182
|
+
`current_scheduler_name="${schedulerName}"`,
|
|
183
|
+
`if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
|
|
184
|
+
` ${gcloudSchedulerCmd()} jobs update http "$current_scheduler_name" ${argsString}`,
|
|
185
|
+
`else`,
|
|
186
|
+
` ${gcloudSchedulerCmd()} jobs create http "$current_scheduler_name" ${argsString}`,
|
|
187
|
+
`fi`,
|
|
188
|
+
]
|
|
189
|
+
.filter(notNil)
|
|
190
|
+
.join("\n");
|
|
191
|
+
},
|
|
192
|
+
);
|
|
161
193
|
};
|
|
162
194
|
|
|
163
195
|
const getCloudRunJobsWithSchedule = (context: ComponentContext) => {
|
|
@@ -170,11 +202,13 @@ const getCloudRunJobsWithSchedule = (context: ComponentContext) => {
|
|
|
170
202
|
): entry is {
|
|
171
203
|
jobName: BashExpression;
|
|
172
204
|
job: DeployConfigCloudRunJobWithSchedule;
|
|
205
|
+
jobKey: string;
|
|
173
206
|
} => entry.job.when === "schedule",
|
|
174
207
|
)
|
|
175
|
-
.map(({ job, jobName }) => ({
|
|
208
|
+
.map(({ job, jobName, jobKey }) => ({
|
|
176
209
|
job,
|
|
177
210
|
jobName,
|
|
211
|
+
jobKey,
|
|
178
212
|
schedulerName: jobName.concat("-scheduler"),
|
|
179
213
|
}));
|
|
180
214
|
};
|
|
@@ -190,9 +224,10 @@ const getCloudRunJobsWithNames = (context: ComponentContext) => {
|
|
|
190
224
|
.filter((entry): entry is [string, DeployConfigCloudRunJob] =>
|
|
191
225
|
Boolean(entry[1]),
|
|
192
226
|
)
|
|
193
|
-
.map(([
|
|
194
|
-
jobName: getFullJobName(
|
|
227
|
+
.map(([jobKey, job]) => ({
|
|
228
|
+
jobName: getFullJobName(jobKey),
|
|
195
229
|
job,
|
|
230
|
+
jobKey,
|
|
196
231
|
}));
|
|
197
232
|
return jobsWithNames;
|
|
198
233
|
};
|
|
@@ -25,7 +25,7 @@ export const getServiceDeployScript = (
|
|
|
25
25
|
const customConfig = service !== true ? service : undefined;
|
|
26
26
|
const command =
|
|
27
27
|
service !== true
|
|
28
|
-
? service?.command ?? context.
|
|
28
|
+
? service?.command ?? context.build.config.startCommand
|
|
29
29
|
: undefined;
|
|
30
30
|
|
|
31
31
|
const commandArray = command
|
|
@@ -49,6 +49,10 @@ export const getServiceDeployScript = (
|
|
|
49
49
|
"cpu-throttling": customConfig?.noCpuThrottling !== true,
|
|
50
50
|
cpu: customConfig?.cpu,
|
|
51
51
|
memory: customConfig?.memory,
|
|
52
|
+
timeout: customConfig?.timeout,
|
|
53
|
+
"vpc-connector": customConfig?.vpcConnector,
|
|
54
|
+
"vpc-egress": customConfig?.vpcEgress,
|
|
55
|
+
"use-http2": customConfig?.http2,
|
|
52
56
|
"allow-unauthenticated": customConfig?.allowUnauthenticated ?? true,
|
|
53
57
|
ingress: customConfig?.ingress ?? "all",
|
|
54
58
|
"cpu-boost": true,
|
|
@@ -21,7 +21,7 @@ export const setGoogleProjectNumberScript = (
|
|
|
21
21
|
`export GCLOUD_PROJECT_NUMBER=$(${gcloudCmd()} projects describe ${
|
|
22
22
|
deployConfig.projectId
|
|
23
23
|
} --format="value(projectNumber)")`,
|
|
24
|
-
|
|
24
|
+
'echo "GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER"',
|
|
25
25
|
];
|
|
26
26
|
|
|
27
27
|
export const makeLabelString = (obj: Record<string, unknown>) =>
|
|
@@ -30,7 +30,7 @@ export const makeLabelString = (obj: Record<string, unknown>) =>
|
|
|
30
30
|
.join(",");
|
|
31
31
|
|
|
32
32
|
export const getCloudRunDeployConfig = (context: ComponentContext) => {
|
|
33
|
-
const deployConfig = context.
|
|
33
|
+
const deployConfig = context.deploy?.config;
|
|
34
34
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
35
35
|
// should not happen
|
|
36
36
|
throw new Error("deploy config is wrong");
|
|
@@ -12,10 +12,7 @@ import { getCloudRunStopScripts } from "./getCloudRunStopScripts";
|
|
|
12
12
|
export const createGoogleCloudRunDeployJobs = (
|
|
13
13
|
context: ComponentContext,
|
|
14
14
|
): CatladderJob[] => {
|
|
15
|
-
const deployConfig = context.
|
|
16
|
-
if (deployConfig === false) {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
15
|
+
const deployConfig = context.deploy?.config;
|
|
19
16
|
if (!isOfDeployType(deployConfig, "google-cloudrun")) {
|
|
20
17
|
// should not happen
|
|
21
18
|
throw new Error("deploy config is wrong");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { DeployTypeDefinition } from "..";
|
|
1
|
+
import type { DeployConfigCloudRun, DeployTypeDefinition } from "..";
|
|
2
2
|
import {
|
|
3
|
-
BashExpression,
|
|
4
3
|
getBashVariable,
|
|
5
4
|
joinBashExpressions,
|
|
6
5
|
} from "../../bash/BashExpression";
|
|
6
|
+
import type { BuildConfig } from "../../build";
|
|
7
7
|
import { getSecretVarName } from "../../context";
|
|
8
8
|
import type { EnvironmentContext } from "../../types/environmentContext";
|
|
9
9
|
import { sanitizeForBashVariable } from "../../utils/gitlab";
|
|
@@ -27,7 +27,7 @@ const getCloudSqlVariables = ({
|
|
|
27
27
|
env,
|
|
28
28
|
componentName,
|
|
29
29
|
fullConfig,
|
|
30
|
-
}: EnvironmentContext<
|
|
30
|
+
}: EnvironmentContext<BuildConfig, DeployConfigCloudRun>) => {
|
|
31
31
|
if (deployConfigRaw && deployConfigRaw.cloudSql) {
|
|
32
32
|
const DB_NAME = getFullDbName(
|
|
33
33
|
deployConfigRaw.cloudSql,
|
|
@@ -56,71 +56,72 @@ const getCloudSqlVariables = ({
|
|
|
56
56
|
}
|
|
57
57
|
return {};
|
|
58
58
|
};
|
|
59
|
-
export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
additionalSecretKeys: (ctx) => [
|
|
72
|
-
{
|
|
73
|
-
key: GCLOUD_DEPLOY_CREDENTIALS_KEY,
|
|
74
|
-
hidden: true,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
key: GCLOUD_RUN_CANONICAL_HOST_SUFFIX,
|
|
78
|
-
hidden: true,
|
|
59
|
+
export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<DeployConfigCloudRun> =
|
|
60
|
+
{
|
|
61
|
+
jobs: createGoogleCloudRunDeployJobs,
|
|
62
|
+
defaults: ({ deployConfigRaw, envType }) => {
|
|
63
|
+
if (deployConfigRaw && deployConfigRaw.cloudSql) {
|
|
64
|
+
return {
|
|
65
|
+
cloudSql: {
|
|
66
|
+
deleteDatabaseOnStop: envType === "review",
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {};
|
|
79
71
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
additionalSecretKeys: (ctx) => [
|
|
73
|
+
{
|
|
74
|
+
key: GCLOUD_DEPLOY_CREDENTIALS_KEY,
|
|
75
|
+
hidden: true,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: GCLOUD_RUN_CANONICAL_HOST_SUFFIX,
|
|
79
|
+
hidden: true,
|
|
80
|
+
},
|
|
81
|
+
...(ctx.deployConfigRaw && ctx.deployConfigRaw.cloudSql
|
|
82
|
+
? [{ key: "DB_PASSWORD" }]
|
|
83
|
+
: []),
|
|
84
|
+
],
|
|
85
|
+
getAdditionalEnvVars: (ctx) => {
|
|
86
|
+
const { fullName, env, componentName, deployConfigRaw } = ctx;
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
const HOST_INTERNAL = joinBashExpressions(
|
|
89
|
+
[
|
|
90
|
+
fullName,
|
|
91
|
+
getBashVariable(
|
|
92
|
+
getSecretVarName(
|
|
93
|
+
env,
|
|
94
|
+
componentName,
|
|
95
|
+
GCLOUD_RUN_CANONICAL_HOST_SUFFIX,
|
|
96
|
+
),
|
|
95
97
|
),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
: {};
|
|
98
|
+
],
|
|
99
|
+
"-",
|
|
100
|
+
).toLowerCase();
|
|
101
|
+
const jobTriggers =
|
|
102
|
+
deployConfigRaw && deployConfigRaw.jobs
|
|
103
|
+
? Object.fromEntries(
|
|
104
|
+
Object.entries(deployConfigRaw.jobs).map(([name, job]) => [
|
|
105
|
+
"CLOUD_RUN_JOB_TRIGGER_URL_" + sanitizeForBashVariable(name),
|
|
106
|
+
`https://${
|
|
107
|
+
deployConfigRaw.region
|
|
108
|
+
}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${
|
|
109
|
+
deployConfigRaw.projectId
|
|
110
|
+
}/jobs/${getCloudRunJobName(fullName, name)}:run`,
|
|
111
|
+
]),
|
|
112
|
+
)
|
|
113
|
+
: {};
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
115
|
+
return {
|
|
116
|
+
HOST_INTERNAL,
|
|
117
|
+
...getCloudSqlVariables(ctx),
|
|
118
|
+
...jobTriggers,
|
|
119
|
+
DEPLOY_CLOUD_RUN_PROJECT_ID: deployConfigRaw
|
|
120
|
+
? deployConfigRaw.projectId
|
|
121
|
+
: undefined,
|
|
122
|
+
DEPLOY_CLOUD_RUN_REGION: deployConfigRaw
|
|
123
|
+
? deployConfigRaw.region
|
|
124
|
+
: undefined,
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAllCacheConfigsFromConfig } from "../../build/cache/getAllCacheConfigsFromConfig";
|
|
1
2
|
import { getYarnInstall } from "../../build/node/yarn";
|
|
2
3
|
import { getRunnerImage } from "../../runner";
|
|
3
4
|
import type { ComponentContext } from "../../types/context";
|
|
@@ -12,24 +13,23 @@ import { isOfDeployType } from "../types";
|
|
|
12
13
|
export const createCustomDeployJobs = (
|
|
13
14
|
context: ComponentContext,
|
|
14
15
|
): CatladderJob[] => {
|
|
15
|
-
const deployConfig = context.
|
|
16
|
-
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
16
|
+
const deployConfig = context.deploy?.config;
|
|
17
|
+
|
|
19
18
|
if (!isOfDeployType(deployConfig, "custom")) {
|
|
20
19
|
// should not happen
|
|
21
20
|
throw new Error("deploy config is not custom");
|
|
22
21
|
}
|
|
23
22
|
// FIXME: custom deploy currently assumes yarn-based project
|
|
24
|
-
const yarnInstall = getYarnInstall(context
|
|
23
|
+
const yarnInstall = getYarnInstall(context, {
|
|
25
24
|
noCustomPostInstall: true,
|
|
26
25
|
});
|
|
27
|
-
|
|
26
|
+
|
|
27
|
+
const result = createDeployementJobs(context, {
|
|
28
28
|
deploy: {
|
|
29
29
|
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
|
|
30
|
-
cache: deployConfig
|
|
30
|
+
cache: getAllCacheConfigsFromConfig(context, deployConfig),
|
|
31
31
|
script: [
|
|
32
|
-
`cd ${context.
|
|
32
|
+
`cd ${context.build.dir}`,
|
|
33
33
|
...(deployConfig.requiresYarnInstall ? yarnInstall : []),
|
|
34
34
|
...deployConfig.script,
|
|
35
35
|
...getDependencyTrackUploadScript(context),
|
|
@@ -47,4 +47,5 @@ export const createCustomDeployJobs = (
|
|
|
47
47
|
}
|
|
48
48
|
: undefined,
|
|
49
49
|
});
|
|
50
|
+
return result;
|
|
50
51
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { DeployTypeDefinition } from "..";
|
|
1
|
+
import type { DeployConfigCustom, DeployTypeDefinition } from "..";
|
|
2
2
|
import { createCustomDeployJobs } from "./deployJob";
|
|
3
3
|
|
|
4
|
-
export const CUSTOM_DEPLOY_TYPE: DeployTypeDefinition<
|
|
4
|
+
export const CUSTOM_DEPLOY_TYPE: DeployTypeDefinition<DeployConfigCustom> = {
|
|
5
5
|
jobs: createCustomDeployJobs,
|
|
6
6
|
defaults: () => ({}),
|
|
7
7
|
additionalSecretKeys: () => [],
|
|
@@ -8,10 +8,7 @@ import { isOfDeployType } from "../types";
|
|
|
8
8
|
export const createDockerTagDeployJobs = (
|
|
9
9
|
context: ComponentContext,
|
|
10
10
|
): CatladderJob[] => {
|
|
11
|
-
const deployConfig = context.
|
|
12
|
-
if (deployConfig === false) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
11
|
+
const deployConfig = context.deploy?.config;
|
|
15
12
|
if (!isOfDeployType(deployConfig, "dockerTag")) {
|
|
16
13
|
// should not happen
|
|
17
14
|
throw new Error("deploy config is not dockerTag");
|
|
@@ -19,7 +16,7 @@ export const createDockerTagDeployJobs = (
|
|
|
19
16
|
const tag = deployConfig.tag;
|
|
20
17
|
return createDeployementJobs(context, {
|
|
21
18
|
deploy: {
|
|
22
|
-
...getDockerJobBaseProps(
|
|
19
|
+
...getDockerJobBaseProps(),
|
|
23
20
|
script: [
|
|
24
21
|
...gitlabDockerLogin(context),
|
|
25
22
|
`docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG`,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { DeployTypeDefinition } from "..";
|
|
1
|
+
import type { DeployConfigDockerTag, DeployTypeDefinition } from "..";
|
|
2
2
|
import { createDockerTagDeployJobs } from "./deployJob";
|
|
3
3
|
|
|
4
|
-
export const DOCKER_TAG_DEPLOY_TYPE: DeployTypeDefinition<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
4
|
+
export const DOCKER_TAG_DEPLOY_TYPE: DeployTypeDefinition<DeployConfigDockerTag> =
|
|
5
|
+
{
|
|
6
|
+
jobs: createDockerTagDeployJobs,
|
|
7
|
+
defaults: () => ({}),
|
|
8
|
+
additionalSecretKeys: () => [],
|
|
9
|
+
getAdditionalEnvVars: () => ({}),
|
|
10
|
+
};
|
package/src/deploy/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SecretEnvVar } from "..";
|
|
1
|
+
import type { BuildConfig, SecretEnvVar } from "..";
|
|
2
2
|
import type { BashExpression } from "../bash/BashExpression";
|
|
3
3
|
import type { ComponentContext } from "../types/context";
|
|
4
4
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
@@ -8,26 +8,28 @@ import { GCLOUD_RUN_DEPLOY_TYPE } from "./cloudRun";
|
|
|
8
8
|
import { CUSTOM_DEPLOY_TYPE } from "./custom";
|
|
9
9
|
import { DOCKER_TAG_DEPLOY_TYPE } from "./dockerTag";
|
|
10
10
|
import { KUBERNETES_DEPLOY_TYPE } from "./kubernetes";
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
DeployConfig,
|
|
13
|
+
DeployConfigGeneric,
|
|
14
|
+
DeployConfigType,
|
|
15
|
+
} from "./types";
|
|
12
16
|
export * from "./cloudRun";
|
|
13
17
|
export * from "./kubernetes";
|
|
14
18
|
export * from "./types";
|
|
15
19
|
export * from "./utils";
|
|
16
20
|
|
|
17
|
-
export type DeployTypeDefinition<
|
|
21
|
+
export type DeployTypeDefinition<D extends DeployConfig> = {
|
|
18
22
|
jobs: (context: ComponentContext) => CatladderJob[];
|
|
19
|
-
defaults: (
|
|
20
|
-
envContext: EnvironmentContext<any, T>,
|
|
21
|
-
) => PartialDeep<DeployConfigGeneric<T>>;
|
|
23
|
+
defaults: (envContext: EnvironmentContext<BuildConfig, D>) => PartialDeep<D>;
|
|
22
24
|
additionalSecretKeys: (
|
|
23
|
-
envContext: EnvironmentContext<
|
|
25
|
+
envContext: EnvironmentContext<BuildConfig, D>,
|
|
24
26
|
) => SecretEnvVar[];
|
|
25
27
|
getAdditionalEnvVars: (
|
|
26
|
-
envContext: EnvironmentContext<
|
|
28
|
+
envContext: EnvironmentContext<BuildConfig, D>,
|
|
27
29
|
) => Record<string, string | BashExpression | undefined | null>;
|
|
28
30
|
};
|
|
29
31
|
export type DeployTypes = {
|
|
30
|
-
[T in DeployConfigType]: DeployTypeDefinition<T
|
|
32
|
+
[T in DeployConfigType]: DeployTypeDefinition<DeployConfigGeneric<T>>;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
export const DEPLOY_TYPES: DeployTypes = {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { BuildConfig } from "../../build";
|
|
1
2
|
import type { EnvironmentContext } from "../../types/environmentContext";
|
|
3
|
+
import type { DeployConfigKubernetes } from "../types";
|
|
2
4
|
|
|
3
5
|
export const additionalKubernetesSecretKeys = ({
|
|
4
6
|
deployConfigRaw,
|
|
5
|
-
}: EnvironmentContext<
|
|
7
|
+
}: EnvironmentContext<BuildConfig, DeployConfigKubernetes>) => {
|
|
6
8
|
if (!deployConfigRaw) {
|
|
7
9
|
return [];
|
|
8
10
|
}
|
|
@@ -5,8 +5,10 @@ import { getFullDbName } from "../../cloudSql/utils";
|
|
|
5
5
|
import { isOfDeployType } from "../../types";
|
|
6
6
|
|
|
7
7
|
export const hasKubernetesCloudSQL = (context: ComponentContext) => {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const deployConfig = context.deploy?.config;
|
|
9
|
+
|
|
10
|
+
if (isOfDeployType(deployConfig, "kubernetes")) {
|
|
11
|
+
return deployConfig.values?.cloudsql?.enabled;
|
|
10
12
|
}
|
|
11
13
|
return false;
|
|
12
14
|
};
|
|
@@ -24,11 +26,12 @@ export const createKubernetesCloudsqlBaseValues = (
|
|
|
24
26
|
): {
|
|
25
27
|
cloudsql: CloudSqlValues;
|
|
26
28
|
} => {
|
|
27
|
-
|
|
29
|
+
const deployConfig = context.deploy?.config;
|
|
30
|
+
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
28
31
|
throw new Error("cannot get cloud sql config");
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
const config =
|
|
34
|
+
const config = deployConfig.values?.cloudsql;
|
|
32
35
|
|
|
33
36
|
if (!config) {
|
|
34
37
|
throw new Error("cannot get cloud sql config");
|
|
@@ -63,7 +66,7 @@ export const createKubernetesCloudsqlBaseValues = (
|
|
|
63
66
|
config,
|
|
64
67
|
context.fullConfig,
|
|
65
68
|
context.environment.slugPrefix,
|
|
66
|
-
context.
|
|
69
|
+
context.name,
|
|
67
70
|
),
|
|
68
71
|
},
|
|
69
72
|
};
|
|
@@ -17,10 +17,7 @@ const ALL_VALUES_FILE = "__all_values.yml";
|
|
|
17
17
|
export const createKubernetesDeployJobs = (
|
|
18
18
|
context: ComponentContext,
|
|
19
19
|
): CatladderJob[] => {
|
|
20
|
-
const deployConfig = context.
|
|
21
|
-
if (deployConfig === false) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
20
|
+
const deployConfig = context.deploy?.config;
|
|
24
21
|
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
25
22
|
// should not happen
|
|
26
23
|
throw new Error("deploy config is not kubernetes");
|
|
@@ -42,14 +39,14 @@ export const createKubernetesDeployJobs = (
|
|
|
42
39
|
...context.environment.envVars,
|
|
43
40
|
RELEASE_NAME: context.environment.fullName,
|
|
44
41
|
HELM_EXPERIMENTAL_OCI: "1",
|
|
45
|
-
KUBE_DOCKER_IMAGE_PULL_SECRET: `gitlab-registry-${context.
|
|
42
|
+
KUBE_DOCKER_IMAGE_PULL_SECRET: `gitlab-registry-${context.name}`,
|
|
46
43
|
HELM_GITLAB_CHART_NAME:
|
|
47
44
|
deployConfig.chartName ?? "/helm-charts/the-panter-chart",
|
|
48
45
|
HELM_ARGS: [
|
|
49
46
|
...(deployConfig.debug ? ["--debug"] : []),
|
|
50
47
|
...(deployConfig.additionalHelmArgs ?? []),
|
|
51
48
|
].join(" "),
|
|
52
|
-
COMPONENT_NAME: context.
|
|
49
|
+
COMPONENT_NAME: context.name,
|
|
53
50
|
/** @deprecated */
|
|
54
51
|
BUILD_ID: context.environment.envVars.BUILD_INFO_BUILD_ID,
|
|
55
52
|
},
|