@catladder/cli 0.0.0-main-c78c1d06 → 0.0.0-main-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.
@@ -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-825d7e86" || 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,249 @@ 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 "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);
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 "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);
357326
357547
  var setGoogleProjectNumberScript = function (deployConfig) {
357327
357548
  return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
357328
357549
  };
357550
+ exports.setGoogleProjectNumberScript = setGoogleProjectNumberScript;
357329
357551
  var makeLabelString = function (obj) {
357330
357552
  return Object.entries(obj).map(function (_a) {
357331
357553
  var _b = __read(_a, 2),
@@ -357334,181 +357556,193 @@ var makeLabelString = function (obj) {
357334
357556
  return "".concat(key, "=").concat(value);
357335
357557
  }).join(",");
357336
357558
  };
357337
- var createGoogleCloudRunDeployJobs = function (context) {
357338
- var _a, _b, _c;
357559
+ exports.makeLabelString = makeLabelString;
357560
+ var getCloudRunDeployConfig = function (context) {
357339
357561
  var deployConfig = context.componentConfig.deploy;
357340
- if (deployConfig === false) {
357341
- return [];
357342
- }
357343
357562
  if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
357344
357563
  // should not happen
357345
357564
  throw new Error("deploy config is wrong");
357346
357565
  }
357347
- var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
357348
- var commonArgs = {
357566
+ return deployConfig;
357567
+ };
357568
+ exports.getCloudRunDeployConfig = getCloudRunDeployConfig;
357569
+ function getCommonCloudRunArgs(context) {
357570
+ var deployConfig = (0, exports.getCloudRunDeployConfig)(context);
357571
+ return {
357349
357572
  project: deployConfig.projectId,
357350
357573
  region: deployConfig.region
357351
357574
  };
357352
- 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({
357353
357581
  image: (0, artifactsRegistry_1.getArtifactsRegistryImage)(context)
357354
357582
  }, commonArgs), {
357355
357583
  "set-cloudsql-instances": deployConfig.cloudSql ? deployConfig.cloudSql.instanceConnectionName : undefined
357356
357584
  });
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"
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
357383
357608
  };
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) {
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) {
357488
357642
  var _b = __read(_a, 2),
357489
357643
  name = _b[0],
357490
357644
  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
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
357493
357647
  )), 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) {
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) {
357495
357703
  var _b = __read(_a, 1),
357496
357704
  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);
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);
357499
357740
  return (0, base_1.createDeployementJobs)(context, {
357500
357741
  deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
357501
357742
  artifacts: {
357502
357743
  paths: ["____envvars.yaml"]
357503
357744
  },
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
- },
357745
+ variables: (0, variables_1.getDeployJobVariables)(context),
357512
357746
  image: (0, runner_1.getRunnerImage)("gcloud"),
357513
357747
  script: deployScripts
357514
357748
  }),
@@ -357525,6 +357759,32 @@ exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
357525
357759
 
357526
357760
  /***/ }),
357527
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
+
357528
357788
  /***/ 81344:
357529
357789
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
357530
357790
 
@@ -357577,7 +357837,7 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = expo
357577
357837
  var context_1 = __nccwpck_require__(22041);
357578
357838
  var gitlab_1 = __nccwpck_require__(84997);
357579
357839
  var utils_1 = __nccwpck_require__(70463);
357580
- var deployJob_1 = __nccwpck_require__(82256);
357840
+ var createJobs_1 = __nccwpck_require__(26474);
357581
357841
  var jobName_1 = __nccwpck_require__(77311);
357582
357842
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
357583
357843
  // FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
@@ -357609,7 +357869,7 @@ var getCloudSqlVariables = function (_a) {
357609
357869
  return {};
357610
357870
  };
357611
357871
  exports.GCLOUD_RUN_DEPLOY_TYPE = {
357612
- jobs: deployJob_1.createGoogleCloudRunDeployJobs,
357872
+ jobs: createJobs_1.createGoogleCloudRunDeployJobs,
357613
357873
  defaults: function (_a) {
357614
357874
  var deployConfigRaw = _a.deployConfigRaw,
357615
357875
  envType = _a.envType;