@catladder/cli 0.0.0-refactor-gcloud-auth-no-file-b43bf0d9 → 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.
@@ -7985,15 +7985,23 @@ var child_process_promise_1 = __nccwpck_require__(75763);
7985
7985
  var command_exists_promise_1 = __importDefault(__nccwpck_require__(80133));
7986
7986
  var cmd;
7987
7987
  exports["default"] = (function () { return __awaiter(void 0, void 0, void 0, function () {
7988
- return __generator(this, function (_a) {
7989
- switch (_a.label) {
7988
+ var _a;
7989
+ var _b, _c;
7990
+ return __generator(this, function (_d) {
7991
+ switch (_d.label) {
7990
7992
  case 0:
7991
- if (!!cmd) return [3 /*break*/, 2];
7992
- return [4 /*yield*/, (0, command_exists_promise_1["default"])("code")];
7993
- case 1:
7994
- cmd = (_a.sent()) ? "code --wait" : "vim";
7995
- _a.label = 2;
7996
- case 2: return [2 /*return*/, {
7993
+ if (!!cmd) return [3 /*break*/, 4];
7994
+ if (!((_c = (_b = process.env.VISUAL) !== null && _b !== void 0 ? _b : process.env.EDITOR) !== null && _c !== void 0)) return [3 /*break*/, 1];
7995
+ _a = _c;
7996
+ return [3 /*break*/, 3];
7997
+ case 1: return [4 /*yield*/, (0, command_exists_promise_1["default"])("code")];
7998
+ case 2:
7999
+ _a = ((_d.sent()) ? "code --wait" : "vim");
8000
+ _d.label = 3;
8001
+ case 3:
8002
+ cmd = _a;
8003
+ _d.label = 4;
8004
+ case 4: return [2 /*return*/, {
7997
8005
  open: function (path) { return __awaiter(void 0, void 0, void 0, function () {
7998
8006
  return __generator(this, function (_a) {
7999
8007
  switch (_a.label) {
@@ -355462,7 +355470,7 @@ exports.readConfigSync = readConfigSync;
355462
355470
 
355463
355471
  exports.__esModule = true;
355464
355472
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
355465
- exports.PIPELINE_IMAGE_TAG = "refactor-gcloud-auth-no-file-b43bf0d9" || 0;
355473
+ exports.PIPELINE_IMAGE_TAG = "refactor-cloud-run-825d7e86" || 0;
355466
355474
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
355467
355475
 
355468
355476
  /***/ }),
@@ -357249,7 +357257,7 @@ exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
357249
357257
 
357250
357258
  /***/ }),
357251
357259
 
357252
- /***/ 82256:
357260
+ /***/ 66321:
357253
357261
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
357254
357262
 
357255
357263
  "use strict";
@@ -357297,27 +357305,249 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
357297
357305
  return to.concat(ar || Array.prototype.slice.call(from));
357298
357306
  };
357299
357307
  exports.__esModule = true;
357300
- exports.createGoogleCloudRunDeployJobs = void 0;
357301
- var js_yaml_1 = __nccwpck_require__(3618);
357302
- var lodash_1 = __nccwpck_require__(23255);
357303
- var _1 = __nccwpck_require__(81344);
357304
- var docker_1 = __nccwpck_require__(33219);
357305
- var getLabels_1 = __nccwpck_require__(30486);
357306
- var runner_1 = __nccwpck_require__(55071);
357308
+ exports.getCreateScheduleScripts = exports.getJobCreateScripts = exports.getJobRunScripts = exports.getDeleteJobsScripts = exports.getDeleteSchedulesScripts = void 0;
357307
357309
  var gitlab_1 = __nccwpck_require__(84997);
357308
- var base_1 = __nccwpck_require__(82866);
357309
- var sbom_1 = __nccwpck_require__(65928);
357310
- var types_1 = __nccwpck_require__(63109);
357311
357310
  var createArgsString_1 = __nccwpck_require__(8686);
357312
- var database_1 = __nccwpck_require__(41384);
357313
- var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(22607);
357314
357311
  var jobName_1 = __nccwpck_require__(77311);
357315
- var artifactsRegistry_1 = __nccwpck_require__(28159);
357312
+ var common_1 = __nccwpck_require__(75655);
357313
+ var getLabels_1 = __nccwpck_require__(30486);
357314
+ var getJobRunScriptForJob = function (context, jobName, wait) {
357315
+ var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
357316
+ var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
357317
+ return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgsString).concat(wait ? " --wait" : "");
357318
+ };
357319
+ var getDeleteSchedulesScripts = function (context) {
357320
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
357321
+ var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
357322
+ var argsString = (0, createArgsString_1.createArgsString)({
357323
+ project: deployConfig.projectId,
357324
+ location: deployConfig.region
357325
+ });
357326
+ return jobsWithSchedule.map(function (_a) {
357327
+ var schedulerName = _a.schedulerName;
357328
+ return ["gcloud scheduler jobs delete ".concat(schedulerName, " ").concat(argsString)];
357329
+ }).flat();
357330
+ };
357331
+ exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
357332
+ var getDeleteJobsScripts = function (context) {
357333
+ var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
357334
+ var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
357335
+ var jobsWithNames = getCloudRunJobsWithNames(context);
357336
+ return jobsWithNames.flatMap(function (_a) {
357337
+ var jobName = _a.jobName;
357338
+ return [
357339
+ // first delete all job executions. Otherwise delete might fail if one of those is still running
357340
+ "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)];
357341
+ });
357342
+ };
357343
+ exports.getDeleteJobsScripts = getDeleteJobsScripts;
357344
+ var getJobRunScripts = function (context, when) {
357345
+ var jobsWithNames = getCloudRunJobsWithNames(context);
357346
+ return jobsWithNames.filter(function (_a) {
357347
+ var job = _a.job;
357348
+ return job.when === when;
357349
+ }).map(function (_a) {
357350
+ var jobName = _a.jobName;
357351
+ return getJobRunScriptForJob(context, jobName,
357352
+ // wait for completin on stop jobs, since stop will delete the jobs afterwards, so they will fail
357353
+ ["preStop", "postStop"].includes(when));
357354
+ });
357355
+ };
357356
+ exports.getJobRunScripts = getJobRunScripts;
357357
+ var getJobCreateScripts = function (context) {
357358
+ var jobsWithNames = getCloudRunJobsWithNames(context);
357359
+ return jobsWithNames.map(function (_a) {
357360
+ var job = _a.job,
357361
+ jobName = _a.jobName;
357362
+ return getJobCreateScriptsForJob(context, jobName, job);
357363
+ }).flat();
357364
+ };
357365
+ exports.getJobCreateScripts = getJobCreateScripts;
357366
+ var getJobCreateScriptsForJob = function (context, jobName, job) {
357367
+ var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
357368
+ // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
357369
+ // lucky, update on the other hand accepts it... so let's just imediatly update it
357370
+ // also we cannot upsert a job, so we have to create it and catch the error and then update
357371
+ var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
357372
+ var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
357373
+ command: '"' + commandArray.join(",") + '"'
357374
+ }, commonDeployArgs), {
357375
+ labels: (0, common_1.makeLabelString)(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
357376
+ "cloud-run-job-name": jobName
357377
+ })),
357378
+ image: job.image || commonDeployArgs.image,
357379
+ memory: job.memory || "512Mi",
357380
+ "task-timeout": job.timeout || "10m"
357381
+ }));
357382
+ var argsString = "".concat(jobName, " ").concat(commonDeployArgsString);
357383
+ 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);
357384
+ };
357385
+ var getCreateScheduleScripts = function (context) {
357386
+ var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
357387
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
357388
+ return jobsWithSchedule.map(function (_a) {
357389
+ var _b;
357390
+ var job = _a.job,
357391
+ jobName = _a.jobName,
357392
+ schedulerName = _a.schedulerName;
357393
+ var argsString = (0, createArgsString_1.createArgsString)({
357394
+ project: deployConfig.projectId,
357395
+ location: deployConfig.region,
357396
+ schedule: "\"".concat(job.schedule, "\""),
357397
+ "max-retry-attempts": (_b = job.maxRetryAttempts) !== null && _b !== void 0 ? _b : 0,
357398
+ uri: "\"https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(jobName, ":run\""),
357399
+ "http-method": "POST",
357400
+ "oauth-service-account-email": "$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"
357401
+ });
357402
+ var commonArgs = "http ".concat(schedulerName, " ").concat(argsString);
357403
+ return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["gcloud scheduler jobs create ".concat(commonArgs)])), false), ["gcloud scheduler jobs update ".concat(commonArgs)], false);
357404
+ }).flat();
357405
+ };
357406
+ exports.getCreateScheduleScripts = getCreateScheduleScripts;
357407
+ var getCloudRunJobsWithSchedule = function (context) {
357408
+ var jobsWithNames = getCloudRunJobsWithNames(context);
357409
+ return jobsWithNames.filter(function (entry) {
357410
+ return entry.job.when === "schedule";
357411
+ }).map(function (_a) {
357412
+ var job = _a.job,
357413
+ jobName = _a.jobName;
357414
+ return {
357415
+ job: job,
357416
+ jobName: jobName,
357417
+ schedulerName: jobName + "-scheduler"
357418
+ };
357419
+ });
357420
+ };
357421
+ var getCloudRunJobsWithNames = function (context) {
357422
+ var _a;
357423
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
357424
+ var getFullJobName = function (name) {
357425
+ return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
357426
+ };
357427
+ var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
357428
+ // filter out disabled jobs
357429
+ .filter(function (entry) {
357430
+ return Boolean(entry[1]);
357431
+ }).map(function (_a) {
357432
+ var _b = __read(_a, 2),
357433
+ name = _b[0],
357434
+ job = _b[1];
357435
+ return {
357436
+ jobName: getFullJobName(name),
357437
+ job: job
357438
+ };
357439
+ });
357440
+ return jobsWithNames;
357441
+ };
357442
+
357443
+ /***/ }),
357444
+
357445
+ /***/ 77210:
357446
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
357447
+
357448
+ "use strict";
357449
+
357450
+
357451
+ var __assign = this && this.__assign || function () {
357452
+ __assign = Object.assign || function (t) {
357453
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
357454
+ s = arguments[i];
357455
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
357456
+ }
357457
+ return t;
357458
+ };
357459
+ return __assign.apply(this, arguments);
357460
+ };
357461
+ exports.__esModule = true;
357462
+ exports.getServiceDeleteScript = exports.getServiceDeployScript = void 0;
357463
+ var getLabels_1 = __nccwpck_require__(30486);
357464
+ var createArgsString_1 = __nccwpck_require__(8686);
357316
357465
  var getServiceName_1 = __nccwpck_require__(89391);
357317
- var cleanup_1 = __nccwpck_require__(10964);
357466
+ var common_1 = __nccwpck_require__(75655);
357467
+ var getServiceDeployScript = function (context, service, nameSuffix) {
357468
+ var _a, _b, _c, _d, _e;
357469
+ var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
357470
+ var serviceName = (0, getServiceName_1.getServiceName)(context);
357471
+ var customConfig = service !== true ? service : undefined;
357472
+ var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
357473
+ var commandArray = command ? Array.isArray(command) ? command : command.split(" ") : undefined;
357474
+ var fullServiceName = "".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "");
357475
+ var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
357476
+ // command as empty string resets it to default (uses the image's entrypoint)
357477
+ command: commandArray ? '"' + commandArray.join(",") + '"' : '""'
357478
+ }, commonDeployArgs), {
357479
+ labels: (0, common_1.makeLabelString)(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
357480
+ "cloud-run-service-name": fullServiceName
357481
+ })),
357482
+ "env-vars-file": "____envvars.yaml",
357483
+ "min-instances": (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _b !== void 0 ? _b : 0,
357484
+ "max-instances": (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances) !== null && _c !== void 0 ? _c : 100,
357485
+ "cpu-throttling": (customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling) !== true,
357486
+ memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
357487
+ "allow-unauthenticated": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _d !== void 0 ? _d : true,
357488
+ ingress: (_e = customConfig === null || customConfig === void 0 ? void 0 : customConfig.ingress) !== null && _e !== void 0 ? _e : "all",
357489
+ "cpu-boost": true
357490
+ }));
357491
+ return "gcloud run deploy ".concat(fullServiceName, " ").concat(argsString);
357492
+ };
357493
+ exports.getServiceDeployScript = getServiceDeployScript;
357494
+ var getServiceDeleteScript = function (context, serviceSuffix) {
357495
+ var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
357496
+ var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
357497
+ var serviceName = (0, getServiceName_1.getServiceName)(context);
357498
+ var fullServiceName = serviceSuffix ? "".concat(serviceName, "-").concat(serviceSuffix) : serviceName;
357499
+ return ["gcloud run services delete ".concat(fullServiceName, " ").concat(commonArgsString)];
357500
+ };
357501
+ exports.getServiceDeleteScript = getServiceDeleteScript;
357502
+
357503
+ /***/ }),
357504
+
357505
+ /***/ 75655:
357506
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
357507
+
357508
+ "use strict";
357509
+
357510
+
357511
+ var __assign = this && this.__assign || function () {
357512
+ __assign = Object.assign || function (t) {
357513
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
357514
+ s = arguments[i];
357515
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
357516
+ }
357517
+ return t;
357518
+ };
357519
+ return __assign.apply(this, arguments);
357520
+ };
357521
+ var __read = this && this.__read || function (o, n) {
357522
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
357523
+ if (!m) return o;
357524
+ var i = m.call(o),
357525
+ r,
357526
+ ar = [],
357527
+ e;
357528
+ try {
357529
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
357530
+ } catch (error) {
357531
+ e = {
357532
+ error: error
357533
+ };
357534
+ } finally {
357535
+ try {
357536
+ if (r && !r.done && (m = i["return"])) m.call(i);
357537
+ } finally {
357538
+ if (e) throw e.error;
357539
+ }
357540
+ }
357541
+ return ar;
357542
+ };
357543
+ exports.__esModule = true;
357544
+ exports.getCommonDeployArgs = exports.getCommonCloudRunArgs = exports.getCloudRunDeployConfig = exports.makeLabelString = exports.setGoogleProjectNumberScript = void 0;
357545
+ var types_1 = __nccwpck_require__(63109);
357546
+ var artifactsRegistry_1 = __nccwpck_require__(28159);
357318
357547
  var setGoogleProjectNumberScript = function (deployConfig) {
357319
357548
  return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
357320
357549
  };
357550
+ exports.setGoogleProjectNumberScript = setGoogleProjectNumberScript;
357321
357551
  var makeLabelString = function (obj) {
357322
357552
  return Object.entries(obj).map(function (_a) {
357323
357553
  var _b = __read(_a, 2),
@@ -357326,181 +357556,193 @@ var makeLabelString = function (obj) {
357326
357556
  return "".concat(key, "=").concat(value);
357327
357557
  }).join(",");
357328
357558
  };
357329
- var createGoogleCloudRunDeployJobs = function (context) {
357330
- var _a, _b, _c;
357559
+ exports.makeLabelString = makeLabelString;
357560
+ var getCloudRunDeployConfig = function (context) {
357331
357561
  var deployConfig = context.componentConfig.deploy;
357332
- if (deployConfig === false) {
357333
- return [];
357334
- }
357335
357562
  if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
357336
357563
  // should not happen
357337
357564
  throw new Error("deploy config is wrong");
357338
357565
  }
357339
- var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
357340
- var commonArgs = {
357566
+ return deployConfig;
357567
+ };
357568
+ exports.getCloudRunDeployConfig = getCloudRunDeployConfig;
357569
+ function getCommonCloudRunArgs(context) {
357570
+ var deployConfig = (0, exports.getCloudRunDeployConfig)(context);
357571
+ return {
357341
357572
  project: deployConfig.projectId,
357342
357573
  region: deployConfig.region
357343
357574
  };
357344
- var commonDeployArgs = __assign(__assign({
357575
+ }
357576
+ exports.getCommonCloudRunArgs = getCommonCloudRunArgs;
357577
+ function getCommonDeployArgs(context) {
357578
+ var commonArgs = getCommonCloudRunArgs(context);
357579
+ var deployConfig = (0, exports.getCloudRunDeployConfig)(context);
357580
+ return __assign(__assign({
357345
357581
  image: (0, artifactsRegistry_1.getArtifactsRegistryImage)(context)
357346
357582
  }, commonArgs), {
357347
357583
  "set-cloudsql-instances": deployConfig.cloudSql ? deployConfig.cloudSql.instanceConnectionName : undefined
357348
357584
  });
357349
- var serviceName = (0, getServiceName_1.getServiceName)(context);
357350
- var getFullJobName = function (name) {
357351
- return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
357352
- };
357353
- var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
357354
- // filter out disabled jobs
357355
- .filter(function (entry) {
357356
- return Boolean(entry[1]);
357357
- }).map(function (_a) {
357358
- var _b = __read(_a, 2),
357359
- name = _b[0],
357360
- job = _b[1];
357361
- return {
357362
- jobName: getFullJobName(name),
357363
- job: job
357364
- };
357365
- });
357366
- var jobsWithSchedule = jobsWithNames.filter(function (entry) {
357367
- return entry.job.when === "schedule";
357368
- }).map(function (_a) {
357369
- var job = _a.job,
357370
- jobName = _a.jobName;
357371
- return {
357372
- job: job,
357373
- jobName: jobName,
357374
- schedulerName: jobName + "-scheduler"
357585
+ }
357586
+ exports.getCommonDeployArgs = getCommonDeployArgs;
357587
+
357588
+ /***/ }),
357589
+
357590
+ /***/ 21944:
357591
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
357592
+
357593
+ "use strict";
357594
+
357595
+
357596
+ var __read = this && this.__read || function (o, n) {
357597
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
357598
+ if (!m) return o;
357599
+ var i = m.call(o),
357600
+ r,
357601
+ ar = [],
357602
+ e;
357603
+ try {
357604
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
357605
+ } catch (error) {
357606
+ e = {
357607
+ error: error
357375
357608
  };
357376
- });
357377
- var getServiceDeployScript = function (service, nameSuffix) {
357378
- var _a, _b, _c, _d, _e;
357379
- var customConfig = service !== true ? service : undefined;
357380
- var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
357381
- var commandArray = command ? Array.isArray(command) ? command : command.split(" ") : undefined;
357382
- var fullServiceName = "".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "");
357383
- var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
357384
- // command as empty string resets it to default (uses the image's entrypoint)
357385
- command: commandArray ? '"' + commandArray.join(",") + '"' : '""'
357386
- }, commonDeployArgs), {
357387
- labels: makeLabelString(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
357388
- "cloud-run-service-name": fullServiceName
357389
- })),
357390
- "env-vars-file": "____envvars.yaml",
357391
- "min-instances": (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _b !== void 0 ? _b : 0,
357392
- "max-instances": (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances) !== null && _c !== void 0 ? _c : 100,
357393
- "cpu-throttling": (customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling) !== true,
357394
- memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
357395
- "allow-unauthenticated": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _d !== void 0 ? _d : true,
357396
- ingress: (_e = customConfig === null || customConfig === void 0 ? void 0 : customConfig.ingress) !== null && _e !== void 0 ? _e : "all",
357397
- "cpu-boost": true
357398
- }));
357399
- return "gcloud run deploy ".concat(fullServiceName, " ").concat(argsString);
357400
- };
357401
- var getJobCreateScriptsForJob = function (jobName, job) {
357402
- // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
357403
- // lucky, update on the other hand accepts it... so let's just imediatly update it
357404
- // also we cannot upsert a job, so we have to create it and catch the error and then update
357405
- var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
357406
- var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
357407
- command: '"' + commandArray.join(",") + '"'
357408
- }, commonDeployArgs), {
357409
- labels: makeLabelString(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
357410
- "cloud-run-job-name": jobName
357411
- })),
357412
- image: job.image || commonDeployArgs.image,
357413
- memory: job.memory || "512Mi",
357414
- "task-timeout": job.timeout || "10m"
357415
- }));
357416
- var argsString = "".concat(jobName, " ").concat(commonDeployArgsString);
357417
- 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);
357418
- };
357419
- var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
357420
- var getJobCreateScripts = function () {
357421
- return jobsWithNames.map(function (_a) {
357422
- var job = _a.job,
357423
- jobName = _a.jobName;
357424
- return getJobCreateScriptsForJob(jobName, job);
357425
- }).flat();
357426
- };
357427
- var getJobRunScriptForJob = function (jobName, wait) {
357428
- return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgsString).concat(wait ? " --wait" : "");
357429
- };
357430
- var getJobRunScripts = function (when) {
357431
- return jobsWithNames.filter(function (_a) {
357432
- var job = _a.job;
357433
- return job.when === when;
357434
- }).map(function (_a) {
357435
- var jobName = _a.jobName;
357436
- return getJobRunScriptForJob(jobName,
357437
- // wait for completin on stop jobs, since stop will delete the jobs afterwards, so they will fail
357438
- ["preStop", "postStop"].includes(when));
357439
- });
357440
- };
357441
- var getCreateScheduleScripts = function () {
357442
- return jobsWithSchedule.map(function (_a) {
357443
- var _b;
357444
- var job = _a.job,
357445
- jobName = _a.jobName,
357446
- schedulerName = _a.schedulerName;
357447
- var argsString = (0, createArgsString_1.createArgsString)({
357448
- project: deployConfig.projectId,
357449
- location: deployConfig.region,
357450
- schedule: "\"".concat(job.schedule, "\""),
357451
- "max-retry-attempts": (_b = job.maxRetryAttempts) !== null && _b !== void 0 ? _b : 0,
357452
- uri: "\"https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(jobName, ":run\""),
357453
- "http-method": "POST",
357454
- "oauth-service-account-email": "$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"
357455
- });
357456
- var commonArgs = "http ".concat(schedulerName, " ").concat(argsString);
357457
- return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["gcloud scheduler jobs create ".concat(commonArgs)])), false), ["gcloud scheduler jobs update ".concat(commonArgs)], false);
357458
- }).flat();
357459
- };
357460
- var getDeleteSchedulesScripts = function () {
357461
- var argsString = (0, createArgsString_1.createArgsString)({
357462
- project: deployConfig.projectId,
357463
- location: deployConfig.region
357464
- });
357465
- return jobsWithSchedule.map(function (_a) {
357466
- var schedulerName = _a.schedulerName;
357467
- return ["gcloud scheduler jobs delete ".concat(schedulerName, " ").concat(argsString)];
357468
- }).flat();
357469
- };
357470
- var getDeleteJobsScripts = function () {
357471
- return jobsWithNames.flatMap(function (_a) {
357472
- var jobName = _a.jobName;
357473
- return [
357474
- // first delete all job executions. Otherwise delete might fail if one of those is still running
357475
- "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)];
357476
- });
357477
- };
357478
- 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
357479
- : []), 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) {
357609
+ } finally {
357610
+ try {
357611
+ if (r && !r.done && (m = i["return"])) m.call(i);
357612
+ } finally {
357613
+ if (e) throw e.error;
357614
+ }
357615
+ }
357616
+ return ar;
357617
+ };
357618
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
357619
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
357620
+ if (ar || !(i in from)) {
357621
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
357622
+ ar[i] = from[i];
357623
+ }
357624
+ }
357625
+ return to.concat(ar || Array.prototype.slice.call(from));
357626
+ };
357627
+ exports.__esModule = true;
357628
+ exports.getCloudRunDeployScripts = void 0;
357629
+ var gitlab_1 = __nccwpck_require__(84997);
357630
+ var sbom_1 = __nccwpck_require__(65928);
357631
+ var cleanup_1 = __nccwpck_require__(10964);
357632
+ var database_1 = __nccwpck_require__(41384);
357633
+ var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(22607);
357634
+ var cloudRunJobs_1 = __nccwpck_require__(66321);
357635
+ var cloudRunServices_1 = __nccwpck_require__(77210);
357636
+ var common_1 = __nccwpck_require__(75655);
357637
+ function getCloudRunDeployScripts(context) {
357638
+ var _a;
357639
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
357640
+ 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
357641
+ : []), 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) {
357480
357642
  var _b = __read(_a, 2),
357481
357643
  name = _b[0],
357482
357644
  service = _b[1];
357483
- return getServiceDeployScript(service, "-" + name);
357484
- })), 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
357645
+ return (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name);
357646
+ })), 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
357485
357647
  )), false), __read((0, sbom_1.getDependencyTrackUploadScript)(context)), false);
357486
- 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) {
357648
+ }
357649
+ exports.getCloudRunDeployScripts = getCloudRunDeployScripts;
357650
+
357651
+ /***/ }),
357652
+
357653
+ /***/ 40910:
357654
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
357655
+
357656
+ "use strict";
357657
+
357658
+
357659
+ var __read = this && this.__read || function (o, n) {
357660
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
357661
+ if (!m) return o;
357662
+ var i = m.call(o),
357663
+ r,
357664
+ ar = [],
357665
+ e;
357666
+ try {
357667
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
357668
+ } catch (error) {
357669
+ e = {
357670
+ error: error
357671
+ };
357672
+ } finally {
357673
+ try {
357674
+ if (r && !r.done && (m = i["return"])) m.call(i);
357675
+ } finally {
357676
+ if (e) throw e.error;
357677
+ }
357678
+ }
357679
+ return ar;
357680
+ };
357681
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
357682
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
357683
+ if (ar || !(i in from)) {
357684
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
357685
+ ar[i] = from[i];
357686
+ }
357687
+ }
357688
+ return to.concat(ar || Array.prototype.slice.call(from));
357689
+ };
357690
+ exports.__esModule = true;
357691
+ exports.getCloudRunStopScripts = void 0;
357692
+ var sbom_1 = __nccwpck_require__(65928);
357693
+ var cleanup_1 = __nccwpck_require__(10964);
357694
+ var database_1 = __nccwpck_require__(41384);
357695
+ var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(22607);
357696
+ var cloudRunJobs_1 = __nccwpck_require__(66321);
357697
+ var cloudRunServices_1 = __nccwpck_require__(77210);
357698
+ var common_1 = __nccwpck_require__(75655);
357699
+ function getCloudRunStopScripts(context) {
357700
+ var _a;
357701
+ var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
357702
+ 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) {
357487
357703
  var _b = __read(_a, 1),
357488
357704
  name = _b[0];
357489
- return "gcloud run services delete ".concat(serviceName, "-").concat(name, " ").concat(commonArgsString);
357490
- })), 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);
357705
+ return (0, cloudRunServices_1.getServiceDeleteScript)(context, name);
357706
+ })), 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);
357707
+ }
357708
+ exports.getCloudRunStopScripts = getCloudRunStopScripts;
357709
+
357710
+ /***/ }),
357711
+
357712
+ /***/ 26474:
357713
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
357714
+
357715
+ "use strict";
357716
+
357717
+
357718
+ exports.__esModule = true;
357719
+ exports.createGoogleCloudRunDeployJobs = void 0;
357720
+ var lodash_1 = __nccwpck_require__(23255);
357721
+ var docker_1 = __nccwpck_require__(33219);
357722
+ var runner_1 = __nccwpck_require__(55071);
357723
+ var gitlab_1 = __nccwpck_require__(84997);
357724
+ var base_1 = __nccwpck_require__(82866);
357725
+ var types_1 = __nccwpck_require__(63109);
357726
+ var variables_1 = __nccwpck_require__(20408);
357727
+ var getCloudRunDeployScripts_1 = __nccwpck_require__(21944);
357728
+ var getCloudRunStopScripts_1 = __nccwpck_require__(40910);
357729
+ var createGoogleCloudRunDeployJobs = function (context) {
357730
+ var deployConfig = context.componentConfig.deploy;
357731
+ if (deployConfig === false) {
357732
+ return [];
357733
+ }
357734
+ if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
357735
+ // should not happen
357736
+ throw new Error("deploy config is wrong");
357737
+ }
357738
+ var deployScripts = (0, getCloudRunDeployScripts_1.getCloudRunDeployScripts)(context);
357739
+ var stopScripts = (0, getCloudRunStopScripts_1.getCloudRunStopScripts)(context);
357491
357740
  return (0, base_1.createDeployementJobs)(context, {
357492
357741
  deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
357493
357742
  artifacts: {
357494
357743
  paths: ["____envvars.yaml"]
357495
357744
  },
357496
- variables: {
357497
- CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
357498
- ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
357499
- lineWidth: -1,
357500
- quotingType: "'",
357501
- forceQuotes: true
357502
- })
357503
- },
357745
+ variables: (0, variables_1.getDeployJobVariables)(context),
357504
357746
  image: (0, runner_1.getRunnerImage)("gcloud"),
357505
357747
  script: deployScripts
357506
357748
  }),
@@ -357517,6 +357759,32 @@ exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
357517
357759
 
357518
357760
  /***/ }),
357519
357761
 
357762
+ /***/ 20408:
357763
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
357764
+
357765
+ "use strict";
357766
+
357767
+
357768
+ exports.__esModule = true;
357769
+ exports.getDeployJobVariables = void 0;
357770
+ var js_yaml_1 = __nccwpck_require__(3618);
357771
+ var lodash_1 = __nccwpck_require__(23255);
357772
+ var __1 = __nccwpck_require__(25355);
357773
+ function getDeployJobVariables(context) {
357774
+ var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, __1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
357775
+ return {
357776
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
357777
+ ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
357778
+ lineWidth: -1,
357779
+ quotingType: "'",
357780
+ forceQuotes: true
357781
+ })
357782
+ };
357783
+ }
357784
+ exports.getDeployJobVariables = getDeployJobVariables;
357785
+
357786
+ /***/ }),
357787
+
357520
357788
  /***/ 81344:
357521
357789
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
357522
357790
 
@@ -357569,7 +357837,7 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = expo
357569
357837
  var context_1 = __nccwpck_require__(22041);
357570
357838
  var gitlab_1 = __nccwpck_require__(84997);
357571
357839
  var utils_1 = __nccwpck_require__(70463);
357572
- var deployJob_1 = __nccwpck_require__(82256);
357840
+ var createJobs_1 = __nccwpck_require__(26474);
357573
357841
  var jobName_1 = __nccwpck_require__(77311);
357574
357842
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
357575
357843
  // FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
@@ -357601,7 +357869,7 @@ var getCloudSqlVariables = function (_a) {
357601
357869
  return {};
357602
357870
  };
357603
357871
  exports.GCLOUD_RUN_DEPLOY_TYPE = {
357604
- jobs: deployJob_1.createGoogleCloudRunDeployJobs,
357872
+ jobs: createJobs_1.createGoogleCloudRunDeployJobs,
357605
357873
  defaults: function (_a) {
357606
357874
  var deployConfigRaw = _a.deployConfigRaw,
357607
357875
  envType = _a.envType;