@catladder/pipeline 1.144.1 → 1.145.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bash/BashExpression.d.ts +40 -0
- package/dist/bash/BashExpression.js +124 -0
- package/dist/bash/bashExpressionPerPipelineType.d.ts +6 -0
- package/dist/bash/bashExpressionPerPipelineType.js +11 -0
- package/dist/bash/bashYaml.d.ts +10 -0
- package/dist/bash/bashYaml.js +46 -0
- package/dist/bash/getInjectVarsScript.d.ts +2 -0
- package/dist/bash/getInjectVarsScript.js +45 -0
- package/dist/bash/replaceAsync.d.ts +2 -0
- package/dist/{pipeline/commitInfo/getCommitInfo.js → bash/replaceAsync.js} +49 -21
- package/dist/build/base/__tests__/createArtifactsConfig.test.js +3 -1
- package/dist/build/base/constants.js +3 -1
- package/dist/build/base/createAppBuildJob.d.ts +2 -1
- package/dist/build/base/createAppBuildJob.js +10 -6
- package/dist/build/base/createArtifactsConfig.d.ts +1 -1
- package/dist/build/base/createArtifactsConfig.js +3 -1
- package/dist/build/base/index.js +3 -1
- package/dist/build/base/writeBuildInfo.js +4 -3
- package/dist/build/base/writeDotEnv.js +12 -3
- package/dist/build/custom/__tests__/testJob.test.js +3 -1
- package/dist/build/custom/buildJob.js +4 -12
- package/dist/build/custom/index.js +3 -1
- package/dist/build/custom/testJob.d.ts +1 -1
- package/dist/build/custom/testJob.js +18 -14
- package/dist/build/docker.d.ts +5 -31
- package/dist/build/docker.js +16 -9
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +13 -7
- package/dist/build/node/buildJob.js +4 -12
- package/dist/build/node/cache.js +6 -3
- package/dist/build/node/constants.js +3 -1
- package/dist/build/node/index.js +3 -1
- package/dist/build/node/meteor.js +5 -2
- package/dist/build/node/testJob.js +18 -14
- package/dist/build/node/yarn.d.ts +3 -2
- package/dist/build/node/yarn.js +6 -3
- package/dist/build/rails/build.js +3 -1
- package/dist/build/rails/index.js +3 -1
- package/dist/build/rails/test.js +15 -11
- package/dist/build/sbom.js +3 -1
- package/dist/build/types.d.ts +24 -18
- package/dist/build/types.js +3 -1
- package/dist/bundles/catladder-gitlab/index.js +3 -3
- package/dist/catladder-gitlab.js +10 -54
- package/dist/config/__tests__/configruedEnvs.test.js +3 -1
- package/dist/config/configruedEnvs.js +3 -1
- package/dist/config/index.js +13 -7
- package/dist/config/readConfig.js +6 -5
- package/dist/constants.js +5 -3
- package/dist/context/__tests__/resolveReferences.test.js +40 -8
- package/dist/context/getBuildInfoVariables.d.ts +7 -0
- package/dist/context/getBuildInfoVariables.js +29 -0
- package/dist/context/getEnvConfig.js +3 -1
- package/dist/context/getEnvType.js +3 -1
- package/dist/context/getEnvironment.d.ts +3 -3
- package/dist/context/getEnvironment.js +10 -14
- package/dist/context/getEnvironmentContext.d.ts +7 -3
- package/dist/context/getEnvironmentContext.js +21 -11
- package/dist/context/getEnvironmentVariables.d.ts +26 -5
- package/dist/context/getEnvironmentVariables.js +41 -25
- package/dist/context/getLabels.js +4 -2
- package/dist/context/getReviewSlug.d.ts +4 -0
- package/dist/context/getReviewSlug.js +22 -0
- package/dist/context/index.d.ts +12 -3
- package/dist/context/index.js +21 -15
- package/dist/context/resolveReferences.d.ts +3 -1
- package/dist/context/resolveReferences.js +53 -21
- package/dist/context/transformJobOnlyVars.d.ts +5 -2
- package/dist/context/transformJobOnlyVars.js +4 -2
- package/dist/context/utils/envVars.d.ts +1 -1
- package/dist/context/utils/envVars.js +5 -2
- package/dist/defaults/index.js +3 -1
- package/dist/deploy/base/deploy.d.ts +1 -1
- package/dist/deploy/base/deploy.js +12 -11
- package/dist/deploy/base/index.js +3 -1
- package/dist/deploy/base/rollback.d.ts +1 -1
- package/dist/deploy/base/rollback.js +13 -9
- package/dist/deploy/base/stop.d.ts +1 -1
- package/dist/deploy/base/stop.js +16 -11
- package/dist/deploy/base/types.d.ts +1 -1
- package/dist/deploy/base/types.js +3 -1
- package/dist/deploy/base/variables.js +3 -1
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +2 -1
- package/dist/deploy/cloudRun/artifactsRegistry.js +6 -4
- package/dist/deploy/cloudRun/cleanup.js +3 -1
- package/dist/deploy/cloudRun/cloudRunRevisions.js +3 -1
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +8 -5
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +2 -2
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +6 -3
- package/dist/deploy/cloudRun/createJobs/common.d.ts +3 -3
- package/dist/deploy/cloudRun/createJobs/common.js +3 -1
- package/dist/deploy/cloudRun/createJobs/constants.d.ts +1 -0
- package/dist/deploy/cloudRun/createJobs/constants.js +7 -0
- package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +9 -2
- package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +3 -1
- package/dist/deploy/cloudRun/createJobs/index.js +25 -8
- package/dist/deploy/cloudRun/createJobs/volumes.js +3 -1
- package/dist/deploy/cloudRun/index.js +5 -3
- package/dist/deploy/cloudRun/utils/createArgsString.d.ts +2 -1
- package/dist/deploy/cloudRun/utils/createArgsString.js +3 -1
- package/dist/deploy/cloudRun/utils/database.js +13 -13
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +3 -1
- package/dist/deploy/cloudRun/utils/getServiceName.d.ts +1 -1
- package/dist/deploy/cloudRun/utils/getServiceName.js +3 -1
- package/dist/deploy/cloudRun/utils/jobName.d.ts +2 -1
- package/dist/deploy/cloudRun/utils/jobName.js +4 -2
- package/dist/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.js +3 -1
- package/dist/deploy/cloudSql/utils.d.ts +2 -1
- package/dist/deploy/cloudSql/utils.js +7 -2
- package/dist/deploy/custom/deployJob.js +3 -1
- package/dist/deploy/custom/index.js +3 -1
- package/dist/deploy/dockerTag/deployJob.js +3 -1
- package/dist/deploy/dockerTag/index.js +3 -1
- package/dist/deploy/index.d.ts +4 -3
- package/dist/deploy/index.js +13 -7
- package/dist/deploy/kubernetes/additionalSecretKeys.js +3 -1
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -2
- package/dist/deploy/kubernetes/cloudSql/index.js +6 -4
- package/dist/deploy/kubernetes/deployJob.js +22 -15
- package/dist/deploy/kubernetes/index.js +51 -14
- package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -2
- package/dist/deploy/kubernetes/kubeEnv.js +7 -4
- package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeValues.js +3 -2
- package/dist/deploy/kubernetes/mongodb.js +3 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +2 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +3 -1
- package/dist/deploy/sbom.js +3 -1
- package/dist/deploy/types/base.d.ts +8 -2
- package/dist/deploy/types/base.js +3 -1
- package/dist/deploy/types/custom.d.ts +1 -1
- package/dist/deploy/types/custom.js +3 -1
- package/dist/deploy/types/dockerTag.d.ts +1 -1
- package/dist/deploy/types/dockerTag.js +3 -1
- package/dist/deploy/types/googleCloudRun.d.ts +19 -18
- package/dist/deploy/types/googleCloudRun.js +3 -1
- package/dist/deploy/types/index.d.ts +6 -6
- package/dist/deploy/types/index.js +13 -7
- package/dist/deploy/types/kubernetes.d.ts +22 -22
- package/dist/deploy/types/kubernetes.js +3 -1
- package/dist/deploy/utils.js +3 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +16 -9
- package/dist/packageInfos.d.ts +2 -0
- package/dist/packageInfos.js +14 -0
- package/dist/pipeline/createAllJobs.d.ts +13 -5
- package/dist/pipeline/createAllJobs.js +21 -10
- package/dist/pipeline/createChildPipeline.d.ts +1 -1
- package/dist/pipeline/createChildPipeline.js +24 -7
- package/dist/pipeline/createJobsForComponent.d.ts +3 -3
- package/dist/pipeline/createJobsForComponent.js +19 -18
- package/dist/pipeline/createMainPipeline.d.ts +3 -0
- package/dist/pipeline/createMainPipeline.js +248 -0
- package/dist/pipeline/generatePipelineFiles.d.ts +2 -0
- package/dist/pipeline/generatePipelineFiles.js +178 -0
- package/dist/pipeline/getPipelineStages.js +3 -1
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +15 -5
- package/dist/pipeline/gitlab/createGitlabJobs.js +98 -25
- package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +7 -2
- package/dist/pipeline/gitlab/createGitlabPipeline.js +34 -17
- package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.d.ts +1 -0
- package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.js +29 -0
- package/dist/pipeline/gitlab/gitlabReleaseJobs.d.ts +33 -0
- package/dist/pipeline/gitlab/gitlabReleaseJobs.js +24 -0
- package/dist/pipeline/index.d.ts +3 -1
- package/dist/pipeline/index.js +16 -8
- package/dist/pipeline/packageManager.js +4 -2
- package/dist/pipeline/yarn/yarnUtils.js +6 -4
- package/dist/rules/index.d.ts +4 -1
- package/dist/rules/index.js +25 -18
- package/dist/runner/index.d.ts +1 -1
- package/dist/runner/index.js +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +18 -15
- package/dist/types/config.js +5 -2
- package/dist/types/context.d.ts +37 -32
- package/dist/types/context.js +3 -1
- package/dist/types/environmentContext.d.ts +11 -7
- package/dist/types/environmentContext.js +3 -1
- package/dist/types/gitlab-ci-yml.d.ts +30 -30
- package/dist/types/gitlab-ci-yml.js +3 -2
- package/dist/types/gitlab-types.d.ts +4 -6
- package/dist/types/gitlab-types.js +3 -1
- package/dist/types/index.js +13 -7
- package/dist/types/jobs.d.ts +23 -6
- package/dist/types/jobs.js +3 -1
- package/dist/types/pipeline.d.ts +4 -3
- package/dist/types/pipeline.js +3 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/utils.js +3 -1
- package/dist/utils/gitlab.js +3 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/writeFiles.d.ts +7 -0
- package/dist/{pipeline/commitInfo/getBuildId.js → utils/writeFiles.js} +39 -22
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +462 -366
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-no-service.ts.snap +501 -393
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +489 -392
- package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +480 -384
- package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +501 -401
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +1155 -915
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +1116 -888
- package/examples/__snapshots__/cloud-run-with-worker.ts.snap +482 -386
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +452 -356
- package/examples/__snapshots__/custom-build-job.ts.snap +434 -350
- package/examples/__snapshots__/custom-deploy.ts.snap +319 -223
- package/examples/__snapshots__/custom-envs.ts.snap +123 -81
- package/examples/__snapshots__/custom-sbom-java.ts.snap +434 -350
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +846 -969
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +886 -957
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +894 -969
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +1626 -1728
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +974 -1137
- package/examples/__snapshots__/local-dot-env.ts.snap +480 -384
- package/examples/__snapshots__/meteor-kubernetes.ts.snap +906 -1069
- package/examples/__snapshots__/multiline-var.ts.snap +4500 -0
- package/examples/__snapshots__/native-app.ts.snap +706 -578
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +480 -384
- package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +488 -384
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1656 -1942
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +287 -231
- package/examples/custom-deploy.ts +7 -7
- package/examples/multiline-var.ts +64 -0
- package/package.json +5 -8
- package/src/bash/BashExpression.ts +81 -0
- package/src/bash/bashExpressionPerPipelineType.ts +16 -0
- package/src/bash/bashYaml.ts +46 -0
- package/src/bash/getInjectVarsScript.ts +12 -0
- package/src/bash/replaceAsync.ts +50 -0
- package/src/build/base/createAppBuildJob.ts +6 -2
- package/src/build/base/writeBuildInfo.ts +1 -1
- package/src/build/base/writeDotEnv.ts +6 -1
- package/src/build/custom/buildJob.ts +2 -4
- package/src/build/custom/testJob.ts +3 -2
- package/src/build/docker.ts +15 -7
- package/src/build/node/buildJob.ts +1 -3
- package/src/build/node/testJob.ts +3 -2
- package/src/build/node/yarn.ts +9 -4
- package/src/build/rails/test.ts +2 -1
- package/src/build/types.ts +8 -1
- package/src/catladder-gitlab.ts +8 -55
- package/src/config/readConfig.ts +2 -3
- package/src/constants.ts +5 -2
- package/src/context/__tests__/resolveReferences.test.ts +11 -6
- package/src/context/getBuildInfoVariables.ts +40 -0
- package/src/context/getEnvironment.ts +7 -30
- package/src/context/getEnvironmentContext.ts +25 -29
- package/src/context/getEnvironmentVariables.ts +61 -36
- package/src/context/getReviewSlug.ts +27 -0
- package/src/context/index.ts +24 -23
- package/src/context/resolveReferences.ts +28 -8
- package/src/context/transformJobOnlyVars.ts +5 -2
- package/src/context/utils/envVars.ts +2 -1
- package/src/deploy/base/deploy.ts +20 -18
- package/src/deploy/base/rollback.ts +8 -10
- package/src/deploy/base/stop.ts +8 -9
- package/src/deploy/cloudRun/artifactsRegistry.ts +9 -4
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +12 -7
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +3 -2
- package/src/deploy/cloudRun/createJobs/constants.ts +1 -0
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +20 -2
- package/src/deploy/cloudRun/createJobs/index.ts +17 -8
- package/src/deploy/cloudRun/index.ts +14 -6
- package/src/deploy/cloudRun/utils/createArgsString.ts +2 -1
- package/src/deploy/cloudRun/utils/database.ts +2 -2
- package/src/deploy/cloudRun/utils/jobName.ts +7 -2
- package/src/deploy/cloudSql/utils.ts +12 -9
- package/src/deploy/index.ts +2 -1
- package/src/deploy/kubernetes/cloudSql/index.ts +3 -2
- package/src/deploy/kubernetes/deployJob.ts +24 -10
- package/src/deploy/kubernetes/index.ts +15 -8
- package/src/deploy/kubernetes/kubeEnv.ts +8 -6
- package/src/deploy/kubernetes/kubeValues.ts +0 -1
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +2 -1
- package/src/deploy/types/base.ts +6 -0
- package/src/deploy/types/googleCloudRun.ts +2 -0
- package/src/index.ts +2 -1
- package/src/packageInfos.ts +10 -0
- package/src/pipeline/createAllJobs.ts +24 -10
- package/src/pipeline/createChildPipeline.ts +19 -8
- package/src/pipeline/createJobsForComponent.ts +14 -22
- package/src/pipeline/createMainPipeline.ts +88 -0
- package/src/pipeline/generatePipelineFiles.ts +29 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +174 -51
- package/src/pipeline/gitlab/createGitlabPipeline.ts +16 -14
- package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +46 -0
- package/src/pipeline/gitlab/gitlabReleaseJobs.ts +20 -0
- package/src/pipeline/index.ts +2 -0
- package/src/rules/index.ts +15 -9
- package/src/types/config.ts +11 -2
- package/src/types/context.ts +39 -26
- package/src/types/environmentContext.ts +12 -6
- package/src/types/gitlab-ci-yml.ts +0 -1
- package/src/types/gitlab-types.ts +5 -4
- package/src/types/jobs.ts +28 -3
- package/src/types/pipeline.ts +4 -0
- package/src/utils/writeFiles.ts +40 -0
- package/dist/deploy/cloudRun/createJobs/variables.d.ts +0 -5
- package/dist/deploy/cloudRun/createJobs/variables.js +0 -19
- package/dist/pipeline/commitInfo/getBuildId.d.ts +0 -6
- package/dist/pipeline/commitInfo/getCommitInfo.d.ts +0 -2
- package/src/deploy/cloudRun/createJobs/variables.ts +0 -21
- package/src/pipeline/commitInfo/getBuildId.ts +0 -17
- package/src/pipeline/commitInfo/getCommitInfo.ts +0 -15
package/dist/catladder-gitlab.js
CHANGED
|
@@ -1,58 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __assign = this && this.__assign || function () {
|
|
4
|
-
__assign = Object.assign || function (t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = this && this.__rest || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
3
|
var _a;
|
|
22
|
-
exports
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
25
7
|
var config_1 = require("./config");
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var isDefaultBranch = Boolean(CI_DEFAULT_BRANCH) && CI_COMMIT_BRANCH === CI_DEFAULT_BRANCH;
|
|
34
|
-
var isHotfixBranch = CI_COMMIT_BRANCH ? /^[0-9]+\.([0-9]+|x)\.x$/.test(CI_COMMIT_BRANCH) : false;
|
|
35
|
-
var isMergeRequest = Boolean(CI_MERGE_REQUEST_ID);
|
|
36
|
-
var isTaggedRelease = Boolean(CI_COMMIT_TAG);
|
|
37
|
-
console.info("catladder version ".concat(constants_1.PIPELINE_IMAGE_TAG));
|
|
38
|
-
var trigger = isMergeRequest || isHotfixBranch ? "mr" : isDefaultBranch ? "mainBranch" : isTaggedRelease ? "taggedRelease" : null;
|
|
39
|
-
if (trigger) {
|
|
40
|
-
var config = (_a = (0, config_1.readConfigSync)()) === null || _a === void 0 ? void 0 : _a.config;
|
|
41
|
-
if (!config) {
|
|
42
|
-
throw new Error("no catladder config found");
|
|
43
|
-
}
|
|
44
|
-
(0, pipeline_1.createChildPipeline)("gitlab", trigger, config).then(function (_a) {
|
|
45
|
-
var jobs = _a.jobs,
|
|
46
|
-
mainPipeline = __rest(_a, ["jobs"]);
|
|
47
|
-
// need to spread out the jobs
|
|
48
|
-
(0, fs_1.writeFileSync)("__pipeline.yml", (0, js_yaml_1.dump)(__assign(__assign({}, jobs), mainPipeline)), {
|
|
49
|
-
encoding: "utf-8"
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
} else {
|
|
53
|
-
throw new Error("no matching trigger: " + JSON.stringify({
|
|
54
|
-
isMergeRequest: isMergeRequest,
|
|
55
|
-
isDefaultBranch: isDefaultBranch,
|
|
56
|
-
isTaggedRelease: isTaggedRelease
|
|
57
|
-
}, null, 2));
|
|
58
|
-
}
|
|
8
|
+
var generatePipelineFiles_1 = require("./pipeline/generatePipelineFiles");
|
|
9
|
+
var mode = process.argv[2] || "local";
|
|
10
|
+
var config = (_a = (0, config_1.readConfigSync)()) === null || _a === void 0 ? void 0 : _a.config;
|
|
11
|
+
if (!config) {
|
|
12
|
+
throw new Error("no catladder config found");
|
|
13
|
+
}
|
|
14
|
+
(0, generatePipelineFiles_1.generatePipelineFiles)(config, "gitlab", mode);
|
|
@@ -31,7 +31,9 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
31
31
|
}
|
|
32
32
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
33
|
};
|
|
34
|
-
exports
|
|
34
|
+
Object.defineProperty(exports, "__esModule", {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
35
37
|
exports.getAllEnvsByTrigger = exports.getAllEnvsInAllComponents = exports.getAllEnvs = void 0;
|
|
36
38
|
var types_1 = require("../types");
|
|
37
39
|
var getConfiguredAndDefaultEnvs = function (config, componentName, envTypes) {
|
package/dist/config/index.js
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
11
15
|
} : function (o, m, k, k2) {
|
|
12
16
|
if (k2 === undefined) k2 = k;
|
|
13
17
|
o[k2] = m[k];
|
|
@@ -15,6 +19,8 @@ var __createBinding = this && this.__createBinding || (Object.create ? function
|
|
|
15
19
|
var __exportStar = this && this.__exportStar || function (m, exports) {
|
|
16
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
21
|
};
|
|
18
|
-
exports
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
19
25
|
__exportStar(require("./configruedEnvs"), exports);
|
|
20
26
|
__exportStar(require("./readConfig"), exports);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.readConfigSync = void 0;
|
|
5
7
|
var fs_1 = require("fs");
|
|
6
8
|
var ts_node_1 = require("ts-node");
|
|
7
|
-
var
|
|
9
|
+
var yaml_1 = require("yaml");
|
|
8
10
|
// allows us to load ts files
|
|
9
11
|
var fullPath = function (directory, ext) {
|
|
10
12
|
return directory + "/catladder." + ext;
|
|
@@ -33,14 +35,13 @@ var readConfigSync = function (directory) {
|
|
|
33
35
|
return {
|
|
34
36
|
path: filePath,
|
|
35
37
|
ext: found,
|
|
36
|
-
|
|
37
|
-
config: requireUncached(filePath)["default"]
|
|
38
|
+
config: requireUncached(filePath).default
|
|
38
39
|
};
|
|
39
40
|
} else {
|
|
40
41
|
return {
|
|
41
42
|
path: filePath,
|
|
42
43
|
ext: found,
|
|
43
|
-
config: (0,
|
|
44
|
+
config: (0, yaml_1.parse)((0, fs_1.readFileSync)(filePath, {
|
|
44
45
|
encoding: "utf-8"
|
|
45
46
|
}))
|
|
46
47
|
};
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
5
|
-
exports.PIPELINE_IMAGE_TAG = "v1-
|
|
6
|
-
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
|
7
|
+
exports.PIPELINE_IMAGE_TAG = "v1-145-0-3e39d121" || "latest";
|
|
8
|
+
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
|
|
@@ -55,7 +55,7 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
55
55
|
}
|
|
56
56
|
function step(op) {
|
|
57
57
|
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
-
while (_) try {
|
|
58
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
59
59
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
60
60
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
61
|
switch (op[0]) {
|
|
@@ -115,8 +115,40 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
|
|
118
|
+
var __read = this && this.__read || function (o, n) {
|
|
119
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
120
|
+
if (!m) return o;
|
|
121
|
+
var i = m.call(o),
|
|
122
|
+
r,
|
|
123
|
+
ar = [],
|
|
124
|
+
e;
|
|
125
|
+
try {
|
|
126
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
e = {
|
|
129
|
+
error: error
|
|
130
|
+
};
|
|
131
|
+
} finally {
|
|
132
|
+
try {
|
|
133
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
134
|
+
} finally {
|
|
135
|
+
if (e) throw e.error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return ar;
|
|
139
|
+
};
|
|
140
|
+
Object.defineProperty(exports, "__esModule", {
|
|
141
|
+
value: true
|
|
142
|
+
});
|
|
119
143
|
var resolveReferences_1 = require("../resolveReferences");
|
|
144
|
+
var unpackBashExpressions = function (obj) {
|
|
145
|
+
return Object.fromEntries(Object.entries(obj).map(function (_a) {
|
|
146
|
+
var _b = __read(_a, 2),
|
|
147
|
+
key = _b[0],
|
|
148
|
+
value = _b[1];
|
|
149
|
+
return [key, value.toString()];
|
|
150
|
+
}));
|
|
151
|
+
};
|
|
120
152
|
describe("resolveReferences", function () {
|
|
121
153
|
it("replaces occurences of ${componentName:VARIABLE_NAME}", function () {
|
|
122
154
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -145,7 +177,7 @@ describe("resolveReferences", function () {
|
|
|
145
177
|
})];
|
|
146
178
|
case 1:
|
|
147
179
|
result = _a.sent();
|
|
148
|
-
expect(result).toEqual({
|
|
180
|
+
expect(unpackBashExpressions(result)).toEqual({
|
|
149
181
|
a: "hello world",
|
|
150
182
|
b: "a replaced value looks like this: 'foo from api', nice!"
|
|
151
183
|
});
|
|
@@ -168,7 +200,7 @@ describe("resolveReferences", function () {
|
|
|
168
200
|
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables)];
|
|
169
201
|
case 1:
|
|
170
202
|
result = _a.sent();
|
|
171
|
-
expect(result).toEqual({
|
|
203
|
+
expect(unpackBashExpressions(result)).toEqual({
|
|
172
204
|
FOO: "hello world",
|
|
173
205
|
BAR: "this: hello world!"
|
|
174
206
|
});
|
|
@@ -202,7 +234,7 @@ describe("resolveReferences", function () {
|
|
|
202
234
|
})];
|
|
203
235
|
case 1:
|
|
204
236
|
result = _a.sent();
|
|
205
|
-
expect(result).toEqual({
|
|
237
|
+
expect(unpackBashExpressions(result)).toEqual({
|
|
206
238
|
FOO: "hello from foo from api",
|
|
207
239
|
BAR: "this: hello from foo from api!"
|
|
208
240
|
});
|
|
@@ -232,7 +264,7 @@ describe("resolveReferences", function () {
|
|
|
232
264
|
})];
|
|
233
265
|
case 1:
|
|
234
266
|
result = _a.sent();
|
|
235
|
-
expect(result).toEqual({
|
|
267
|
+
expect(unpackBashExpressions(result)).toEqual({
|
|
236
268
|
a: "hello world",
|
|
237
269
|
b: "a not found value looks like this: '${api:FOO}'"
|
|
238
270
|
});
|
|
@@ -268,7 +300,7 @@ describe("resolveReferences", function () {
|
|
|
268
300
|
})];
|
|
269
301
|
case 1:
|
|
270
302
|
result = _a.sent();
|
|
271
|
-
expect(result).toEqual({
|
|
303
|
+
expect(unpackBashExpressions(result)).toEqual({
|
|
272
304
|
a: "value is hi, foo from api!"
|
|
273
305
|
});
|
|
274
306
|
return [2 /*return*/];
|
|
@@ -303,7 +335,7 @@ describe("resolveReferences", function () {
|
|
|
303
335
|
})];
|
|
304
336
|
case 1:
|
|
305
337
|
result = _a.sent();
|
|
306
|
-
expect(result).toEqual({
|
|
338
|
+
expect(unpackBashExpressions(result)).toEqual({
|
|
307
339
|
a: "value is frontend api ${frontend:FOO}!"
|
|
308
340
|
});
|
|
309
341
|
return [2 /*return*/];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BashExpression } from "../bash/BashExpression";
|
|
2
|
+
import type { EnvironmentContext } from "../types/environmentContext";
|
|
3
|
+
export declare const getBuildInfoVariables: (ctx: EnvironmentContext<any, any>) => {
|
|
4
|
+
BUILD_INFO_BUILD_ID: string | BashExpression;
|
|
5
|
+
BUILD_INFO_BUILD_TIME: string | BashExpression;
|
|
6
|
+
BUILD_INFO_CURRENT_VERSION: string | BashExpression;
|
|
7
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBuildInfoVariables = void 0;
|
|
7
|
+
var BashExpression_1 = require("../bash/BashExpression");
|
|
8
|
+
var bashExpressionPerPipelineType_1 = require("../bash/bashExpressionPerPipelineType");
|
|
9
|
+
var BUILD_TIME = {
|
|
10
|
+
default: "unknown-build-time",
|
|
11
|
+
gitlab: new BashExpression_1.BashExpression("$CI_JOB_STARTED_AT")
|
|
12
|
+
};
|
|
13
|
+
var BUILD_ID = {
|
|
14
|
+
default: new BashExpression_1.BashExpression("$(git describe --tags 2>/dev/null || git rev-parse HEAD)")
|
|
15
|
+
};
|
|
16
|
+
var CURRENT_VERSION = {
|
|
17
|
+
default: new BashExpression_1.BashExpression(
|
|
18
|
+
// because we do shallow fetch, we need to ask the origin
|
|
19
|
+
"$(tag=$(git ls-remote origin \"refs/tags/v*[0-9]\" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\///'); [ -z \"$tag\" ] && echo \"v0.0.0\" || echo \"$tag\")")
|
|
20
|
+
};
|
|
21
|
+
var getBuildInfoVariables = function (ctx) {
|
|
22
|
+
var pipelineType = ctx.pipelineType;
|
|
23
|
+
return {
|
|
24
|
+
BUILD_INFO_BUILD_ID: (0, bashExpressionPerPipelineType_1.getBashExpressionPerPipelineType)(BUILD_ID, pipelineType),
|
|
25
|
+
BUILD_INFO_BUILD_TIME: (0, bashExpressionPerPipelineType_1.getBashExpressionPerPipelineType)(BUILD_TIME, pipelineType),
|
|
26
|
+
BUILD_INFO_CURRENT_VERSION: (0, bashExpressionPerPipelineType_1.getBashExpressionPerPipelineType)(CURRENT_VERSION, pipelineType)
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
exports.getBuildInfoVariables = getBuildInfoVariables;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export declare const getEnvironment: (
|
|
1
|
+
import type { CreateContextContext } from "..";
|
|
2
|
+
import type { Environment } from "../types/context";
|
|
3
|
+
export declare const getEnvironment: (ctx: CreateContextContext) => Promise<Environment>;
|
|
@@ -65,7 +65,7 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
65
65
|
}
|
|
66
66
|
function step(op) {
|
|
67
67
|
if (f) throw new TypeError("Generator is already executing.");
|
|
68
|
-
while (_) try {
|
|
68
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
69
69
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
70
70
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
71
71
|
switch (op[0]) {
|
|
@@ -125,33 +125,29 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
exports
|
|
128
|
+
Object.defineProperty(exports, "__esModule", {
|
|
129
|
+
value: true
|
|
130
|
+
});
|
|
129
131
|
exports.getEnvironment = void 0;
|
|
130
|
-
var deploy_1 = require("../deploy");
|
|
131
132
|
var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
132
133
|
var getEnvironmentVariables_1 = require("./getEnvironmentVariables");
|
|
133
|
-
var getEnvironment = function (
|
|
134
|
+
var getEnvironment = function (ctx) {
|
|
134
135
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
135
|
-
var variables, envContext, envType
|
|
136
|
+
var env, variables, envContext, envType;
|
|
136
137
|
return __generator(this, function (_a) {
|
|
137
138
|
switch (_a.label) {
|
|
138
139
|
case 0:
|
|
139
|
-
|
|
140
|
+
env = ctx.env;
|
|
141
|
+
return [4 /*yield*/, (0, getEnvironmentVariables_1.getEnvironmentVariables)(ctx)];
|
|
140
142
|
case 1:
|
|
141
143
|
variables = _a.sent();
|
|
142
|
-
envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(
|
|
144
|
+
envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(ctx);
|
|
143
145
|
envType = envContext.envType;
|
|
144
|
-
deployConfig = config.components[componentName].deploy;
|
|
145
|
-
gitlabEnvironment = __assign({
|
|
146
|
-
name: envContext.gitlabEnvironmentName
|
|
147
|
-
}, !(0, deploy_1.isOfDeployType)(deployConfig, "google-cloudrun") || deployConfig.service !== false ? {
|
|
148
|
-
url: variables.url
|
|
149
|
-
} : {});
|
|
150
146
|
return [2 /*return*/, __assign({
|
|
151
147
|
envType: envType,
|
|
152
|
-
gitlabEnvironment: gitlabEnvironment,
|
|
153
148
|
fullName: envContext.fullName,
|
|
154
149
|
slugPrefix: envContext.environmentSlugPrefix,
|
|
150
|
+
reviewSlug: envContext.reviewSlug,
|
|
155
151
|
slug: envContext.environmentSlug,
|
|
156
152
|
shortName: env
|
|
157
153
|
}, variables)];
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { CommitInfo } from "../types/context";
|
|
1
|
+
import type { CreateContextContext } from "..";
|
|
3
2
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
4
|
-
export declare const getEnvironmentContext: (
|
|
3
|
+
export declare const getEnvironmentContext: ({
|
|
4
|
+
env,
|
|
5
|
+
componentName,
|
|
6
|
+
config,
|
|
7
|
+
pipelineType
|
|
8
|
+
}: CreateContextContext) => EnvironmentContext<any, any>;
|
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.getEnvironmentContext = void 0;
|
|
7
|
+
var BashExpression_1 = require("../bash/BashExpression");
|
|
5
8
|
var getEnvConfig_1 = require("./getEnvConfig");
|
|
6
9
|
var getEnvType_1 = require("./getEnvType");
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
var getReviewSlug_1 = require("./getReviewSlug");
|
|
11
|
+
var getEnvironmentSlugPrefix = function (env, reviewSlug) {
|
|
12
|
+
if (reviewSlug) {
|
|
13
|
+
return (0, BashExpression_1.joinBashExpressions)([env, reviewSlug], "-");
|
|
14
|
+
}
|
|
15
|
+
return env;
|
|
10
16
|
};
|
|
11
|
-
var getEnvironmentContext = function (
|
|
17
|
+
var getEnvironmentContext = function (_a) {
|
|
18
|
+
var env = _a.env,
|
|
19
|
+
componentName = _a.componentName,
|
|
20
|
+
config = _a.config,
|
|
21
|
+
pipelineType = _a.pipelineType;
|
|
12
22
|
var envConfigRaw = (0, getEnvConfig_1.getEnvConfig)(config, componentName, env);
|
|
13
23
|
var envType = (0, getEnvType_1.getEnvType)(env, envConfigRaw);
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var fullName =
|
|
24
|
+
var reviewSlug = (0, getReviewSlug_1.getReviewSlug)(envConfigRaw, env, pipelineType);
|
|
25
|
+
var environmentSlugPrefix = getEnvironmentSlugPrefix(env, reviewSlug);
|
|
26
|
+
var environmentSlug = environmentSlugPrefix.concat("-".concat(componentName));
|
|
27
|
+
var fullName = (0, BashExpression_1.joinBashExpressions)([config.customerName, config.appName, environmentSlug], "-");
|
|
18
28
|
return {
|
|
19
29
|
envConfigRaw: envConfigRaw,
|
|
20
30
|
deployConfigRaw: envConfigRaw.deploy,
|
|
21
31
|
buildConfigRaw: envConfigRaw.build,
|
|
22
32
|
environmentSlugPrefix: environmentSlugPrefix,
|
|
23
33
|
environmentSlug: environmentSlug,
|
|
24
|
-
|
|
34
|
+
reviewSlug: reviewSlug,
|
|
35
|
+
pipelineType: pipelineType,
|
|
25
36
|
fullName: fullName,
|
|
26
37
|
envType: envType,
|
|
27
|
-
commitInfo: commitInfo,
|
|
28
38
|
componentName: componentName,
|
|
29
39
|
env: env,
|
|
30
40
|
fullConfig: config
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type { Context, EnvironmentEnvVarPart as EnvironmentVariables } from "../types";
|
|
2
|
+
import type { CreateContextContext } from "..";
|
|
3
|
+
import type { StringOrBashExpression } from "../bash/BashExpression";
|
|
4
|
+
import type { EnvironmentContext } from "../types/environmentContext";
|
|
5
|
+
export type SecretEnvVar = {
|
|
4
6
|
key: string;
|
|
5
7
|
hidden?: boolean;
|
|
6
8
|
};
|
|
7
|
-
|
|
9
|
+
declare const getBasePredefinedVariables: (ctx: EnvironmentContext<any, any>) => {
|
|
10
|
+
BUILD_INFO_BUILD_ID?: string | import("../bash/BashExpression").BashExpression | undefined;
|
|
11
|
+
BUILD_INFO_BUILD_TIME?: string | import("../bash/BashExpression").BashExpression | undefined;
|
|
12
|
+
BUILD_INFO_CURRENT_VERSION?: string | import("../bash/BashExpression").BashExpression | undefined;
|
|
13
|
+
ENV_SHORT: string;
|
|
14
|
+
APP_DIR: string;
|
|
15
|
+
ENV_TYPE: "stage" | "local" | "dev" | "review" | "prod";
|
|
16
|
+
};
|
|
17
|
+
type BasePredefinedVariables = ReturnType<typeof getBasePredefinedVariables>;
|
|
18
|
+
export type PredefinedVariables = BasePredefinedVariables & {
|
|
19
|
+
/**
|
|
20
|
+
* undefined in rails, Rails before 6.1 (mis)uses the `HOST` environment variable to specify the IP to bind to
|
|
21
|
+
*/
|
|
22
|
+
HOST?: StringOrBashExpression;
|
|
23
|
+
ROOT_URL: StringOrBashExpression;
|
|
24
|
+
HOST_INTERNAL: StringOrBashExpression;
|
|
25
|
+
ROOT_URL_INTERNAL: StringOrBashExpression;
|
|
26
|
+
};
|
|
27
|
+
export declare const getEnvironmentVariables: (ctx: CreateContextContext, alreadyVisited?: Record<string, Record<string, boolean>>) => Promise<EnvironmentVariables>;
|
|
8
28
|
export declare const getSecretVarName: (env: string, componentName: string, key: string) => string;
|
|
9
|
-
export declare const getSecretVarNameForContext: (context: Context, key: string) => string;
|
|
29
|
+
export declare const getSecretVarNameForContext: (context: Context, key: string) => string;
|
|
30
|
+
export {};
|
|
@@ -65,7 +65,7 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
65
65
|
}
|
|
66
66
|
function step(op) {
|
|
67
67
|
if (f) throw new TypeError("Generator is already executing.");
|
|
68
|
-
while (_) try {
|
|
68
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
69
69
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
70
70
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
71
71
|
switch (op[0]) {
|
|
@@ -156,59 +156,73 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
156
156
|
}
|
|
157
157
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
158
158
|
};
|
|
159
|
-
exports
|
|
159
|
+
Object.defineProperty(exports, "__esModule", {
|
|
160
|
+
value: true
|
|
161
|
+
});
|
|
160
162
|
exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironmentVariables = void 0;
|
|
161
163
|
var lodash_1 = require("lodash");
|
|
162
164
|
var deploy_1 = require("../deploy");
|
|
165
|
+
var BashExpression_1 = require("../bash/BashExpression");
|
|
166
|
+
var getBuildInfoVariables_1 = require("./getBuildInfoVariables");
|
|
163
167
|
var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
164
168
|
var resolveReferences_1 = require("./resolveReferences");
|
|
165
|
-
var envVars_1 = require("./utils/envVars");
|
|
166
169
|
var transformJobOnlyVars_1 = require("./transformJobOnlyVars");
|
|
167
|
-
var
|
|
168
|
-
) {
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
var envVars_1 = require("./utils/envVars");
|
|
171
|
+
var getBasePredefinedVariables = function (ctx) {
|
|
172
|
+
return __assign({
|
|
173
|
+
ENV_SHORT: ctx.env,
|
|
174
|
+
APP_DIR: ctx.envConfigRaw.dir,
|
|
175
|
+
ENV_TYPE: ctx.envType
|
|
176
|
+
}, ctx.envType !== "local" ? (0, getBuildInfoVariables_1.getBuildInfoVariables)(ctx) : {});
|
|
177
|
+
};
|
|
178
|
+
var getEnvironmentVariables = function (ctx_1) {
|
|
179
|
+
var args_1 = [];
|
|
180
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
181
|
+
args_1[_i - 1] = arguments[_i];
|
|
171
182
|
}
|
|
172
|
-
return __awaiter(void 0,
|
|
173
|
-
|
|
183
|
+
return __awaiter(void 0, __spreadArray([ctx_1], __read(args_1), false), void 0, function (ctx, alreadyVisited // to prevent endless loop
|
|
184
|
+
) {
|
|
185
|
+
var environmentContext, config, env, componentName, envConfigRaw, deployConfigRaw, buildConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, HOST_INTERNAL, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegacyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
|
|
174
186
|
var _a, _b;
|
|
175
187
|
var _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
188
|
+
if (alreadyVisited === void 0) {
|
|
189
|
+
alreadyVisited = {};
|
|
190
|
+
}
|
|
176
191
|
return __generator(this, function (_m) {
|
|
177
192
|
switch (_m.label) {
|
|
178
193
|
case 0:
|
|
179
|
-
environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(
|
|
194
|
+
environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(ctx);
|
|
195
|
+
config = ctx.config, env = ctx.env, componentName = ctx.componentName;
|
|
180
196
|
envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, buildConfigRaw = environmentContext.buildConfigRaw, envType = environmentContext.envType;
|
|
181
|
-
basePredefinedVariables =
|
|
182
|
-
ENV_SHORT: env,
|
|
183
|
-
APP_DIR: envConfigRaw.dir,
|
|
184
|
-
ENV_TYPE: envType,
|
|
185
|
-
BUILD_INFO_ID: commitInfo === null || commitInfo === void 0 ? void 0 : commitInfo.buildId,
|
|
186
|
-
BUILD_INFO_BUILD_TIME: commitInfo === null || commitInfo === void 0 ? void 0 : commitInfo.buildTime,
|
|
187
|
-
BUILD_INFO_CURRENT_VERSION: commitInfo === null || commitInfo === void 0 ? void 0 : commitInfo.currentVersion
|
|
188
|
-
};
|
|
197
|
+
basePredefinedVariables = getBasePredefinedVariables(environmentContext);
|
|
189
198
|
if (envType === "local") {
|
|
190
199
|
devLocalConfig = envConfigRaw;
|
|
191
200
|
port = (_c = devLocalConfig.port) !== null && _c !== void 0 ? _c : 3000;
|
|
192
|
-
host = "localhost:" + port;
|
|
201
|
+
host = "localhost:" + port.toString();
|
|
193
202
|
url = "http://" + host;
|
|
194
|
-
predefinedVariables = {
|
|
203
|
+
predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), {
|
|
195
204
|
ENV_SHORT: "local",
|
|
196
|
-
ROOT_URL: url
|
|
205
|
+
ROOT_URL: url
|
|
206
|
+
}), config.components[componentName].build.type === "rails" ? {} : {
|
|
207
|
+
HOST: host
|
|
208
|
+
}), {
|
|
197
209
|
HOST_INTERNAL: host,
|
|
198
210
|
ROOT_URL_INTERNAL: "http://" + host,
|
|
199
211
|
PORT: port.toString()
|
|
200
|
-
};
|
|
212
|
+
});
|
|
201
213
|
} else {
|
|
202
214
|
additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
|
|
203
215
|
HOST_INTERNAL = (_d = additionalEnvVars.HOST_INTERNAL) !== null && _d !== void 0 ? _d : "unknown-host.example.com";
|
|
204
216
|
host = (_e = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _e !== void 0 ? _e : HOST_INTERNAL;
|
|
205
|
-
url = "https://"
|
|
217
|
+
url = (0, BashExpression_1.joinBashExpressions)(["https://", host]);
|
|
206
218
|
predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), config.components[componentName].build.type === "rails" ? {} : {
|
|
207
219
|
HOST: host
|
|
208
220
|
}), {
|
|
209
221
|
ROOT_URL: url,
|
|
222
|
+
HOST_INTERNAL: HOST_INTERNAL,
|
|
223
|
+
/**@deprecated */
|
|
210
224
|
HOST_CANONICAL: HOST_INTERNAL,
|
|
211
|
-
ROOT_URL_INTERNAL: "https://"
|
|
225
|
+
ROOT_URL_INTERNAL: (0, BashExpression_1.joinBashExpressions)(["https://", HOST_INTERNAL])
|
|
212
226
|
}), additionalEnvVars);
|
|
213
227
|
}
|
|
214
228
|
publicEnvVarsRaw = (_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.public) !== null && _g !== void 0 ? _g : {};
|
|
@@ -225,7 +239,9 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
|
|
|
225
239
|
return __generator(this, function (_a) {
|
|
226
240
|
switch (_a.label) {
|
|
227
241
|
case 0:
|
|
228
|
-
return [4 /*yield*/, (0, exports.getEnvironmentVariables)(
|
|
242
|
+
return [4 /*yield*/, (0, exports.getEnvironmentVariables)(__assign(__assign({}, ctx), {
|
|
243
|
+
componentName: otherComponentName
|
|
244
|
+
}), alreadyVisited)];
|
|
229
245
|
case 1:
|
|
230
246
|
otherEnvVars = _a.sent().envVars;
|
|
231
247
|
return [2 /*return*/, otherEnvVars];
|
|
@@ -15,14 +15,16 @@ var __importDefault = this && this.__importDefault || function (mod) {
|
|
|
15
15
|
"default": mod
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
exports
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: true
|
|
20
|
+
});
|
|
19
21
|
exports.getLabels = void 0;
|
|
20
22
|
var slugify_1 = __importDefault(require("slugify"));
|
|
21
23
|
var sanitize = function (value) {
|
|
22
24
|
if (!value) return value;
|
|
23
25
|
//"The value can only contain lowercase letters, numeric characters, underscores and dashes. The value can be at most 63 characters long. International characters are allowed."
|
|
24
26
|
// slugify should do the job
|
|
25
|
-
return (0, slugify_1
|
|
27
|
+
return (0, slugify_1.default)(value).toLowerCase();
|
|
26
28
|
};
|
|
27
29
|
var getLabels = function (context) {
|
|
28
30
|
var _a, _b, _c;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type StringOrBashExpression } from "../bash/BashExpression";
|
|
2
|
+
import type { PipelineType } from "../types";
|
|
3
|
+
import type { EnvConfigWithComponent } from "../types/config";
|
|
4
|
+
export declare const getReviewSlug: (envConfig: EnvConfigWithComponent, env: string, pipelineType?: PipelineType) => StringOrBashExpression | null;
|