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