@catladder/cli 0.0.0-refactor-gcloud-auth-no-file-7a9a76ea → 0.0.0-refactore-catenv-command-validates-argument-78d05852
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/bin/catci +3 -0
- package/bin/catci-dev +3 -0
- package/dist/apps/catci/catci.d.ts +1 -0
- package/dist/apps/catci/catci.js +86 -0
- package/dist/apps/catci/catci.js.map +1 -0
- package/dist/apps/catci/commands/security/auditDocument.d.ts +19 -0
- package/dist/apps/catci/commands/security/auditDocument.js +90 -0
- package/dist/apps/catci/commands/security/auditDocument.js.map +1 -0
- package/dist/apps/catci/commands/security/commands.d.ts +2 -0
- package/dist/apps/catci/commands/security/commands.js +185 -0
- package/dist/apps/catci/commands/security/commands.js.map +1 -0
- package/dist/apps/catci/commands/security/createSecurityAuditMergeRequest.d.ts +9 -0
- package/dist/apps/catci/commands/security/createSecurityAuditMergeRequest.js +112 -0
- package/dist/apps/catci/commands/security/createSecurityAuditMergeRequest.js.map +1 -0
- package/dist/apps/catci/commands/security/evaluateSecurityAudit.d.ts +5 -0
- package/dist/apps/catci/commands/security/evaluateSecurityAudit.js +76 -0
- package/dist/apps/catci/commands/security/evaluateSecurityAudit.js.map +1 -0
- package/dist/apps/catci/commands/security/topics.json +112 -0
- package/dist/apps/catenv/catenv.d.ts +1 -2
- package/dist/apps/catenv/catenv.js +4 -2
- package/dist/apps/catenv/catenv.js.map +1 -1
- package/dist/apps/cli/commands/project/commandSecurityEvaluate.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandSecurityEvaluate.js +70 -0
- package/dist/apps/cli/commands/project/commandSecurityEvaluate.js.map +1 -0
- package/dist/apps/cli/commands/project/index.js +2 -0
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/bundles/catci/index.js +71390 -0
- package/dist/bundles/catenv/index.js +529 -202
- package/dist/bundles/cli/index.js +2538 -1138
- package/dist/catci.d.ts +1 -0
- package/dist/catci.js +5 -0
- package/dist/catci.js.map +1 -0
- package/dist/catenv.js +1 -3
- package/dist/catenv.js.map +1 -1
- package/dist/config/getProjectConfig.js +6 -9
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/config/parseChoiceArgument.d.ts +13 -0
- package/dist/config/parseChoiceArgument.js +43 -0
- package/dist/config/parseChoiceArgument.js.map +1 -0
- package/dist/gcloud/serviceAccounts.js +3 -1
- package/dist/gcloud/serviceAccounts.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/getEditor.js +16 -8
- package/dist/utils/getEditor.js.map +1 -1
- package/package.json +9 -5
- package/scripts/bundle +2 -0
- package/src/apps/catci/catci.ts +26 -0
- package/src/apps/catci/commands/security/auditDocument.ts +150 -0
- package/src/apps/catci/commands/security/commands.ts +161 -0
- package/src/apps/catci/commands/security/createSecurityAuditMergeRequest.ts +98 -0
- package/src/apps/catci/commands/security/evaluateSecurityAudit.ts +30 -0
- package/src/apps/catci/commands/security/topics.json +120 -0
- package/src/apps/catenv/catenv.ts +8 -6
- package/src/apps/cli/commands/project/commandSecurityEvaluate.ts +26 -0
- package/src/apps/cli/commands/project/index.ts +2 -0
- package/src/catci.ts +3 -0
- package/src/catenv.ts +2 -6
- package/src/config/getProjectConfig.ts +9 -11
- package/src/config/parseChoiceArgument.ts +50 -0
- package/src/gcloud/serviceAccounts.ts +2 -1
- package/src/utils/getEditor.ts +4 -1
|
@@ -44,11 +44,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
44
44
|
};
|
|
45
45
|
exports.__esModule = true;
|
|
46
46
|
var getProjectConfig_1 = __nccwpck_require__(4146);
|
|
47
|
+
var parseChoiceArgument_1 = __nccwpck_require__(3008);
|
|
47
48
|
var printVariables_1 = __nccwpck_require__(7770);
|
|
48
49
|
var writeDotEnvFiles_1 = __nccwpck_require__(4295);
|
|
49
50
|
var writeEnvDTs_1 = __nccwpck_require__(4615);
|
|
50
|
-
exports["default"] = (function (
|
|
51
|
-
var config;
|
|
51
|
+
exports["default"] = (function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
+
var config, choice;
|
|
52
53
|
return __generator(this, function (_a) {
|
|
53
54
|
switch (_a.label) {
|
|
54
55
|
case 0: return [4 /*yield*/, (0, getProjectConfig_1.getProjectConfig)()];
|
|
@@ -57,6 +58,7 @@ exports["default"] = (function (choice) { return __awaiter(void 0, void 0, void
|
|
|
57
58
|
if (!config) {
|
|
58
59
|
return [2 /*return*/];
|
|
59
60
|
}
|
|
61
|
+
choice = (0, parseChoiceArgument_1.parseChoiceArgument)(config);
|
|
60
62
|
return [4 /*yield*/, (0, printVariables_1.printVariables)(config, choice)];
|
|
61
63
|
case 2:
|
|
62
64
|
_a.sent();
|
|
@@ -543,9 +545,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
543
545
|
};
|
|
544
546
|
exports.__esModule = true;
|
|
545
547
|
var catenv_1 = __importDefault(__nccwpck_require__(3073));
|
|
546
|
-
|
|
547
|
-
var choice = process.argv[2] ? (0, parseChoice_1.parseChoice)(process.argv[2]) : null;
|
|
548
|
-
(0, catenv_1["default"])(choice).then(function () {
|
|
548
|
+
(0, catenv_1["default"])().then(function () {
|
|
549
549
|
// we have to exit manually, because we have some file watches
|
|
550
550
|
process.exit();
|
|
551
551
|
});
|
|
@@ -795,15 +795,12 @@ var resolveSecrets = function (vorpal, varSets) { return __awaiter(void 0, void
|
|
|
795
795
|
.map(function (_a) {
|
|
796
796
|
var key = _a[0], value = _a[1];
|
|
797
797
|
var secretKey = set.secretEnvVarKeys.find(function (k) { return k.key === key; });
|
|
798
|
-
if (secretKey) {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
value = value.replace(new RegExp("\\$" + variable.key, "g"), variable.value);
|
|
805
|
-
}
|
|
806
|
-
return [key, value];
|
|
798
|
+
if ((secretKey === null || secretKey === void 0 ? void 0 : secretKey.hidden) || value === undefined) {
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
for (var _i = 0, allVariablesInGitlab_1 = allVariablesInGitlab; _i < allVariablesInGitlab_1.length; _i++) {
|
|
802
|
+
var variable = allVariablesInGitlab_1[_i];
|
|
803
|
+
value = value.replace(new RegExp("\\$" + variable.key, "g"), variable.value);
|
|
807
804
|
}
|
|
808
805
|
return [key, value];
|
|
809
806
|
})
|
|
@@ -889,6 +886,56 @@ exports.parseChoice = parseChoice;
|
|
|
889
886
|
|
|
890
887
|
/***/ }),
|
|
891
888
|
|
|
889
|
+
/***/ 3008:
|
|
890
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
891
|
+
|
|
892
|
+
"use strict";
|
|
893
|
+
|
|
894
|
+
exports.__esModule = true;
|
|
895
|
+
exports.parseChoiceArgument = exports.getEnvComponentArgument = void 0;
|
|
896
|
+
var pipeline_1 = __nccwpck_require__(5355);
|
|
897
|
+
var envTypes = Object.keys(pipeline_1.ENV_TYPES);
|
|
898
|
+
var getEnvComponentArgument = function () {
|
|
899
|
+
var _a;
|
|
900
|
+
var componentMatch = "([a-zA-Z0-9_-]+)";
|
|
901
|
+
var argRegexp = new RegExp("^((".concat(envTypes.join('|'), "):").concat(componentMatch, "|").concat(componentMatch, ")$"));
|
|
902
|
+
var envComponent = (_a = process.argv[2]) !== null && _a !== void 0 ? _a : '';
|
|
903
|
+
var _b = argRegexp.exec(envComponent), _c = _b[2], env = _c === void 0 ? 'local' : _c, componentNameWithEnv = _b[3], onlyComponentName = _b[4];
|
|
904
|
+
if (!(0, pipeline_1.isKnowEnvType)(env)) {
|
|
905
|
+
throw new Error("invalid env type! ".concat(env, ".\nEnv must be one of: ").concat(envTypes.join(', ')));
|
|
906
|
+
}
|
|
907
|
+
if (componentNameWithEnv === null || componentNameWithEnv === void 0 ? void 0 : componentNameWithEnv.length) {
|
|
908
|
+
return { env: env, componentName: componentNameWithEnv };
|
|
909
|
+
}
|
|
910
|
+
if (onlyComponentName === null || onlyComponentName === void 0 ? void 0 : onlyComponentName.length) {
|
|
911
|
+
return { env: env, componentName: onlyComponentName };
|
|
912
|
+
}
|
|
913
|
+
return { env: env };
|
|
914
|
+
};
|
|
915
|
+
exports.getEnvComponentArgument = getEnvComponentArgument;
|
|
916
|
+
/**
|
|
917
|
+
* Parses the environment component argument and returns a Choice object.
|
|
918
|
+
* @param envComponent - The environment component argument to parse.
|
|
919
|
+
* @returns The parsed Choice object.
|
|
920
|
+
* @throws Error if the env type is invalid.
|
|
921
|
+
*/
|
|
922
|
+
var parseChoiceArgument = function (_a) {
|
|
923
|
+
var components = _a.components;
|
|
924
|
+
var _b = (0, exports.getEnvComponentArgument)(), env = _b.env, componentName = _b.componentName;
|
|
925
|
+
var componentNames = Object.keys(components);
|
|
926
|
+
if ((componentName === null || componentName === void 0 ? void 0 : componentName.length) && !componentNames.includes(componentName)) {
|
|
927
|
+
throw new Error("invalid component name! Component must be one of: ".concat(componentNames.join(', ')));
|
|
928
|
+
}
|
|
929
|
+
if (componentName === null || componentName === void 0 ? void 0 : componentName.length) {
|
|
930
|
+
return { env: env, componentName: componentName };
|
|
931
|
+
}
|
|
932
|
+
return { env: env };
|
|
933
|
+
};
|
|
934
|
+
exports.parseChoiceArgument = parseChoiceArgument;
|
|
935
|
+
//# sourceMappingURL=parseChoiceArgument.js.map
|
|
936
|
+
|
|
937
|
+
/***/ }),
|
|
938
|
+
|
|
892
939
|
/***/ 8116:
|
|
893
940
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
894
941
|
|
|
@@ -40535,7 +40582,7 @@ var createRailsBuildJobs = function (context) {
|
|
|
40535
40582
|
dockerBuild: {
|
|
40536
40583
|
variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
|
|
40537
40584
|
// custom script
|
|
40538
|
-
script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
|
|
40585
|
+
script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["cd ".concat(context.componentConfig.dir), "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
|
|
40539
40586
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
40540
40587
|
"sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")], false)
|
|
40541
40588
|
}
|
|
@@ -40920,7 +40967,7 @@ exports.readConfigSync = readConfigSync;
|
|
|
40920
40967
|
|
|
40921
40968
|
exports.__esModule = true;
|
|
40922
40969
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
40923
|
-
exports.PIPELINE_IMAGE_TAG = "
|
|
40970
|
+
exports.PIPELINE_IMAGE_TAG = "refactore-catenv-command-validates-argument-78d05852" || 0;
|
|
40924
40971
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
|
|
40925
40972
|
|
|
40926
40973
|
/***/ }),
|
|
@@ -41830,7 +41877,7 @@ exports.__esModule = true;
|
|
|
41830
41877
|
exports.translateLegacyFromComponents = exports.resolveReferences = void 0;
|
|
41831
41878
|
var lodash_1 = __nccwpck_require__(3255);
|
|
41832
41879
|
var string_replace_async_1 = __importDefault(__nccwpck_require__(4439));
|
|
41833
|
-
var REGEX = /\$\{(([^:]+):)?([^}]+)}/gm;
|
|
41880
|
+
var REGEX = /\$\{(([^:}]+):)?([^}]+)}/gm;
|
|
41834
41881
|
var resolveReferences = function (vars, getOtherVariables, alreadyVisitedBase) {
|
|
41835
41882
|
if (alreadyVisitedBase === void 0) {
|
|
41836
41883
|
alreadyVisitedBase = {};
|
|
@@ -42707,7 +42754,7 @@ exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
|
|
|
42707
42754
|
|
|
42708
42755
|
/***/ }),
|
|
42709
42756
|
|
|
42710
|
-
/***/
|
|
42757
|
+
/***/ 6321:
|
|
42711
42758
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
42712
42759
|
|
|
42713
42760
|
"use strict";
|
|
@@ -42755,27 +42802,263 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
42755
42802
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
42756
42803
|
};
|
|
42757
42804
|
exports.__esModule = true;
|
|
42758
|
-
exports.
|
|
42759
|
-
var js_yaml_1 = __nccwpck_require__(3618);
|
|
42760
|
-
var lodash_1 = __nccwpck_require__(3255);
|
|
42761
|
-
var _1 = __nccwpck_require__(1344);
|
|
42762
|
-
var docker_1 = __nccwpck_require__(3219);
|
|
42763
|
-
var getLabels_1 = __nccwpck_require__(486);
|
|
42764
|
-
var runner_1 = __nccwpck_require__(5071);
|
|
42805
|
+
exports.getCreateScheduleScripts = exports.getJobCreateScripts = exports.getJobRunScripts = exports.getDeleteJobsScripts = exports.getDeleteSchedulesScripts = void 0;
|
|
42765
42806
|
var gitlab_1 = __nccwpck_require__(4997);
|
|
42766
|
-
var base_1 = __nccwpck_require__(2866);
|
|
42767
|
-
var sbom_1 = __nccwpck_require__(5928);
|
|
42768
|
-
var types_1 = __nccwpck_require__(3109);
|
|
42769
42807
|
var createArgsString_1 = __nccwpck_require__(8686);
|
|
42770
|
-
var database_1 = __nccwpck_require__(1384);
|
|
42771
|
-
var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
|
|
42772
42808
|
var jobName_1 = __nccwpck_require__(7311);
|
|
42773
|
-
var
|
|
42809
|
+
var common_1 = __nccwpck_require__(5655);
|
|
42810
|
+
var getLabels_1 = __nccwpck_require__(486);
|
|
42811
|
+
var getJobRunScriptForJob = function (context, jobName, wait) {
|
|
42812
|
+
var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
42813
|
+
var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
42814
|
+
return "".concat((0, common_1.gcloudRunCmd)(), " jobs execute ").concat(jobName, " ").concat(commonArgsString).concat(wait ? " --wait" : "");
|
|
42815
|
+
};
|
|
42816
|
+
var getDeleteSchedulesScripts = function (context) {
|
|
42817
|
+
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
42818
|
+
var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
|
|
42819
|
+
var argsString = (0, createArgsString_1.createArgsString)({
|
|
42820
|
+
project: deployConfig.projectId,
|
|
42821
|
+
location: deployConfig.region
|
|
42822
|
+
});
|
|
42823
|
+
return jobsWithSchedule.map(function (_a) {
|
|
42824
|
+
var schedulerName = _a.schedulerName;
|
|
42825
|
+
return ["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs delete ").concat(schedulerName, " ").concat(argsString)];
|
|
42826
|
+
}).flat();
|
|
42827
|
+
};
|
|
42828
|
+
exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
|
|
42829
|
+
var getDeleteJobsScripts = function (context) {
|
|
42830
|
+
var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
42831
|
+
var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
42832
|
+
var jobsWithNames = getCloudRunJobsWithNames(context);
|
|
42833
|
+
return jobsWithNames.flatMap(function (_a) {
|
|
42834
|
+
var jobName = _a.jobName;
|
|
42835
|
+
return [
|
|
42836
|
+
// first delete all job executions. Otherwise delete might fail if one of those is still running
|
|
42837
|
+
"".concat((0, common_1.gcloudRunCmd)(), " jobs executions list ").concat(commonArgsString, " --job ").concat(jobName, " --format=\"value(name)\" | xargs -I {} ").concat((0, common_1.gcloudRunCmd)(), " jobs executions delete {} --quiet ").concat(commonArgsString), "".concat((0, common_1.gcloudRunCmd)(), " jobs delete ").concat(jobName, " ").concat(commonArgsString)];
|
|
42838
|
+
});
|
|
42839
|
+
};
|
|
42840
|
+
exports.getDeleteJobsScripts = getDeleteJobsScripts;
|
|
42841
|
+
var getJobRunScripts = function (context, when) {
|
|
42842
|
+
var jobsWithNames = getCloudRunJobsWithNames(context);
|
|
42843
|
+
return jobsWithNames.filter(function (_a) {
|
|
42844
|
+
var job = _a.job;
|
|
42845
|
+
return job.when === when;
|
|
42846
|
+
}).map(function (_a) {
|
|
42847
|
+
var jobName = _a.jobName;
|
|
42848
|
+
return getJobRunScriptForJob(context, jobName,
|
|
42849
|
+
// wait for completin on stop jobs, since stop will delete the jobs afterwards, so they will fail
|
|
42850
|
+
["preStop", "postStop"].includes(when));
|
|
42851
|
+
});
|
|
42852
|
+
};
|
|
42853
|
+
exports.getJobRunScripts = getJobRunScripts;
|
|
42854
|
+
var getJobCreateScripts = function (context) {
|
|
42855
|
+
var jobsWithNames = getCloudRunJobsWithNames(context);
|
|
42856
|
+
return jobsWithNames.map(function (_a) {
|
|
42857
|
+
var job = _a.job,
|
|
42858
|
+
jobName = _a.jobName;
|
|
42859
|
+
return getJobCreateScriptsForJob(context, jobName, job);
|
|
42860
|
+
}).flat();
|
|
42861
|
+
};
|
|
42862
|
+
exports.getJobCreateScripts = getJobCreateScripts;
|
|
42863
|
+
var getJobCreateScriptsForJob = function (context, jobName, job) {
|
|
42864
|
+
var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
|
|
42865
|
+
// we cannot upsert a job, so we have to create it and catch the error and then update
|
|
42866
|
+
var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
|
|
42867
|
+
var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
|
|
42868
|
+
command: '"' + commandArray.join(",") + '"'
|
|
42869
|
+
}, commonDeployArgs), {
|
|
42870
|
+
labels: (0, common_1.makeLabelString)(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
|
|
42871
|
+
"cloud-run-job-name": jobName
|
|
42872
|
+
})),
|
|
42873
|
+
image: job.image || commonDeployArgs.image,
|
|
42874
|
+
memory: job.memory || "512Mi",
|
|
42875
|
+
"task-timeout": job.timeout || "10m",
|
|
42876
|
+
parallelism: job.parallelism || 1,
|
|
42877
|
+
"env-vars-file": "____envvars.yaml",
|
|
42878
|
+
"max-retries": 0
|
|
42879
|
+
}));
|
|
42880
|
+
var argsString = "".concat(jobName, " ").concat(commonDeployArgsString);
|
|
42881
|
+
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["".concat((0, common_1.gcloudRunCmd)(), " jobs create ").concat(argsString)])), false), ["".concat((0, common_1.gcloudRunCmd)(), " jobs update ").concat(argsString)], false);
|
|
42882
|
+
};
|
|
42883
|
+
var getCreateScheduleScripts = function (context) {
|
|
42884
|
+
var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
|
|
42885
|
+
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
42886
|
+
return jobsWithSchedule.map(function (_a) {
|
|
42887
|
+
var _b;
|
|
42888
|
+
var job = _a.job,
|
|
42889
|
+
jobName = _a.jobName,
|
|
42890
|
+
schedulerName = _a.schedulerName;
|
|
42891
|
+
var argsString = (0, createArgsString_1.createArgsString)({
|
|
42892
|
+
project: deployConfig.projectId,
|
|
42893
|
+
location: deployConfig.region,
|
|
42894
|
+
schedule: "\"".concat(job.schedule, "\""),
|
|
42895
|
+
"max-retry-attempts": (_b = job.maxRetryAttempts) !== null && _b !== void 0 ? _b : 0,
|
|
42896
|
+
uri: "\"https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(jobName, ":run\""),
|
|
42897
|
+
"http-method": "POST",
|
|
42898
|
+
"oauth-service-account-email": "$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"
|
|
42899
|
+
});
|
|
42900
|
+
var commonArgs = "http ".concat(schedulerName, " ").concat(argsString);
|
|
42901
|
+
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs create ").concat(commonArgs)])), false), ["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs update ").concat(commonArgs)], false);
|
|
42902
|
+
}).flat();
|
|
42903
|
+
};
|
|
42904
|
+
exports.getCreateScheduleScripts = getCreateScheduleScripts;
|
|
42905
|
+
var getCloudRunJobsWithSchedule = function (context) {
|
|
42906
|
+
var jobsWithNames = getCloudRunJobsWithNames(context);
|
|
42907
|
+
return jobsWithNames.filter(function (entry) {
|
|
42908
|
+
return entry.job.when === "schedule";
|
|
42909
|
+
}).map(function (_a) {
|
|
42910
|
+
var job = _a.job,
|
|
42911
|
+
jobName = _a.jobName;
|
|
42912
|
+
return {
|
|
42913
|
+
job: job,
|
|
42914
|
+
jobName: jobName,
|
|
42915
|
+
schedulerName: jobName + "-scheduler"
|
|
42916
|
+
};
|
|
42917
|
+
});
|
|
42918
|
+
};
|
|
42919
|
+
var getCloudRunJobsWithNames = function (context) {
|
|
42920
|
+
var _a;
|
|
42921
|
+
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
42922
|
+
var getFullJobName = function (name) {
|
|
42923
|
+
return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
|
|
42924
|
+
};
|
|
42925
|
+
var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
|
|
42926
|
+
// filter out disabled jobs
|
|
42927
|
+
.filter(function (entry) {
|
|
42928
|
+
return Boolean(entry[1]);
|
|
42929
|
+
}).map(function (_a) {
|
|
42930
|
+
var _b = __read(_a, 2),
|
|
42931
|
+
name = _b[0],
|
|
42932
|
+
job = _b[1];
|
|
42933
|
+
return {
|
|
42934
|
+
jobName: getFullJobName(name),
|
|
42935
|
+
job: job
|
|
42936
|
+
};
|
|
42937
|
+
});
|
|
42938
|
+
return jobsWithNames;
|
|
42939
|
+
};
|
|
42940
|
+
|
|
42941
|
+
/***/ }),
|
|
42942
|
+
|
|
42943
|
+
/***/ 7210:
|
|
42944
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
42945
|
+
|
|
42946
|
+
"use strict";
|
|
42947
|
+
|
|
42948
|
+
|
|
42949
|
+
var __assign = this && this.__assign || function () {
|
|
42950
|
+
__assign = Object.assign || function (t) {
|
|
42951
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
42952
|
+
s = arguments[i];
|
|
42953
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
42954
|
+
}
|
|
42955
|
+
return t;
|
|
42956
|
+
};
|
|
42957
|
+
return __assign.apply(this, arguments);
|
|
42958
|
+
};
|
|
42959
|
+
exports.__esModule = true;
|
|
42960
|
+
exports.getServiceDeleteScript = exports.getServiceDeployScript = void 0;
|
|
42961
|
+
var getLabels_1 = __nccwpck_require__(486);
|
|
42962
|
+
var createArgsString_1 = __nccwpck_require__(8686);
|
|
42774
42963
|
var getServiceName_1 = __nccwpck_require__(9391);
|
|
42775
|
-
var
|
|
42964
|
+
var common_1 = __nccwpck_require__(5655);
|
|
42965
|
+
var getServiceDeployScript = function (context, service, nameSuffix) {
|
|
42966
|
+
var _a, _b, _c, _d, _e;
|
|
42967
|
+
var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
|
|
42968
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
42969
|
+
var customConfig = service !== true ? service : undefined;
|
|
42970
|
+
var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
|
|
42971
|
+
var commandArray = command ? Array.isArray(command) ? command : command.split(" ") : undefined;
|
|
42972
|
+
var fullServiceName = "".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "");
|
|
42973
|
+
var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
|
|
42974
|
+
// command as empty string resets it to default (uses the image's entrypoint)
|
|
42975
|
+
command: commandArray ? '"' + commandArray.join(",") + '"' : '""'
|
|
42976
|
+
}, commonDeployArgs), {
|
|
42977
|
+
labels: (0, common_1.makeLabelString)(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
|
|
42978
|
+
"cloud-run-service-name": fullServiceName
|
|
42979
|
+
})),
|
|
42980
|
+
"env-vars-file": "____envvars.yaml",
|
|
42981
|
+
"min-instances": (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _b !== void 0 ? _b : 0,
|
|
42982
|
+
"max-instances": (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances) !== null && _c !== void 0 ? _c : 100,
|
|
42983
|
+
"cpu-throttling": (customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling) !== true,
|
|
42984
|
+
memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
|
|
42985
|
+
"allow-unauthenticated": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _d !== void 0 ? _d : true,
|
|
42986
|
+
ingress: (_e = customConfig === null || customConfig === void 0 ? void 0 : customConfig.ingress) !== null && _e !== void 0 ? _e : "all",
|
|
42987
|
+
"cpu-boost": true,
|
|
42988
|
+
"execution-environment": customConfig === null || customConfig === void 0 ? void 0 : customConfig.executionEnvironment
|
|
42989
|
+
}));
|
|
42990
|
+
return "".concat((0, common_1.gcloudRunCmd)(), " deploy ").concat(fullServiceName, " ").concat(argsString);
|
|
42991
|
+
};
|
|
42992
|
+
exports.getServiceDeployScript = getServiceDeployScript;
|
|
42993
|
+
var getServiceDeleteScript = function (context, serviceSuffix) {
|
|
42994
|
+
var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
42995
|
+
var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
42996
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
42997
|
+
var fullServiceName = serviceSuffix ? "".concat(serviceName, "-").concat(serviceSuffix) : serviceName;
|
|
42998
|
+
return ["".concat((0, common_1.gcloudRunCmd)(), " services delete ").concat(fullServiceName, " ").concat(commonArgsString)];
|
|
42999
|
+
};
|
|
43000
|
+
exports.getServiceDeleteScript = getServiceDeleteScript;
|
|
43001
|
+
|
|
43002
|
+
/***/ }),
|
|
43003
|
+
|
|
43004
|
+
/***/ 5655:
|
|
43005
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
43006
|
+
|
|
43007
|
+
"use strict";
|
|
43008
|
+
|
|
43009
|
+
|
|
43010
|
+
var __assign = this && this.__assign || function () {
|
|
43011
|
+
__assign = Object.assign || function (t) {
|
|
43012
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
43013
|
+
s = arguments[i];
|
|
43014
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
43015
|
+
}
|
|
43016
|
+
return t;
|
|
43017
|
+
};
|
|
43018
|
+
return __assign.apply(this, arguments);
|
|
43019
|
+
};
|
|
43020
|
+
var __read = this && this.__read || function (o, n) {
|
|
43021
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
43022
|
+
if (!m) return o;
|
|
43023
|
+
var i = m.call(o),
|
|
43024
|
+
r,
|
|
43025
|
+
ar = [],
|
|
43026
|
+
e;
|
|
43027
|
+
try {
|
|
43028
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43029
|
+
} catch (error) {
|
|
43030
|
+
e = {
|
|
43031
|
+
error: error
|
|
43032
|
+
};
|
|
43033
|
+
} finally {
|
|
43034
|
+
try {
|
|
43035
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
43036
|
+
} finally {
|
|
43037
|
+
if (e) throw e.error;
|
|
43038
|
+
}
|
|
43039
|
+
}
|
|
43040
|
+
return ar;
|
|
43041
|
+
};
|
|
43042
|
+
exports.__esModule = true;
|
|
43043
|
+
exports.getCommonDeployArgs = exports.getCommonCloudRunArgs = exports.getCloudRunDeployConfig = exports.makeLabelString = exports.setGoogleProjectNumberScript = exports.gcloudSchedulerCmd = exports.gcloudRunCmd = exports.gcloudCmd = void 0;
|
|
43044
|
+
var types_1 = __nccwpck_require__(3109);
|
|
43045
|
+
var artifactsRegistry_1 = __nccwpck_require__(8159);
|
|
43046
|
+
var gcloudCmd = function (version) {
|
|
43047
|
+
return version ? "gcloud ".concat(version) : "gcloud";
|
|
43048
|
+
};
|
|
43049
|
+
exports.gcloudCmd = gcloudCmd;
|
|
43050
|
+
var gcloudRunCmd = function (version) {
|
|
43051
|
+
return "".concat((0, exports.gcloudCmd)(version), " run");
|
|
43052
|
+
};
|
|
43053
|
+
exports.gcloudRunCmd = gcloudRunCmd;
|
|
43054
|
+
var gcloudSchedulerCmd = function (version) {
|
|
43055
|
+
return "".concat((0, exports.gcloudCmd)(version), " scheduler");
|
|
43056
|
+
};
|
|
43057
|
+
exports.gcloudSchedulerCmd = gcloudSchedulerCmd;
|
|
42776
43058
|
var setGoogleProjectNumberScript = function (deployConfig) {
|
|
42777
|
-
return ["export GCLOUD_PROJECT_NUMBER=$(
|
|
43059
|
+
return ["export GCLOUD_PROJECT_NUMBER=$(".concat((0, exports.gcloudCmd)(), " projects describe ").concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
|
|
42778
43060
|
};
|
|
43061
|
+
exports.setGoogleProjectNumberScript = setGoogleProjectNumberScript;
|
|
42779
43062
|
var makeLabelString = function (obj) {
|
|
42780
43063
|
return Object.entries(obj).map(function (_a) {
|
|
42781
43064
|
var _b = __read(_a, 2),
|
|
@@ -42784,181 +43067,193 @@ var makeLabelString = function (obj) {
|
|
|
42784
43067
|
return "".concat(key, "=").concat(value);
|
|
42785
43068
|
}).join(",");
|
|
42786
43069
|
};
|
|
42787
|
-
|
|
42788
|
-
|
|
43070
|
+
exports.makeLabelString = makeLabelString;
|
|
43071
|
+
var getCloudRunDeployConfig = function (context) {
|
|
42789
43072
|
var deployConfig = context.componentConfig.deploy;
|
|
42790
|
-
if (deployConfig === false) {
|
|
42791
|
-
return [];
|
|
42792
|
-
}
|
|
42793
43073
|
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
42794
43074
|
// should not happen
|
|
42795
43075
|
throw new Error("deploy config is wrong");
|
|
42796
43076
|
}
|
|
42797
|
-
|
|
42798
|
-
|
|
43077
|
+
return deployConfig;
|
|
43078
|
+
};
|
|
43079
|
+
exports.getCloudRunDeployConfig = getCloudRunDeployConfig;
|
|
43080
|
+
function getCommonCloudRunArgs(context) {
|
|
43081
|
+
var deployConfig = (0, exports.getCloudRunDeployConfig)(context);
|
|
43082
|
+
return {
|
|
42799
43083
|
project: deployConfig.projectId,
|
|
42800
43084
|
region: deployConfig.region
|
|
42801
43085
|
};
|
|
42802
|
-
|
|
43086
|
+
}
|
|
43087
|
+
exports.getCommonCloudRunArgs = getCommonCloudRunArgs;
|
|
43088
|
+
function getCommonDeployArgs(context) {
|
|
43089
|
+
var commonArgs = getCommonCloudRunArgs(context);
|
|
43090
|
+
var deployConfig = (0, exports.getCloudRunDeployConfig)(context);
|
|
43091
|
+
return __assign(__assign({
|
|
42803
43092
|
image: (0, artifactsRegistry_1.getArtifactsRegistryImage)(context)
|
|
42804
43093
|
}, commonArgs), {
|
|
42805
43094
|
"set-cloudsql-instances": deployConfig.cloudSql ? deployConfig.cloudSql.instanceConnectionName : undefined
|
|
42806
43095
|
});
|
|
42807
|
-
|
|
42808
|
-
|
|
42809
|
-
|
|
42810
|
-
|
|
42811
|
-
|
|
42812
|
-
|
|
42813
|
-
|
|
42814
|
-
|
|
42815
|
-
|
|
42816
|
-
|
|
42817
|
-
|
|
42818
|
-
|
|
42819
|
-
|
|
42820
|
-
|
|
42821
|
-
|
|
42822
|
-
|
|
42823
|
-
|
|
42824
|
-
|
|
42825
|
-
|
|
42826
|
-
|
|
42827
|
-
|
|
42828
|
-
|
|
42829
|
-
|
|
42830
|
-
job: job,
|
|
42831
|
-
jobName: jobName,
|
|
42832
|
-
schedulerName: jobName + "-scheduler"
|
|
43096
|
+
}
|
|
43097
|
+
exports.getCommonDeployArgs = getCommonDeployArgs;
|
|
43098
|
+
|
|
43099
|
+
/***/ }),
|
|
43100
|
+
|
|
43101
|
+
/***/ 1944:
|
|
43102
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
43103
|
+
|
|
43104
|
+
"use strict";
|
|
43105
|
+
|
|
43106
|
+
|
|
43107
|
+
var __read = this && this.__read || function (o, n) {
|
|
43108
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
43109
|
+
if (!m) return o;
|
|
43110
|
+
var i = m.call(o),
|
|
43111
|
+
r,
|
|
43112
|
+
ar = [],
|
|
43113
|
+
e;
|
|
43114
|
+
try {
|
|
43115
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43116
|
+
} catch (error) {
|
|
43117
|
+
e = {
|
|
43118
|
+
error: error
|
|
42833
43119
|
};
|
|
42834
|
-
}
|
|
42835
|
-
|
|
42836
|
-
|
|
42837
|
-
|
|
42838
|
-
|
|
42839
|
-
|
|
42840
|
-
|
|
42841
|
-
|
|
42842
|
-
|
|
42843
|
-
|
|
42844
|
-
|
|
42845
|
-
|
|
42846
|
-
|
|
42847
|
-
|
|
42848
|
-
|
|
42849
|
-
|
|
42850
|
-
|
|
42851
|
-
|
|
42852
|
-
|
|
42853
|
-
|
|
42854
|
-
|
|
42855
|
-
|
|
42856
|
-
|
|
42857
|
-
|
|
42858
|
-
|
|
42859
|
-
|
|
42860
|
-
|
|
42861
|
-
|
|
42862
|
-
|
|
42863
|
-
|
|
42864
|
-
|
|
42865
|
-
|
|
42866
|
-
|
|
42867
|
-
labels: makeLabelString(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
|
|
42868
|
-
"cloud-run-job-name": jobName
|
|
42869
|
-
})),
|
|
42870
|
-
image: job.image || commonDeployArgs.image,
|
|
42871
|
-
memory: job.memory || "512Mi",
|
|
42872
|
-
"task-timeout": job.timeout || "10m"
|
|
42873
|
-
}));
|
|
42874
|
-
var argsString = "".concat(jobName, " ").concat(commonDeployArgsString);
|
|
42875
|
-
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["gcloud beta run jobs create ".concat(argsString)])), false), ["gcloud beta run jobs update ".concat(argsString, " --env-vars-file=____envvars.yaml")], false);
|
|
42876
|
-
};
|
|
42877
|
-
var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
42878
|
-
var getJobCreateScripts = function () {
|
|
42879
|
-
return jobsWithNames.map(function (_a) {
|
|
42880
|
-
var job = _a.job,
|
|
42881
|
-
jobName = _a.jobName;
|
|
42882
|
-
return getJobCreateScriptsForJob(jobName, job);
|
|
42883
|
-
}).flat();
|
|
42884
|
-
};
|
|
42885
|
-
var getJobRunScriptForJob = function (jobName, wait) {
|
|
42886
|
-
return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgsString).concat(wait ? " --wait" : "");
|
|
42887
|
-
};
|
|
42888
|
-
var getJobRunScripts = function (when) {
|
|
42889
|
-
return jobsWithNames.filter(function (_a) {
|
|
42890
|
-
var job = _a.job;
|
|
42891
|
-
return job.when === when;
|
|
42892
|
-
}).map(function (_a) {
|
|
42893
|
-
var jobName = _a.jobName;
|
|
42894
|
-
return getJobRunScriptForJob(jobName,
|
|
42895
|
-
// wait for completin on stop jobs, since stop will delete the jobs afterwards, so they will fail
|
|
42896
|
-
["preStop", "postStop"].includes(when));
|
|
42897
|
-
});
|
|
42898
|
-
};
|
|
42899
|
-
var getCreateScheduleScripts = function () {
|
|
42900
|
-
return jobsWithSchedule.map(function (_a) {
|
|
42901
|
-
var _b;
|
|
42902
|
-
var job = _a.job,
|
|
42903
|
-
jobName = _a.jobName,
|
|
42904
|
-
schedulerName = _a.schedulerName;
|
|
42905
|
-
var argsString = (0, createArgsString_1.createArgsString)({
|
|
42906
|
-
project: deployConfig.projectId,
|
|
42907
|
-
location: deployConfig.region,
|
|
42908
|
-
schedule: "\"".concat(job.schedule, "\""),
|
|
42909
|
-
"max-retry-attempts": (_b = job.maxRetryAttempts) !== null && _b !== void 0 ? _b : 0,
|
|
42910
|
-
uri: "\"https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(jobName, ":run\""),
|
|
42911
|
-
"http-method": "POST",
|
|
42912
|
-
"oauth-service-account-email": "$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"
|
|
42913
|
-
});
|
|
42914
|
-
var commonArgs = "http ".concat(schedulerName, " ").concat(argsString);
|
|
42915
|
-
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["gcloud scheduler jobs create ".concat(commonArgs)])), false), ["gcloud scheduler jobs update ".concat(commonArgs)], false);
|
|
42916
|
-
}).flat();
|
|
42917
|
-
};
|
|
42918
|
-
var getDeleteSchedulesScripts = function () {
|
|
42919
|
-
var argsString = (0, createArgsString_1.createArgsString)({
|
|
42920
|
-
project: deployConfig.projectId,
|
|
42921
|
-
location: deployConfig.region
|
|
42922
|
-
});
|
|
42923
|
-
return jobsWithSchedule.map(function (_a) {
|
|
42924
|
-
var schedulerName = _a.schedulerName;
|
|
42925
|
-
return ["gcloud scheduler jobs delete ".concat(schedulerName, " ").concat(argsString)];
|
|
42926
|
-
}).flat();
|
|
42927
|
-
};
|
|
42928
|
-
var getDeleteJobsScripts = function () {
|
|
42929
|
-
return jobsWithNames.flatMap(function (_a) {
|
|
42930
|
-
var jobName = _a.jobName;
|
|
42931
|
-
return [
|
|
42932
|
-
// first delete all job executions. Otherwise delete might fail if one of those is still running
|
|
42933
|
-
"gcloud beta run jobs executions list ".concat(commonArgsString, " --job ").concat(jobName, " --format=\"value(name)\" | xargs -I {} gcloud beta run jobs executions delete {} --quiet ").concat(commonArgsString), "gcloud beta run jobs delete ".concat(jobName, " ").concat(commonArgsString)];
|
|
42934
|
-
});
|
|
42935
|
-
};
|
|
42936
|
-
var deployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gitlab_1.collapseableSection)("prepare", "Prepare...")(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(setGoogleProjectNumberScript(deployConfig)), false))), false), __read((0, gitlab_1.collapseableSection)("deploy", "Deploy to cloud run")(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(deployConfig.cloudSql ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
42937
|
-
: []), false), __read(getCreateScheduleScripts()), false), __read(getJobCreateScripts()), false), __read(getJobRunScripts("preDeploy")), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(Object.entries((_b = deployConfig.additionalServices) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
|
|
43120
|
+
} finally {
|
|
43121
|
+
try {
|
|
43122
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
43123
|
+
} finally {
|
|
43124
|
+
if (e) throw e.error;
|
|
43125
|
+
}
|
|
43126
|
+
}
|
|
43127
|
+
return ar;
|
|
43128
|
+
};
|
|
43129
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
43130
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
43131
|
+
if (ar || !(i in from)) {
|
|
43132
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
43133
|
+
ar[i] = from[i];
|
|
43134
|
+
}
|
|
43135
|
+
}
|
|
43136
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
43137
|
+
};
|
|
43138
|
+
exports.__esModule = true;
|
|
43139
|
+
exports.getCloudRunDeployScripts = void 0;
|
|
43140
|
+
var gitlab_1 = __nccwpck_require__(4997);
|
|
43141
|
+
var sbom_1 = __nccwpck_require__(5928);
|
|
43142
|
+
var cleanup_1 = __nccwpck_require__(964);
|
|
43143
|
+
var database_1 = __nccwpck_require__(1384);
|
|
43144
|
+
var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
|
|
43145
|
+
var cloudRunJobs_1 = __nccwpck_require__(6321);
|
|
43146
|
+
var cloudRunServices_1 = __nccwpck_require__(7210);
|
|
43147
|
+
var common_1 = __nccwpck_require__(5655);
|
|
43148
|
+
function getCloudRunDeployScripts(context) {
|
|
43149
|
+
var _a;
|
|
43150
|
+
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
43151
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gitlab_1.collapseableSection)("prepare", "Prepare...")(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read((0, common_1.setGoogleProjectNumberScript)(deployConfig)), false))), false), __read((0, gitlab_1.collapseableSection)("deploy", "Deploy to cloud run")(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(deployConfig.cloudSql ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
43152
|
+
: []), false), __read((0, cloudRunJobs_1.getCreateScheduleScripts)(context)), false), __read((0, cloudRunJobs_1.getJobCreateScripts)(context)), false), __read((0, cloudRunJobs_1.getJobRunScripts)(context, "preDeploy")), false), __read(deployConfig.service !== false ? [(0, cloudRunServices_1.getServiceDeployScript)(context, deployConfig.service)] : []), false), __read(Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
|
|
42938
43153
|
var _b = __read(_a, 2),
|
|
42939
43154
|
name = _b[0],
|
|
42940
43155
|
service = _b[1];
|
|
42941
|
-
return getServiceDeployScript(service, "-" + name);
|
|
42942
|
-
})), false), __read(getJobRunScripts("postDeploy")), false))), false), __read((0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy") // we cleanup inactive images both on deploy and stop
|
|
43156
|
+
return (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name);
|
|
43157
|
+
})), false), __read((0, cloudRunJobs_1.getJobRunScripts)(context, "postDeploy")), false))), false), __read((0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy") // we cleanup inactive images both on deploy and stop
|
|
42943
43158
|
)), false), __read((0, sbom_1.getDependencyTrackUploadScript)(context)), false);
|
|
42944
|
-
|
|
43159
|
+
}
|
|
43160
|
+
exports.getCloudRunDeployScripts = getCloudRunDeployScripts;
|
|
43161
|
+
|
|
43162
|
+
/***/ }),
|
|
43163
|
+
|
|
43164
|
+
/***/ 910:
|
|
43165
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
43166
|
+
|
|
43167
|
+
"use strict";
|
|
43168
|
+
|
|
43169
|
+
|
|
43170
|
+
var __read = this && this.__read || function (o, n) {
|
|
43171
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
43172
|
+
if (!m) return o;
|
|
43173
|
+
var i = m.call(o),
|
|
43174
|
+
r,
|
|
43175
|
+
ar = [],
|
|
43176
|
+
e;
|
|
43177
|
+
try {
|
|
43178
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43179
|
+
} catch (error) {
|
|
43180
|
+
e = {
|
|
43181
|
+
error: error
|
|
43182
|
+
};
|
|
43183
|
+
} finally {
|
|
43184
|
+
try {
|
|
43185
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
43186
|
+
} finally {
|
|
43187
|
+
if (e) throw e.error;
|
|
43188
|
+
}
|
|
43189
|
+
}
|
|
43190
|
+
return ar;
|
|
43191
|
+
};
|
|
43192
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
43193
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
43194
|
+
if (ar || !(i in from)) {
|
|
43195
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
43196
|
+
ar[i] = from[i];
|
|
43197
|
+
}
|
|
43198
|
+
}
|
|
43199
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
43200
|
+
};
|
|
43201
|
+
exports.__esModule = true;
|
|
43202
|
+
exports.getCloudRunStopScripts = void 0;
|
|
43203
|
+
var sbom_1 = __nccwpck_require__(5928);
|
|
43204
|
+
var cleanup_1 = __nccwpck_require__(964);
|
|
43205
|
+
var database_1 = __nccwpck_require__(1384);
|
|
43206
|
+
var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
|
|
43207
|
+
var cloudRunJobs_1 = __nccwpck_require__(6321);
|
|
43208
|
+
var cloudRunServices_1 = __nccwpck_require__(7210);
|
|
43209
|
+
var common_1 = __nccwpck_require__(5655);
|
|
43210
|
+
function getCloudRunStopScripts(context) {
|
|
43211
|
+
var _a;
|
|
43212
|
+
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
43213
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read((0, cloudRunJobs_1.getJobRunScripts)(context, "preStop")), false), __read(deployConfig.service !== false ? (0, cloudRunServices_1.getServiceDeleteScript)(context) : []), false), __read(Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).flatMap(function (_a) {
|
|
42945
43214
|
var _b = __read(_a, 1),
|
|
42946
43215
|
name = _b[0];
|
|
42947
|
-
return
|
|
42948
|
-
})), false), __read(getJobRunScripts("postStop")), false), __read(getDeleteSchedulesScripts()), false), __read(getDeleteJobsScripts()), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false), __read((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "onStop")), false), __read((0, sbom_1.getDependencyTrackDeleteScript)(context)), false);
|
|
43216
|
+
return (0, cloudRunServices_1.getServiceDeleteScript)(context, name);
|
|
43217
|
+
})), false), __read((0, cloudRunJobs_1.getJobRunScripts)(context, "postStop")), false), __read((0, cloudRunJobs_1.getDeleteSchedulesScripts)(context)), false), __read((0, cloudRunJobs_1.getDeleteJobsScripts)(context)), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false), __read((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "onStop")), false), __read((0, sbom_1.getDependencyTrackDeleteScript)(context)), false);
|
|
43218
|
+
}
|
|
43219
|
+
exports.getCloudRunStopScripts = getCloudRunStopScripts;
|
|
43220
|
+
|
|
43221
|
+
/***/ }),
|
|
43222
|
+
|
|
43223
|
+
/***/ 6474:
|
|
43224
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
43225
|
+
|
|
43226
|
+
"use strict";
|
|
43227
|
+
|
|
43228
|
+
|
|
43229
|
+
exports.__esModule = true;
|
|
43230
|
+
exports.createGoogleCloudRunDeployJobs = void 0;
|
|
43231
|
+
var lodash_1 = __nccwpck_require__(3255);
|
|
43232
|
+
var docker_1 = __nccwpck_require__(3219);
|
|
43233
|
+
var runner_1 = __nccwpck_require__(5071);
|
|
43234
|
+
var gitlab_1 = __nccwpck_require__(4997);
|
|
43235
|
+
var base_1 = __nccwpck_require__(2866);
|
|
43236
|
+
var types_1 = __nccwpck_require__(3109);
|
|
43237
|
+
var variables_1 = __nccwpck_require__(408);
|
|
43238
|
+
var getCloudRunDeployScripts_1 = __nccwpck_require__(1944);
|
|
43239
|
+
var getCloudRunStopScripts_1 = __nccwpck_require__(910);
|
|
43240
|
+
var createGoogleCloudRunDeployJobs = function (context) {
|
|
43241
|
+
var deployConfig = context.componentConfig.deploy;
|
|
43242
|
+
if (deployConfig === false) {
|
|
43243
|
+
return [];
|
|
43244
|
+
}
|
|
43245
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
43246
|
+
// should not happen
|
|
43247
|
+
throw new Error("deploy config is wrong");
|
|
43248
|
+
}
|
|
43249
|
+
var deployScripts = (0, getCloudRunDeployScripts_1.getCloudRunDeployScripts)(context);
|
|
43250
|
+
var stopScripts = (0, getCloudRunStopScripts_1.getCloudRunStopScripts)(context);
|
|
42949
43251
|
return (0, base_1.createDeployementJobs)(context, {
|
|
42950
43252
|
deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
|
|
42951
43253
|
artifacts: {
|
|
42952
43254
|
paths: ["____envvars.yaml"]
|
|
42953
43255
|
},
|
|
42954
|
-
variables:
|
|
42955
|
-
CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
|
|
42956
|
-
ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
|
|
42957
|
-
lineWidth: -1,
|
|
42958
|
-
quotingType: "'",
|
|
42959
|
-
forceQuotes: true
|
|
42960
|
-
})
|
|
42961
|
-
},
|
|
43256
|
+
variables: (0, variables_1.getDeployJobVariables)(context),
|
|
42962
43257
|
image: (0, runner_1.getRunnerImage)("gcloud"),
|
|
42963
43258
|
script: deployScripts
|
|
42964
43259
|
}),
|
|
@@ -42975,6 +43270,32 @@ exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
|
|
|
42975
43270
|
|
|
42976
43271
|
/***/ }),
|
|
42977
43272
|
|
|
43273
|
+
/***/ 408:
|
|
43274
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
43275
|
+
|
|
43276
|
+
"use strict";
|
|
43277
|
+
|
|
43278
|
+
|
|
43279
|
+
exports.__esModule = true;
|
|
43280
|
+
exports.getDeployJobVariables = void 0;
|
|
43281
|
+
var js_yaml_1 = __nccwpck_require__(3618);
|
|
43282
|
+
var lodash_1 = __nccwpck_require__(3255);
|
|
43283
|
+
var __1 = __nccwpck_require__(5355);
|
|
43284
|
+
function getDeployJobVariables(context) {
|
|
43285
|
+
var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, __1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
|
|
43286
|
+
return {
|
|
43287
|
+
CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
|
|
43288
|
+
ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
|
|
43289
|
+
lineWidth: -1,
|
|
43290
|
+
quotingType: "'",
|
|
43291
|
+
forceQuotes: true
|
|
43292
|
+
})
|
|
43293
|
+
};
|
|
43294
|
+
}
|
|
43295
|
+
exports.getDeployJobVariables = getDeployJobVariables;
|
|
43296
|
+
|
|
43297
|
+
/***/ }),
|
|
43298
|
+
|
|
42978
43299
|
/***/ 1344:
|
|
42979
43300
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
42980
43301
|
|
|
@@ -43027,7 +43348,7 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = expo
|
|
|
43027
43348
|
var context_1 = __nccwpck_require__(2041);
|
|
43028
43349
|
var gitlab_1 = __nccwpck_require__(4997);
|
|
43029
43350
|
var utils_1 = __nccwpck_require__(463);
|
|
43030
|
-
var
|
|
43351
|
+
var createJobs_1 = __nccwpck_require__(6474);
|
|
43031
43352
|
var jobName_1 = __nccwpck_require__(7311);
|
|
43032
43353
|
exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
|
|
43033
43354
|
// FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
|
|
@@ -43059,7 +43380,7 @@ var getCloudSqlVariables = function (_a) {
|
|
|
43059
43380
|
return {};
|
|
43060
43381
|
};
|
|
43061
43382
|
exports.GCLOUD_RUN_DEPLOY_TYPE = {
|
|
43062
|
-
jobs:
|
|
43383
|
+
jobs: createJobs_1.createGoogleCloudRunDeployJobs,
|
|
43063
43384
|
defaults: function (_a) {
|
|
43064
43385
|
var deployConfigRaw = _a.deployConfigRaw,
|
|
43065
43386
|
envType = _a.envType;
|
|
@@ -43145,22 +43466,28 @@ var lodash_1 = __nccwpck_require__(3255);
|
|
|
43145
43466
|
* @param args args record
|
|
43146
43467
|
* @returns
|
|
43147
43468
|
*/
|
|
43148
|
-
var createArgsString = function (
|
|
43149
|
-
|
|
43150
|
-
|
|
43151
|
-
|
|
43152
|
-
|
|
43153
|
-
|
|
43154
|
-
|
|
43155
|
-
|
|
43156
|
-
|
|
43157
|
-
|
|
43158
|
-
|
|
43159
|
-
|
|
43160
|
-
|
|
43161
|
-
|
|
43162
|
-
|
|
43163
|
-
|
|
43469
|
+
var createArgsString = function () {
|
|
43470
|
+
var args = [];
|
|
43471
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
43472
|
+
args[_i] = arguments[_i];
|
|
43473
|
+
}
|
|
43474
|
+
return args.map(function (argObj) {
|
|
43475
|
+
return Object.entries(argObj).filter(function (_a) {
|
|
43476
|
+
var _b = __read(_a, 2),
|
|
43477
|
+
value = _b[1];
|
|
43478
|
+
return !(0, lodash_1.isNil)(value);
|
|
43479
|
+
}).map(function (_a) {
|
|
43480
|
+
var _b = __read(_a, 2),
|
|
43481
|
+
key = _b[0],
|
|
43482
|
+
value = _b[1];
|
|
43483
|
+
if (value === true) {
|
|
43484
|
+
return "--".concat(key);
|
|
43485
|
+
} else if (value === false) {
|
|
43486
|
+
return "--no-".concat(key);
|
|
43487
|
+
}
|
|
43488
|
+
return "--".concat(key, "=").concat(value);
|
|
43489
|
+
});
|
|
43490
|
+
}).flat().join(" ");
|
|
43164
43491
|
};
|
|
43165
43492
|
exports.createArgsString = createArgsString;
|
|
43166
43493
|
|