@catladder/cli 0.0.0-refactor-gcloud-auth-no-file-7a9a76ea → 0.0.0-refactor-cloud-run-825d7e86

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 = "refactor-gcloud-auth-no-file-7a9a76ea" || 0;
40923
+ exports.PIPELINE_IMAGE_TAG = "refactor-cloud-run-825d7e86" || 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,249 @@ 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 "gcloud beta run 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 ["gcloud scheduler 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
+ "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)];
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)(["gcloud beta run jobs create ".concat(argsString)])), false), ["gcloud beta run 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)(["gcloud scheduler jobs create ".concat(commonArgs)])), false), ["gcloud scheduler 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 "gcloud run 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 ["gcloud run 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 = void 0;
42995
+ var types_1 = __nccwpck_require__(3109);
42996
+ var artifactsRegistry_1 = __nccwpck_require__(8159);
42776
42997
  var setGoogleProjectNumberScript = function (deployConfig) {
42777
42998
  return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
42778
42999
  };
43000
+ exports.setGoogleProjectNumberScript = setGoogleProjectNumberScript;
42779
43001
  var makeLabelString = function (obj) {
42780
43002
  return Object.entries(obj).map(function (_a) {
42781
43003
  var _b = __read(_a, 2),
@@ -42784,181 +43006,193 @@ var makeLabelString = function (obj) {
42784
43006
  return "".concat(key, "=").concat(value);
42785
43007
  }).join(",");
42786
43008
  };
42787
- var createGoogleCloudRunDeployJobs = function (context) {
42788
- var _a, _b, _c;
43009
+ exports.makeLabelString = makeLabelString;
43010
+ var getCloudRunDeployConfig = function (context) {
42789
43011
  var deployConfig = context.componentConfig.deploy;
42790
- if (deployConfig === false) {
42791
- return [];
42792
- }
42793
43012
  if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
42794
43013
  // should not happen
42795
43014
  throw new Error("deploy config is wrong");
42796
43015
  }
42797
- var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
42798
- var commonArgs = {
43016
+ return deployConfig;
43017
+ };
43018
+ exports.getCloudRunDeployConfig = getCloudRunDeployConfig;
43019
+ function getCommonCloudRunArgs(context) {
43020
+ var deployConfig = (0, exports.getCloudRunDeployConfig)(context);
43021
+ return {
42799
43022
  project: deployConfig.projectId,
42800
43023
  region: deployConfig.region
42801
43024
  };
42802
- var commonDeployArgs = __assign(__assign({
43025
+ }
43026
+ exports.getCommonCloudRunArgs = getCommonCloudRunArgs;
43027
+ function getCommonDeployArgs(context) {
43028
+ var commonArgs = getCommonCloudRunArgs(context);
43029
+ var deployConfig = (0, exports.getCloudRunDeployConfig)(context);
43030
+ return __assign(__assign({
42803
43031
  image: (0, artifactsRegistry_1.getArtifactsRegistryImage)(context)
42804
43032
  }, commonArgs), {
42805
43033
  "set-cloudsql-instances": deployConfig.cloudSql ? deployConfig.cloudSql.instanceConnectionName : undefined
42806
43034
  });
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"
43035
+ }
43036
+ exports.getCommonDeployArgs = getCommonDeployArgs;
43037
+
43038
+ /***/ }),
43039
+
43040
+ /***/ 1944:
43041
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43042
+
43043
+ "use strict";
43044
+
43045
+
43046
+ var __read = this && this.__read || function (o, n) {
43047
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
43048
+ if (!m) return o;
43049
+ var i = m.call(o),
43050
+ r,
43051
+ ar = [],
43052
+ e;
43053
+ try {
43054
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
43055
+ } catch (error) {
43056
+ e = {
43057
+ error: error
42833
43058
  };
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) {
43059
+ } finally {
43060
+ try {
43061
+ if (r && !r.done && (m = i["return"])) m.call(i);
43062
+ } finally {
43063
+ if (e) throw e.error;
43064
+ }
43065
+ }
43066
+ return ar;
43067
+ };
43068
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43069
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
43070
+ if (ar || !(i in from)) {
43071
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
43072
+ ar[i] = from[i];
43073
+ }
43074
+ }
43075
+ return to.concat(ar || Array.prototype.slice.call(from));
43076
+ };
43077
+ exports.__esModule = true;
43078
+ exports.getCloudRunDeployScripts = void 0;
43079
+ var gitlab_1 = __nccwpck_require__(4997);
43080
+ var sbom_1 = __nccwpck_require__(5928);
43081
+ var cleanup_1 = __nccwpck_require__(964);
43082
+ var database_1 = __nccwpck_require__(1384);
43083
+ var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
43084
+ var cloudRunJobs_1 = __nccwpck_require__(6321);
43085
+ var cloudRunServices_1 = __nccwpck_require__(7210);
43086
+ var common_1 = __nccwpck_require__(5655);
43087
+ function getCloudRunDeployScripts(context) {
43088
+ var _a;
43089
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
43090
+ 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
43091
+ : []), 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
43092
  var _b = __read(_a, 2),
42939
43093
  name = _b[0],
42940
43094
  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
43095
+ return (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name);
43096
+ })), 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
43097
  )), 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) {
43098
+ }
43099
+ exports.getCloudRunDeployScripts = getCloudRunDeployScripts;
43100
+
43101
+ /***/ }),
43102
+
43103
+ /***/ 910:
43104
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43105
+
43106
+ "use strict";
43107
+
43108
+
43109
+ var __read = this && this.__read || function (o, n) {
43110
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
43111
+ if (!m) return o;
43112
+ var i = m.call(o),
43113
+ r,
43114
+ ar = [],
43115
+ e;
43116
+ try {
43117
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
43118
+ } catch (error) {
43119
+ e = {
43120
+ error: error
43121
+ };
43122
+ } finally {
43123
+ try {
43124
+ if (r && !r.done && (m = i["return"])) m.call(i);
43125
+ } finally {
43126
+ if (e) throw e.error;
43127
+ }
43128
+ }
43129
+ return ar;
43130
+ };
43131
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43132
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
43133
+ if (ar || !(i in from)) {
43134
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
43135
+ ar[i] = from[i];
43136
+ }
43137
+ }
43138
+ return to.concat(ar || Array.prototype.slice.call(from));
43139
+ };
43140
+ exports.__esModule = true;
43141
+ exports.getCloudRunStopScripts = void 0;
43142
+ var sbom_1 = __nccwpck_require__(5928);
43143
+ var cleanup_1 = __nccwpck_require__(964);
43144
+ var database_1 = __nccwpck_require__(1384);
43145
+ var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
43146
+ var cloudRunJobs_1 = __nccwpck_require__(6321);
43147
+ var cloudRunServices_1 = __nccwpck_require__(7210);
43148
+ var common_1 = __nccwpck_require__(5655);
43149
+ function getCloudRunStopScripts(context) {
43150
+ var _a;
43151
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
43152
+ 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
43153
  var _b = __read(_a, 1),
42946
43154
  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);
43155
+ return (0, cloudRunServices_1.getServiceDeleteScript)(context, name);
43156
+ })), 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);
43157
+ }
43158
+ exports.getCloudRunStopScripts = getCloudRunStopScripts;
43159
+
43160
+ /***/ }),
43161
+
43162
+ /***/ 6474:
43163
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
43164
+
43165
+ "use strict";
43166
+
43167
+
43168
+ exports.__esModule = true;
43169
+ exports.createGoogleCloudRunDeployJobs = void 0;
43170
+ var lodash_1 = __nccwpck_require__(3255);
43171
+ var docker_1 = __nccwpck_require__(3219);
43172
+ var runner_1 = __nccwpck_require__(5071);
43173
+ var gitlab_1 = __nccwpck_require__(4997);
43174
+ var base_1 = __nccwpck_require__(2866);
43175
+ var types_1 = __nccwpck_require__(3109);
43176
+ var variables_1 = __nccwpck_require__(408);
43177
+ var getCloudRunDeployScripts_1 = __nccwpck_require__(1944);
43178
+ var getCloudRunStopScripts_1 = __nccwpck_require__(910);
43179
+ var createGoogleCloudRunDeployJobs = function (context) {
43180
+ var deployConfig = context.componentConfig.deploy;
43181
+ if (deployConfig === false) {
43182
+ return [];
43183
+ }
43184
+ if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
43185
+ // should not happen
43186
+ throw new Error("deploy config is wrong");
43187
+ }
43188
+ var deployScripts = (0, getCloudRunDeployScripts_1.getCloudRunDeployScripts)(context);
43189
+ var stopScripts = (0, getCloudRunStopScripts_1.getCloudRunStopScripts)(context);
42949
43190
  return (0, base_1.createDeployementJobs)(context, {
42950
43191
  deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
42951
43192
  artifacts: {
42952
43193
  paths: ["____envvars.yaml"]
42953
43194
  },
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
- },
43195
+ variables: (0, variables_1.getDeployJobVariables)(context),
42962
43196
  image: (0, runner_1.getRunnerImage)("gcloud"),
42963
43197
  script: deployScripts
42964
43198
  }),
@@ -42975,6 +43209,32 @@ exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
42975
43209
 
42976
43210
  /***/ }),
42977
43211
 
43212
+ /***/ 408:
43213
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
43214
+
43215
+ "use strict";
43216
+
43217
+
43218
+ exports.__esModule = true;
43219
+ exports.getDeployJobVariables = void 0;
43220
+ var js_yaml_1 = __nccwpck_require__(3618);
43221
+ var lodash_1 = __nccwpck_require__(3255);
43222
+ var __1 = __nccwpck_require__(5355);
43223
+ function getDeployJobVariables(context) {
43224
+ var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, __1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
43225
+ return {
43226
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
43227
+ ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
43228
+ lineWidth: -1,
43229
+ quotingType: "'",
43230
+ forceQuotes: true
43231
+ })
43232
+ };
43233
+ }
43234
+ exports.getDeployJobVariables = getDeployJobVariables;
43235
+
43236
+ /***/ }),
43237
+
42978
43238
  /***/ 1344:
42979
43239
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
42980
43240
 
@@ -43027,7 +43287,7 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = expo
43027
43287
  var context_1 = __nccwpck_require__(2041);
43028
43288
  var gitlab_1 = __nccwpck_require__(4997);
43029
43289
  var utils_1 = __nccwpck_require__(463);
43030
- var deployJob_1 = __nccwpck_require__(2256);
43290
+ var createJobs_1 = __nccwpck_require__(6474);
43031
43291
  var jobName_1 = __nccwpck_require__(7311);
43032
43292
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
43033
43293
  // FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
@@ -43059,7 +43319,7 @@ var getCloudSqlVariables = function (_a) {
43059
43319
  return {};
43060
43320
  };
43061
43321
  exports.GCLOUD_RUN_DEPLOY_TYPE = {
43062
- jobs: deployJob_1.createGoogleCloudRunDeployJobs,
43322
+ jobs: createJobs_1.createGoogleCloudRunDeployJobs,
43063
43323
  defaults: function (_a) {
43064
43324
  var deployConfigRaw = _a.deployConfigRaw,
43065
43325
  envType = _a.envType;