@catladder/cli 0.0.0-main-c78c1d06 → 0.0.0-main-2d11ff72

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.
@@ -40920,7 +40920,7 @@ exports.readConfigSync = readConfigSync;
40920
40920
 
40921
40921
  exports.__esModule = true;
40922
40922
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
40923
- exports.PIPELINE_IMAGE_TAG = "main-c78c1d06" || 0;
40923
+ exports.PIPELINE_IMAGE_TAG = "main-2d11ff72" || 0;
40924
40924
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
40925
40925
 
40926
40926
  /***/ }),
@@ -42707,7 +42707,7 @@ exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
42707
42707
 
42708
42708
  /***/ }),
42709
42709
 
42710
- /***/ 2256:
42710
+ /***/ 6321:
42711
42711
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
42712
42712
 
42713
42713
  "use strict";
@@ -42755,27 +42755,261 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
42755
42755
  return to.concat(ar || Array.prototype.slice.call(from));
42756
42756
  };
42757
42757
  exports.__esModule = true;
42758
- exports.createGoogleCloudRunDeployJobs = void 0;
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);
42758
+ exports.getCreateScheduleScripts = exports.getJobCreateScripts = exports.getJobRunScripts = exports.getDeleteJobsScripts = exports.getDeleteSchedulesScripts = void 0;
42765
42759
  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
42760
  var createArgsString_1 = __nccwpck_require__(8686);
42770
- var database_1 = __nccwpck_require__(1384);
42771
- var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
42772
42761
  var jobName_1 = __nccwpck_require__(7311);
42773
- var artifactsRegistry_1 = __nccwpck_require__(8159);
42762
+ var common_1 = __nccwpck_require__(5655);
42763
+ var getLabels_1 = __nccwpck_require__(486);
42764
+ var getJobRunScriptForJob = function (context, jobName, wait) {
42765
+ var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
42766
+ var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
42767
+ return "".concat((0, common_1.gcloudRunCmd)("beta"), " jobs execute ").concat(jobName, " ").concat(commonArgsString).concat(wait ? " --wait" : "");
42768
+ };
42769
+ var getDeleteSchedulesScripts = function (context) {
42770
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
42771
+ var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
42772
+ var argsString = (0, createArgsString_1.createArgsString)({
42773
+ project: deployConfig.projectId,
42774
+ location: deployConfig.region
42775
+ });
42776
+ return jobsWithSchedule.map(function (_a) {
42777
+ var schedulerName = _a.schedulerName;
42778
+ return ["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs delete ").concat(schedulerName, " ").concat(argsString)];
42779
+ }).flat();
42780
+ };
42781
+ exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
42782
+ var getDeleteJobsScripts = function (context) {
42783
+ var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
42784
+ var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
42785
+ var jobsWithNames = getCloudRunJobsWithNames(context);
42786
+ return jobsWithNames.flatMap(function (_a) {
42787
+ var jobName = _a.jobName;
42788
+ return [
42789
+ // first delete all job executions. Otherwise delete might fail if one of those is still running
42790
+ "".concat((0, common_1.gcloudRunCmd)("beta"), " jobs executions list ").concat(commonArgsString, " --job ").concat(jobName, " --format=\"value(name)\" | xargs -I {} ").concat((0, common_1.gcloudRunCmd)("beta"), " jobs executions delete {} --quiet ").concat(commonArgsString), "".concat((0, common_1.gcloudRunCmd)("beta"), " jobs delete ").concat(jobName, " ").concat(commonArgsString)];
42791
+ });
42792
+ };
42793
+ exports.getDeleteJobsScripts = getDeleteJobsScripts;
42794
+ var getJobRunScripts = function (context, when) {
42795
+ var jobsWithNames = getCloudRunJobsWithNames(context);
42796
+ return jobsWithNames.filter(function (_a) {
42797
+ var job = _a.job;
42798
+ return job.when === when;
42799
+ }).map(function (_a) {
42800
+ var jobName = _a.jobName;
42801
+ return getJobRunScriptForJob(context, jobName,
42802
+ // wait for completin on stop jobs, since stop will delete the jobs afterwards, so they will fail
42803
+ ["preStop", "postStop"].includes(when));
42804
+ });
42805
+ };
42806
+ exports.getJobRunScripts = getJobRunScripts;
42807
+ var getJobCreateScripts = function (context) {
42808
+ var jobsWithNames = getCloudRunJobsWithNames(context);
42809
+ return jobsWithNames.map(function (_a) {
42810
+ var job = _a.job,
42811
+ jobName = _a.jobName;
42812
+ return getJobCreateScriptsForJob(context, jobName, job);
42813
+ }).flat();
42814
+ };
42815
+ exports.getJobCreateScripts = getJobCreateScripts;
42816
+ var getJobCreateScriptsForJob = function (context, jobName, job) {
42817
+ var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
42818
+ // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
42819
+ // lucky, update on the other hand accepts it... so let's just imediatly update it
42820
+ // also we cannot upsert a job, so we have to create it and catch the error and then update
42821
+ var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
42822
+ var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
42823
+ command: '"' + commandArray.join(",") + '"'
42824
+ }, commonDeployArgs), {
42825
+ labels: (0, common_1.makeLabelString)(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
42826
+ "cloud-run-job-name": jobName
42827
+ })),
42828
+ image: job.image || commonDeployArgs.image,
42829
+ memory: job.memory || "512Mi",
42830
+ "task-timeout": job.timeout || "10m"
42831
+ }));
42832
+ var argsString = "".concat(jobName, " ").concat(commonDeployArgsString);
42833
+ return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["".concat((0, common_1.gcloudRunCmd)("beta"), " jobs create ").concat(argsString)])), false), ["".concat((0, common_1.gcloudRunCmd)("beta"), " jobs update ").concat(argsString, " --env-vars-file=____envvars.yaml")], false);
42834
+ };
42835
+ var getCreateScheduleScripts = function (context) {
42836
+ var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
42837
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
42838
+ return jobsWithSchedule.map(function (_a) {
42839
+ var _b;
42840
+ var job = _a.job,
42841
+ jobName = _a.jobName,
42842
+ schedulerName = _a.schedulerName;
42843
+ var argsString = (0, createArgsString_1.createArgsString)({
42844
+ project: deployConfig.projectId,
42845
+ location: deployConfig.region,
42846
+ schedule: "\"".concat(job.schedule, "\""),
42847
+ "max-retry-attempts": (_b = job.maxRetryAttempts) !== null && _b !== void 0 ? _b : 0,
42848
+ uri: "\"https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(jobName, ":run\""),
42849
+ "http-method": "POST",
42850
+ "oauth-service-account-email": "$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"
42851
+ });
42852
+ var commonArgs = "http ".concat(schedulerName, " ").concat(argsString);
42853
+ 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);
42854
+ }).flat();
42855
+ };
42856
+ exports.getCreateScheduleScripts = getCreateScheduleScripts;
42857
+ var getCloudRunJobsWithSchedule = function (context) {
42858
+ var jobsWithNames = getCloudRunJobsWithNames(context);
42859
+ return jobsWithNames.filter(function (entry) {
42860
+ return entry.job.when === "schedule";
42861
+ }).map(function (_a) {
42862
+ var job = _a.job,
42863
+ jobName = _a.jobName;
42864
+ return {
42865
+ job: job,
42866
+ jobName: jobName,
42867
+ schedulerName: jobName + "-scheduler"
42868
+ };
42869
+ });
42870
+ };
42871
+ var getCloudRunJobsWithNames = function (context) {
42872
+ var _a;
42873
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
42874
+ var getFullJobName = function (name) {
42875
+ return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
42876
+ };
42877
+ var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
42878
+ // filter out disabled jobs
42879
+ .filter(function (entry) {
42880
+ return Boolean(entry[1]);
42881
+ }).map(function (_a) {
42882
+ var _b = __read(_a, 2),
42883
+ name = _b[0],
42884
+ job = _b[1];
42885
+ return {
42886
+ jobName: getFullJobName(name),
42887
+ job: job
42888
+ };
42889
+ });
42890
+ return jobsWithNames;
42891
+ };
42892
+
42893
+ /***/ }),
42894
+
42895
+ /***/ 7210:
42896
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
42897
+
42898
+ "use strict";
42899
+
42900
+
42901
+ var __assign = this && this.__assign || function () {
42902
+ __assign = Object.assign || function (t) {
42903
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
42904
+ s = arguments[i];
42905
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
42906
+ }
42907
+ return t;
42908
+ };
42909
+ return __assign.apply(this, arguments);
42910
+ };
42911
+ exports.__esModule = true;
42912
+ exports.getServiceDeleteScript = exports.getServiceDeployScript = void 0;
42913
+ var getLabels_1 = __nccwpck_require__(486);
42914
+ var createArgsString_1 = __nccwpck_require__(8686);
42774
42915
  var getServiceName_1 = __nccwpck_require__(9391);
42775
- var cleanup_1 = __nccwpck_require__(964);
42916
+ var common_1 = __nccwpck_require__(5655);
42917
+ var getServiceDeployScript = function (context, service, nameSuffix) {
42918
+ var _a, _b, _c, _d, _e;
42919
+ var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
42920
+ var serviceName = (0, getServiceName_1.getServiceName)(context);
42921
+ var customConfig = service !== true ? service : undefined;
42922
+ var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
42923
+ var commandArray = command ? Array.isArray(command) ? command : command.split(" ") : undefined;
42924
+ var fullServiceName = "".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "");
42925
+ var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
42926
+ // command as empty string resets it to default (uses the image's entrypoint)
42927
+ command: commandArray ? '"' + commandArray.join(",") + '"' : '""'
42928
+ }, commonDeployArgs), {
42929
+ labels: (0, common_1.makeLabelString)(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
42930
+ "cloud-run-service-name": fullServiceName
42931
+ })),
42932
+ "env-vars-file": "____envvars.yaml",
42933
+ "min-instances": (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _b !== void 0 ? _b : 0,
42934
+ "max-instances": (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances) !== null && _c !== void 0 ? _c : 100,
42935
+ "cpu-throttling": (customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling) !== true,
42936
+ memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
42937
+ "allow-unauthenticated": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _d !== void 0 ? _d : true,
42938
+ ingress: (_e = customConfig === null || customConfig === void 0 ? void 0 : customConfig.ingress) !== null && _e !== void 0 ? _e : "all",
42939
+ "cpu-boost": true
42940
+ }));
42941
+ return "".concat((0, common_1.gcloudRunCmd)(), " deploy ").concat(fullServiceName, " ").concat(argsString);
42942
+ };
42943
+ exports.getServiceDeployScript = getServiceDeployScript;
42944
+ var getServiceDeleteScript = function (context, serviceSuffix) {
42945
+ var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
42946
+ var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
42947
+ var serviceName = (0, getServiceName_1.getServiceName)(context);
42948
+ var fullServiceName = serviceSuffix ? "".concat(serviceName, "-").concat(serviceSuffix) : serviceName;
42949
+ return ["".concat((0, common_1.gcloudRunCmd)(), " services delete ").concat(fullServiceName, " ").concat(commonArgsString)];
42950
+ };
42951
+ exports.getServiceDeleteScript = getServiceDeleteScript;
42952
+
42953
+ /***/ }),
42954
+
42955
+ /***/ 5655:
42956
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
42957
+
42958
+ "use strict";
42959
+
42960
+
42961
+ var __assign = this && this.__assign || function () {
42962
+ __assign = Object.assign || function (t) {
42963
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
42964
+ s = arguments[i];
42965
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
42966
+ }
42967
+ return t;
42968
+ };
42969
+ return __assign.apply(this, arguments);
42970
+ };
42971
+ var __read = this && this.__read || function (o, n) {
42972
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
42973
+ if (!m) return o;
42974
+ var i = m.call(o),
42975
+ r,
42976
+ ar = [],
42977
+ e;
42978
+ try {
42979
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
42980
+ } catch (error) {
42981
+ e = {
42982
+ error: error
42983
+ };
42984
+ } finally {
42985
+ try {
42986
+ if (r && !r.done && (m = i["return"])) m.call(i);
42987
+ } finally {
42988
+ if (e) throw e.error;
42989
+ }
42990
+ }
42991
+ return ar;
42992
+ };
42993
+ exports.__esModule = true;
42994
+ exports.getCommonDeployArgs = exports.getCommonCloudRunArgs = exports.getCloudRunDeployConfig = exports.makeLabelString = exports.setGoogleProjectNumberScript = exports.gcloudSchedulerCmd = exports.gcloudRunCmd = exports.gcloudCmd = void 0;
42995
+ var types_1 = __nccwpck_require__(3109);
42996
+ var artifactsRegistry_1 = __nccwpck_require__(8159);
42997
+ var gcloudCmd = function (version) {
42998
+ return version ? "gcloud ".concat(version) : "gcloud";
42999
+ };
43000
+ exports.gcloudCmd = gcloudCmd;
43001
+ var gcloudRunCmd = function (version) {
43002
+ return "".concat((0, exports.gcloudCmd)(version), " run");
43003
+ };
43004
+ exports.gcloudRunCmd = gcloudRunCmd;
43005
+ var gcloudSchedulerCmd = function (version) {
43006
+ return "".concat((0, exports.gcloudCmd)(version), " scheduler");
43007
+ };
43008
+ exports.gcloudSchedulerCmd = gcloudSchedulerCmd;
42776
43009
  var setGoogleProjectNumberScript = function (deployConfig) {
42777
- return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
43010
+ 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
43011
  };
43012
+ exports.setGoogleProjectNumberScript = setGoogleProjectNumberScript;
42779
43013
  var makeLabelString = function (obj) {
42780
43014
  return Object.entries(obj).map(function (_a) {
42781
43015
  var _b = __read(_a, 2),
@@ -42784,181 +43018,193 @@ var makeLabelString = function (obj) {
42784
43018
  return "".concat(key, "=").concat(value);
42785
43019
  }).join(",");
42786
43020
  };
42787
- var createGoogleCloudRunDeployJobs = function (context) {
42788
- var _a, _b, _c;
43021
+ exports.makeLabelString = makeLabelString;
43022
+ var getCloudRunDeployConfig = function (context) {
42789
43023
  var deployConfig = context.componentConfig.deploy;
42790
- if (deployConfig === false) {
42791
- return [];
42792
- }
42793
43024
  if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
42794
43025
  // should not happen
42795
43026
  throw new Error("deploy config is wrong");
42796
43027
  }
42797
- var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
42798
- var commonArgs = {
43028
+ return deployConfig;
43029
+ };
43030
+ exports.getCloudRunDeployConfig = getCloudRunDeployConfig;
43031
+ function getCommonCloudRunArgs(context) {
43032
+ var deployConfig = (0, exports.getCloudRunDeployConfig)(context);
43033
+ return {
42799
43034
  project: deployConfig.projectId,
42800
43035
  region: deployConfig.region
42801
43036
  };
42802
- var commonDeployArgs = __assign(__assign({
43037
+ }
43038
+ exports.getCommonCloudRunArgs = getCommonCloudRunArgs;
43039
+ function getCommonDeployArgs(context) {
43040
+ var commonArgs = getCommonCloudRunArgs(context);
43041
+ var deployConfig = (0, exports.getCloudRunDeployConfig)(context);
43042
+ return __assign(__assign({
42803
43043
  image: (0, artifactsRegistry_1.getArtifactsRegistryImage)(context)
42804
43044
  }, commonArgs), {
42805
43045
  "set-cloudsql-instances": deployConfig.cloudSql ? deployConfig.cloudSql.instanceConnectionName : undefined
42806
43046
  });
42807
- var serviceName = (0, getServiceName_1.getServiceName)(context);
42808
- var getFullJobName = function (name) {
42809
- return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
42810
- };
42811
- var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
42812
- // filter out disabled jobs
42813
- .filter(function (entry) {
42814
- return Boolean(entry[1]);
42815
- }).map(function (_a) {
42816
- var _b = __read(_a, 2),
42817
- name = _b[0],
42818
- job = _b[1];
42819
- return {
42820
- jobName: getFullJobName(name),
42821
- job: job
42822
- };
42823
- });
42824
- var jobsWithSchedule = jobsWithNames.filter(function (entry) {
42825
- return entry.job.when === "schedule";
42826
- }).map(function (_a) {
42827
- var job = _a.job,
42828
- jobName = _a.jobName;
42829
- return {
42830
- job: job,
42831
- jobName: jobName,
42832
- schedulerName: jobName + "-scheduler"
43047
+ }
43048
+ exports.getCommonDeployArgs = getCommonDeployArgs;
43049
+
43050
+ /***/ }),
43051
+
43052
+ /***/ 1944:
43053
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43054
+
43055
+ "use strict";
43056
+
43057
+
43058
+ var __read = this && this.__read || function (o, n) {
43059
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
43060
+ if (!m) return o;
43061
+ var i = m.call(o),
43062
+ r,
43063
+ ar = [],
43064
+ e;
43065
+ try {
43066
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
43067
+ } catch (error) {
43068
+ e = {
43069
+ error: error
42833
43070
  };
42834
- });
42835
- var getServiceDeployScript = function (service, nameSuffix) {
42836
- var _a, _b, _c, _d, _e;
42837
- var customConfig = service !== true ? service : undefined;
42838
- var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
42839
- var commandArray = command ? Array.isArray(command) ? command : command.split(" ") : undefined;
42840
- var fullServiceName = "".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "");
42841
- var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
42842
- // command as empty string resets it to default (uses the image's entrypoint)
42843
- command: commandArray ? '"' + commandArray.join(",") + '"' : '""'
42844
- }, commonDeployArgs), {
42845
- labels: makeLabelString(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
42846
- "cloud-run-service-name": fullServiceName
42847
- })),
42848
- "env-vars-file": "____envvars.yaml",
42849
- "min-instances": (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _b !== void 0 ? _b : 0,
42850
- "max-instances": (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances) !== null && _c !== void 0 ? _c : 100,
42851
- "cpu-throttling": (customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling) !== true,
42852
- memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
42853
- "allow-unauthenticated": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _d !== void 0 ? _d : true,
42854
- ingress: (_e = customConfig === null || customConfig === void 0 ? void 0 : customConfig.ingress) !== null && _e !== void 0 ? _e : "all",
42855
- "cpu-boost": true
42856
- }));
42857
- return "gcloud run deploy ".concat(fullServiceName, " ").concat(argsString);
42858
- };
42859
- var getJobCreateScriptsForJob = function (jobName, job) {
42860
- // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
42861
- // lucky, update on the other hand accepts it... so let's just imediatly update it
42862
- // also we cannot upsert a job, so we have to create it and catch the error and then update
42863
- var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
42864
- var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
42865
- command: '"' + commandArray.join(",") + '"'
42866
- }, commonDeployArgs), {
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) {
43071
+ } finally {
43072
+ try {
43073
+ if (r && !r.done && (m = i["return"])) m.call(i);
43074
+ } finally {
43075
+ if (e) throw e.error;
43076
+ }
43077
+ }
43078
+ return ar;
43079
+ };
43080
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43081
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
43082
+ if (ar || !(i in from)) {
43083
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
43084
+ ar[i] = from[i];
43085
+ }
43086
+ }
43087
+ return to.concat(ar || Array.prototype.slice.call(from));
43088
+ };
43089
+ exports.__esModule = true;
43090
+ exports.getCloudRunDeployScripts = void 0;
43091
+ var gitlab_1 = __nccwpck_require__(4997);
43092
+ var sbom_1 = __nccwpck_require__(5928);
43093
+ var cleanup_1 = __nccwpck_require__(964);
43094
+ var database_1 = __nccwpck_require__(1384);
43095
+ var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
43096
+ var cloudRunJobs_1 = __nccwpck_require__(6321);
43097
+ var cloudRunServices_1 = __nccwpck_require__(7210);
43098
+ var common_1 = __nccwpck_require__(5655);
43099
+ function getCloudRunDeployScripts(context) {
43100
+ var _a;
43101
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
43102
+ 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
43103
+ : []), 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
43104
  var _b = __read(_a, 2),
42939
43105
  name = _b[0],
42940
43106
  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
43107
+ return (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name);
43108
+ })), 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
43109
  )), false), __read((0, sbom_1.getDependencyTrackUploadScript)(context)), false);
42944
- var stopScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(getJobRunScripts("preStop")), false), __read(deployConfig.service !== false ? ["gcloud run services delete ".concat(serviceName, " ").concat(commonArgsString)] : []), false), __read(Object.entries((_c = deployConfig.additionalServices) !== null && _c !== void 0 ? _c : {}).map(function (_a) {
43110
+ }
43111
+ exports.getCloudRunDeployScripts = getCloudRunDeployScripts;
43112
+
43113
+ /***/ }),
43114
+
43115
+ /***/ 910:
43116
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43117
+
43118
+ "use strict";
43119
+
43120
+
43121
+ var __read = this && this.__read || function (o, n) {
43122
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
43123
+ if (!m) return o;
43124
+ var i = m.call(o),
43125
+ r,
43126
+ ar = [],
43127
+ e;
43128
+ try {
43129
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
43130
+ } catch (error) {
43131
+ e = {
43132
+ error: error
43133
+ };
43134
+ } finally {
43135
+ try {
43136
+ if (r && !r.done && (m = i["return"])) m.call(i);
43137
+ } finally {
43138
+ if (e) throw e.error;
43139
+ }
43140
+ }
43141
+ return ar;
43142
+ };
43143
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43144
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
43145
+ if (ar || !(i in from)) {
43146
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
43147
+ ar[i] = from[i];
43148
+ }
43149
+ }
43150
+ return to.concat(ar || Array.prototype.slice.call(from));
43151
+ };
43152
+ exports.__esModule = true;
43153
+ exports.getCloudRunStopScripts = void 0;
43154
+ var sbom_1 = __nccwpck_require__(5928);
43155
+ var cleanup_1 = __nccwpck_require__(964);
43156
+ var database_1 = __nccwpck_require__(1384);
43157
+ var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
43158
+ var cloudRunJobs_1 = __nccwpck_require__(6321);
43159
+ var cloudRunServices_1 = __nccwpck_require__(7210);
43160
+ var common_1 = __nccwpck_require__(5655);
43161
+ function getCloudRunStopScripts(context) {
43162
+ var _a;
43163
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
43164
+ 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
43165
  var _b = __read(_a, 1),
42946
43166
  name = _b[0];
42947
- return "gcloud run services delete ".concat(serviceName, "-").concat(name, " ").concat(commonArgsString);
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);
43167
+ return (0, cloudRunServices_1.getServiceDeleteScript)(context, name);
43168
+ })), 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);
43169
+ }
43170
+ exports.getCloudRunStopScripts = getCloudRunStopScripts;
43171
+
43172
+ /***/ }),
43173
+
43174
+ /***/ 6474:
43175
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
43176
+
43177
+ "use strict";
43178
+
43179
+
43180
+ exports.__esModule = true;
43181
+ exports.createGoogleCloudRunDeployJobs = void 0;
43182
+ var lodash_1 = __nccwpck_require__(3255);
43183
+ var docker_1 = __nccwpck_require__(3219);
43184
+ var runner_1 = __nccwpck_require__(5071);
43185
+ var gitlab_1 = __nccwpck_require__(4997);
43186
+ var base_1 = __nccwpck_require__(2866);
43187
+ var types_1 = __nccwpck_require__(3109);
43188
+ var variables_1 = __nccwpck_require__(408);
43189
+ var getCloudRunDeployScripts_1 = __nccwpck_require__(1944);
43190
+ var getCloudRunStopScripts_1 = __nccwpck_require__(910);
43191
+ var createGoogleCloudRunDeployJobs = function (context) {
43192
+ var deployConfig = context.componentConfig.deploy;
43193
+ if (deployConfig === false) {
43194
+ return [];
43195
+ }
43196
+ if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
43197
+ // should not happen
43198
+ throw new Error("deploy config is wrong");
43199
+ }
43200
+ var deployScripts = (0, getCloudRunDeployScripts_1.getCloudRunDeployScripts)(context);
43201
+ var stopScripts = (0, getCloudRunStopScripts_1.getCloudRunStopScripts)(context);
42949
43202
  return (0, base_1.createDeployementJobs)(context, {
42950
43203
  deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
42951
43204
  artifacts: {
42952
43205
  paths: ["____envvars.yaml"]
42953
43206
  },
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
- },
43207
+ variables: (0, variables_1.getDeployJobVariables)(context),
42962
43208
  image: (0, runner_1.getRunnerImage)("gcloud"),
42963
43209
  script: deployScripts
42964
43210
  }),
@@ -42975,6 +43221,32 @@ exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
42975
43221
 
42976
43222
  /***/ }),
42977
43223
 
43224
+ /***/ 408:
43225
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
43226
+
43227
+ "use strict";
43228
+
43229
+
43230
+ exports.__esModule = true;
43231
+ exports.getDeployJobVariables = void 0;
43232
+ var js_yaml_1 = __nccwpck_require__(3618);
43233
+ var lodash_1 = __nccwpck_require__(3255);
43234
+ var __1 = __nccwpck_require__(5355);
43235
+ function getDeployJobVariables(context) {
43236
+ var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, __1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
43237
+ return {
43238
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
43239
+ ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
43240
+ lineWidth: -1,
43241
+ quotingType: "'",
43242
+ forceQuotes: true
43243
+ })
43244
+ };
43245
+ }
43246
+ exports.getDeployJobVariables = getDeployJobVariables;
43247
+
43248
+ /***/ }),
43249
+
42978
43250
  /***/ 1344:
42979
43251
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
42980
43252
 
@@ -43027,7 +43299,7 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = expo
43027
43299
  var context_1 = __nccwpck_require__(2041);
43028
43300
  var gitlab_1 = __nccwpck_require__(4997);
43029
43301
  var utils_1 = __nccwpck_require__(463);
43030
- var deployJob_1 = __nccwpck_require__(2256);
43302
+ var createJobs_1 = __nccwpck_require__(6474);
43031
43303
  var jobName_1 = __nccwpck_require__(7311);
43032
43304
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
43033
43305
  // FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
@@ -43059,7 +43331,7 @@ var getCloudSqlVariables = function (_a) {
43059
43331
  return {};
43060
43332
  };
43061
43333
  exports.GCLOUD_RUN_DEPLOY_TYPE = {
43062
- jobs: deployJob_1.createGoogleCloudRunDeployJobs,
43334
+ jobs: createJobs_1.createGoogleCloudRunDeployJobs,
43063
43335
  defaults: function (_a) {
43064
43336
  var deployConfigRaw = _a.deployConfigRaw,
43065
43337
  envType = _a.envType;