@catladder/cli 0.0.0-inventory-2f61feef → 0.0.0-jdbc-e0855190

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.
Files changed (31) hide show
  1. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +106 -45
  2. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
  3. package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
  4. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
  5. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
  6. package/dist/apps/cli/commands/project/index.js +2 -0
  7. package/dist/apps/cli/commands/project/index.js.map +1 -1
  8. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +2 -2
  9. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
  10. package/dist/apps/cli/commands/project/setup/setupCloudRun.js +18 -4
  11. package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -1
  12. package/dist/apps/cli/commands/project/setup/setupCloudSQL.js +2 -2
  13. package/dist/apps/cli/commands/project/setup/setupCloudSQL.js.map +1 -1
  14. package/dist/apps/cli/commands/project/setup/setupContext.js +1 -1
  15. package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  16. package/dist/bundles/catenv/index.js +1150 -352
  17. package/dist/bundles/cli/index.js +1477 -505
  18. package/dist/config/getProjectConfig.d.ts +1 -1
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/dist/utils/gitlab.d.ts +3 -1
  21. package/dist/utils/gitlab.js +60 -9
  22. package/dist/utils/gitlab.js.map +1 -1
  23. package/package.json +2 -2
  24. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +105 -36
  25. package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
  26. package/src/apps/cli/commands/project/index.ts +2 -0
  27. package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +21 -10
  28. package/src/apps/cli/commands/project/setup/setupCloudRun.ts +8 -1
  29. package/src/apps/cli/commands/project/setup/setupCloudSQL.ts +6 -3
  30. package/src/apps/cli/commands/project/setup/setupContext.ts +2 -2
  31. package/src/utils/gitlab.ts +50 -12
@@ -1195,6 +1195,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
1195
1195
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
1196
1196
  }
1197
1197
  };
1198
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1199
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1200
+ if (ar || !(i in from)) {
1201
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1202
+ ar[i] = from[i];
1203
+ }
1204
+ }
1205
+ return to.concat(ar || Array.prototype.slice.call(from));
1206
+ };
1198
1207
  exports.__esModule = true;
1199
1208
  var pipeline_1 = __nccwpck_require__(25355);
1200
1209
  var child_process_promise_1 = __nccwpck_require__(75763);
@@ -1213,79 +1222,79 @@ exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void
1213
1222
  return [4 /*yield*/, (0, autocompletions_1.envAndComponents)()];
1214
1223
  case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])
1215
1224
  .action(function (_a) {
1216
- var _b, _c, _d, _e;
1217
1225
  var envComponent = _a.envComponent;
1218
1226
  return __awaiter(this, void 0, void 0, function () {
1219
- var _f, env, componentName, config, localPort, envVars, POSTGRESQL_PASSWORD, context, values, projectId, defaultInstanceId, instanceId, defaultRegion, region, instanceName, cloudsqlProxyCredentials;
1227
+ var _b, env, componentName, context, proxyInfo, DB_PASSWORD, DB_NAME, instanceName, localPort, cloudsqlProxyCredentials;
1220
1228
  var _this = this;
1221
- return __generator(this, function (_g) {
1222
- switch (_g.label) {
1229
+ return __generator(this, function (_c) {
1230
+ switch (_c.label) {
1223
1231
  case 0:
1224
- _f = (0, getProjectConfig_1.parseChoice)(envComponent), env = _f.env, componentName = _f.componentName;
1225
- return [4 /*yield*/, (0, getProjectConfig_1.getProjectConfig)()];
1232
+ _b = (0, getProjectConfig_1.parseChoice)(envComponent), env = _b.env, componentName = _b.componentName;
1233
+ return [4 /*yield*/, (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName)];
1226
1234
  case 1:
1227
- config = _g.sent();
1235
+ context = _c.sent();
1236
+ if (env === "review") {
1237
+ vorpal.log("⚠️ connection string does not include mr information on review environments");
1238
+ }
1239
+ if (!(0, pipeline_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) return [3 /*break*/, 3];
1240
+ return [4 /*yield*/, getProxyInfoForKubernetes(context)];
1241
+ case 2:
1242
+ proxyInfo = _c.sent();
1243
+ return [3 /*break*/, 6];
1244
+ case 3:
1245
+ if (!(0, pipeline_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun")) return [3 /*break*/, 5];
1246
+ return [4 /*yield*/, getProxyInfoForCloudRun(context)];
1247
+ case 4:
1248
+ proxyInfo = _c.sent();
1249
+ return [3 /*break*/, 6];
1250
+ case 5: throw new Error("unsupported environment");
1251
+ case 6:
1252
+ DB_PASSWORD = proxyInfo.DB_PASSWORD, DB_NAME = proxyInfo.DB_NAME, instanceName = proxyInfo.instanceName;
1228
1253
  return [4 /*yield*/, this.prompt({
1229
1254
  type: "number",
1230
1255
  name: "localPort",
1231
1256
  "default": "54320",
1232
1257
  message: "Local port: "
1233
1258
  })];
1234
- case 2:
1235
- localPort = (_g.sent()).localPort;
1236
- return [4 /*yield*/, (0, getProjectConfig_1.getEnvVars)(this, env, componentName)];
1237
- case 3:
1238
- envVars = _g.sent();
1239
- POSTGRESQL_PASSWORD = envVars === null || envVars === void 0 ? void 0 : envVars.POSTGRESQL_PASSWORD;
1240
- return [4 /*yield*/, (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName)];
1241
- case 4:
1242
- context = _g.sent();
1243
- if (!(0, pipeline_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
1244
- throw new Error("currently only supported for kubernetes deployment");
1245
- }
1259
+ case 7:
1260
+ localPort = (_c.sent()).localPort;
1246
1261
  this.log("");
1247
- this.log("postgres-PW: ".concat(POSTGRESQL_PASSWORD));
1262
+ this.log("postgres-PW: ".concat(DB_PASSWORD));
1248
1263
  this.log("");
1249
- this.log("POSTGRESQL_URL=postgresql://postgres:".concat(POSTGRESQL_PASSWORD, "@localhost:").concat(localPort, "/").concat(context.environment.envVars.KUBE_APP_NAME, "?schema=public"));
1264
+ this.log("POSTGRESQL_URL=postgresql://postgres:".concat(DB_PASSWORD, "@localhost:").concat(localPort, "/").concat(DB_NAME, "?schema=public"));
1250
1265
  this.log("");
1251
- values = context.componentConfig.deploy.values;
1252
- projectId = ((_b = values === null || values === void 0 ? void 0 : values.cloudsql) === null || _b === void 0 ? void 0 : _b.projectId) ||
1253
- ((_c = context.componentConfig.deploy.cluster) === null || _c === void 0 ? void 0 : _c.projectId);
1254
- defaultInstanceId = "".concat(config.customerName, "-").concat(config.appName, "-").concat(env);
1255
- instanceId = ((_d = values === null || values === void 0 ? void 0 : values.cloudsql) === null || _d === void 0 ? void 0 : _d.instanceId) || defaultInstanceId;
1256
- defaultRegion = "europe-west6";
1257
- region = ((_e = values === null || values === void 0 ? void 0 : values.cloudsql) === null || _e === void 0 ? void 0 : _e.region) || defaultRegion;
1258
- instanceName = "".concat(projectId, ":").concat(region, ":").concat(instanceId, "=tcp:").concat(localPort);
1259
1266
  return [4 /*yield*/, (0, getProjectConfig_1.getGitlabVar)(this, env, componentName, "cloudsqlProxyCredentials")];
1260
- case 5:
1261
- cloudsqlProxyCredentials = _g.sent();
1262
- if (!cloudsqlProxyCredentials) {
1263
- // we store cloudsqlProxyCredentials on gitlab, but its currently get pushed via bitwarden due to legacy reasons
1264
- // this will be fixed with when https://git.panter.ch/catladder/catladder/-/merge_requests/32/ is merged
1265
- this.log("cloudsqlProxyCredentials env var missing in gitlab. Please contact gilde-ci-cd about that.");
1266
- throw new Error("cloudsqlProxyCredentials missing in secrets");
1267
- }
1267
+ case 8:
1268
+ cloudsqlProxyCredentials = _c.sent();
1268
1269
  return [4 /*yield*/, (0, tmp_promise_1.withFile)(function (_a) {
1269
1270
  var tmpFilePath = _a.path;
1270
1271
  return __awaiter(_this, void 0, void 0, function () {
1271
1272
  return __generator(this, function (_b) {
1272
1273
  switch (_b.label) {
1273
- case 0: return [4 /*yield*/, (0, fs_extra_1.writeFile)(tmpFilePath, cloudsqlProxyCredentials)];
1274
+ case 0:
1275
+ if (!cloudsqlProxyCredentials) return [3 /*break*/, 2];
1276
+ return [4 /*yield*/, (0, fs_extra_1.writeFile)(tmpFilePath, cloudsqlProxyCredentials)];
1274
1277
  case 1:
1275
1278
  _b.sent();
1276
- return [4 /*yield*/, (0, child_process_promise_1.spawn)("cloud_sql_proxy", ["-instances", instanceName, "-credential_file", tmpFilePath], {
1277
- stdio: "inherit",
1278
- shell: true
1279
- })];
1280
- case 2:
1279
+ _b.label = 2;
1280
+ case 2: return [4 /*yield*/, (0, child_process_promise_1.spawn)("cloud_sql_proxy", __spreadArray([
1281
+ "-instances",
1282
+ "".concat(instanceName, "=tcp:").concat(localPort)
1283
+ ], (cloudsqlProxyCredentials
1284
+ ? ["-credential_file", tmpFilePath]
1285
+ : []), true), {
1286
+ stdio: "inherit",
1287
+ shell: true
1288
+ })];
1289
+ case 3:
1281
1290
  _b.sent();
1282
1291
  return [2 /*return*/];
1283
1292
  }
1284
1293
  });
1285
1294
  });
1286
1295
  })];
1287
- case 6:
1288
- _g.sent();
1296
+ case 9:
1297
+ _c.sent();
1289
1298
  return [2 /*return*/];
1290
1299
  }
1291
1300
  });
@@ -1294,6 +1303,58 @@ exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void
1294
1303
  }
1295
1304
  });
1296
1305
  }); });
1306
+ var getProxyInfoForKubernetes = function (context) { return __awaiter(void 0, void 0, void 0, function () {
1307
+ var envVars, DB_PASSWORD, DB_NAME, values, projectId, defaultInstanceId, instanceId, defaultRegion, region, instanceName;
1308
+ var _a, _b, _c, _d;
1309
+ return __generator(this, function (_e) {
1310
+ switch (_e.label) {
1311
+ case 0:
1312
+ if (!(0, pipeline_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
1313
+ throw new Error("unsupported");
1314
+ }
1315
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvVars)(this, context.environment.shortName, context.componentName)];
1316
+ case 1:
1317
+ envVars = _e.sent();
1318
+ DB_PASSWORD = (envVars === null || envVars === void 0 ? void 0 : envVars.DB_PASSWORD) || (envVars === null || envVars === void 0 ? void 0 : envVars.POSTGRESQL_PASSWORD);
1319
+ DB_NAME = context.environment.envVars.KUBE_APP_NAME;
1320
+ values = context.componentConfig.deploy.values;
1321
+ projectId = ((_a = values === null || values === void 0 ? void 0 : values.cloudsql) === null || _a === void 0 ? void 0 : _a.projectId) ||
1322
+ ((_b = context.componentConfig.deploy.cluster) === null || _b === void 0 ? void 0 : _b.projectId);
1323
+ defaultInstanceId = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName, "-").concat(context.environment.shortName);
1324
+ instanceId = ((_c = values === null || values === void 0 ? void 0 : values.cloudsql) === null || _c === void 0 ? void 0 : _c.instanceId) || defaultInstanceId;
1325
+ defaultRegion = "europe-west6";
1326
+ region = ((_d = values === null || values === void 0 ? void 0 : values.cloudsql) === null || _d === void 0 ? void 0 : _d.region) || defaultRegion;
1327
+ instanceName = "".concat(projectId, ":").concat(region, ":").concat(instanceId);
1328
+ return [2 /*return*/, {
1329
+ instanceName: instanceName,
1330
+ DB_PASSWORD: DB_PASSWORD,
1331
+ DB_NAME: DB_NAME
1332
+ }];
1333
+ }
1334
+ });
1335
+ }); };
1336
+ var getProxyInfoForCloudRun = function (context) { return __awaiter(void 0, void 0, void 0, function () {
1337
+ var envVars, DB_PASSWORD, DB_NAME;
1338
+ return __generator(this, function (_a) {
1339
+ switch (_a.label) {
1340
+ case 0:
1341
+ if (!(0, pipeline_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun") ||
1342
+ !context.componentConfig.deploy.cloudSql) {
1343
+ throw new Error("unsupported");
1344
+ }
1345
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvVars)(this, context.environment.shortName, context.componentName)];
1346
+ case 1:
1347
+ envVars = _a.sent();
1348
+ DB_PASSWORD = envVars === null || envVars === void 0 ? void 0 : envVars.DB_PASSWORD;
1349
+ DB_NAME = context.environment.envVars.DB_NAME;
1350
+ return [2 /*return*/, {
1351
+ instanceName: context.componentConfig.deploy.cloudSql.instanceConnectionName,
1352
+ DB_PASSWORD: DB_PASSWORD,
1353
+ DB_NAME: DB_NAME
1354
+ }];
1355
+ }
1356
+ });
1357
+ }); };
1297
1358
  //# sourceMappingURL=commandCloudSqlProxy.js.map
1298
1359
 
1299
1360
  /***/ }),
@@ -3468,6 +3529,103 @@ exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void
3468
3529
 
3469
3530
  /***/ }),
3470
3531
 
3532
+ /***/ 41863:
3533
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3534
+
3535
+ "use strict";
3536
+
3537
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3538
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3539
+ return new (P || (P = Promise))(function (resolve, reject) {
3540
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3541
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3542
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3543
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
3544
+ });
3545
+ };
3546
+ var __generator = (this && this.__generator) || function (thisArg, body) {
3547
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
3548
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
3549
+ function verb(n) { return function (v) { return step([n, v]); }; }
3550
+ function step(op) {
3551
+ if (f) throw new TypeError("Generator is already executing.");
3552
+ while (_) try {
3553
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
3554
+ if (y = 0, t) op = [op[0] & 2, t.value];
3555
+ switch (op[0]) {
3556
+ case 0: case 1: t = op; break;
3557
+ case 4: _.label++; return { value: op[1], done: false };
3558
+ case 5: _.label++; y = op[1]; op = [0]; continue;
3559
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
3560
+ default:
3561
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
3562
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
3563
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
3564
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
3565
+ if (t[2]) _.ops.pop();
3566
+ _.trys.pop(); continue;
3567
+ }
3568
+ op = body.call(thisArg, _);
3569
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
3570
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
3571
+ }
3572
+ };
3573
+ exports.__esModule = true;
3574
+ exports.projectSecretsClearBackups = void 0;
3575
+ var gitlab_1 = __nccwpck_require__(79818);
3576
+ var autocompletions_1 = __nccwpck_require__(41373);
3577
+ var projectSecretsClearBackups = function (vorpal, keep) {
3578
+ if (keep === void 0) { keep = 3; }
3579
+ return __awaiter(void 0, void 0, void 0, function () {
3580
+ return __generator(this, function (_a) {
3581
+ switch (_a.label) {
3582
+ case 0: return [4 /*yield*/, (0, gitlab_1.clearBackups)(vorpal, keep)];
3583
+ case 1:
3584
+ _a.sent();
3585
+ return [2 /*return*/];
3586
+ }
3587
+ });
3588
+ });
3589
+ };
3590
+ exports.projectSecretsClearBackups = projectSecretsClearBackups;
3591
+ exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
3592
+ var _a, _b;
3593
+ return __generator(this, function (_c) {
3594
+ switch (_c.label) {
3595
+ case 0:
3596
+ _b = (_a = vorpal
3597
+ .command("project-secrets-clear-backups", "clears all backups"))
3598
+ .autocomplete;
3599
+ return [4 /*yield*/, (0, autocompletions_1.allEnvsAndAllComponents)()];
3600
+ case 1:
3601
+ _b.apply(_a, [_c.sent()])
3602
+ .action(function () {
3603
+ return __awaiter(this, void 0, void 0, function () {
3604
+ var keep;
3605
+ return __generator(this, function (_a) {
3606
+ switch (_a.label) {
3607
+ case 0: return [4 /*yield*/, this.prompt({
3608
+ type: "number",
3609
+ name: "keep",
3610
+ "default": 1,
3611
+ message: "How many backups should we keep? 🤔"
3612
+ })];
3613
+ case 1:
3614
+ keep = (_a.sent()).keep;
3615
+ return [4 /*yield*/, (0, exports.projectSecretsClearBackups)(this, keep)];
3616
+ case 2: return [2 /*return*/, _a.sent()];
3617
+ }
3618
+ });
3619
+ });
3620
+ });
3621
+ return [2 /*return*/];
3622
+ }
3623
+ });
3624
+ }); });
3625
+ //# sourceMappingURL=commandSecretsClearBackups.js.map
3626
+
3627
+ /***/ }),
3628
+
3471
3629
  /***/ 54108:
3472
3630
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3473
3631
 
@@ -3753,6 +3911,7 @@ var commandOpenGrafana_1 = __importDefault(__nccwpck_require__(70414));
3753
3911
  var commandPortForward_1 = __importDefault(__nccwpck_require__(3415));
3754
3912
  var commandTriggerCronjob_1 = __importDefault(__nccwpck_require__(51827));
3755
3913
  var commandOpenGrafanaPod_1 = __importDefault(__nccwpck_require__(55848));
3914
+ var commandSecretsClearBackups_1 = __importDefault(__nccwpck_require__(41863));
3756
3915
  exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
3757
3916
  return __generator(this, function (_a) {
3758
3917
  (0, commandSetup_1["default"])(vorpal);
@@ -3771,6 +3930,7 @@ exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void
3771
3930
  (0, commandOpenEnv_1["default"])(vorpal);
3772
3931
  (0, commandTriggerCronjob_1["default"])(vorpal);
3773
3932
  (0, commandConfigSecrets_1["default"])(vorpal);
3933
+ (0, commandSecretsClearBackups_1["default"])(vorpal);
3774
3934
  (0, commandDeletePods_1["default"])(vorpal);
3775
3935
  (0, commandCopyDB_1["default"])(vorpal);
3776
3936
  (0, commandGetShell_1["default"])(vorpal);
@@ -3992,7 +4152,7 @@ var setupAccessTokens = function (instance) { return __awaiter(void 0, void 0, v
3992
4152
  key: "GL_TOKEN",
3993
4153
  value: GL_TOKEN,
3994
4154
  masked: true
3995
- })];
4155
+ }, "POST")];
3996
4156
  case 7:
3997
4157
  _b.sent();
3998
4158
  return [3 /*break*/, 8];
@@ -4005,7 +4165,7 @@ var setupAccessTokens = function (instance) { return __awaiter(void 0, void 0, v
4005
4165
  id: projectId,
4006
4166
  name: "gitlab-deploy-token",
4007
4167
  scopes: ["read_registry"]
4008
- })];
4168
+ }, "POST")];
4009
4169
  case 10:
4010
4170
  _b.sent();
4011
4171
  _b.label = 11;
@@ -4059,6 +4219,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
4059
4219
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4060
4220
  }
4061
4221
  };
4222
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4223
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4224
+ if (ar || !(i in from)) {
4225
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4226
+ ar[i] = from[i];
4227
+ }
4228
+ }
4229
+ return to.concat(ar || Array.prototype.slice.call(from));
4230
+ };
4062
4231
  exports.__esModule = true;
4063
4232
  exports.setupCloudRun = void 0;
4064
4233
  var pipeline_1 = __nccwpck_require__(25355);
@@ -4079,7 +4248,12 @@ var setupCloudRun = function (instance, context) { return __awaiter(void 0, void
4079
4248
  config = context.componentConfig.deploy;
4080
4249
  // enable services
4081
4250
  instance.log("enable required servies...");
4082
- return [4 /*yield*/, (0, enableServices_1.enableGCloudServices)(["run.googleapis.com", "artifactregistry.googleapis.com"], config)];
4251
+ return [4 /*yield*/, (0, enableServices_1.enableGCloudServices)(__spreadArray([
4252
+ "run.googleapis.com",
4253
+ "artifactregistry.googleapis.com"
4254
+ ], (config.cloudSql
4255
+ ? ["sqladmin.googleapis.com", "sql-component.googleapis.com"]
4256
+ : []), true), config)];
4083
4257
  case 1:
4084
4258
  _b.sent();
4085
4259
  instance.log("upsert artifacts registry...");
@@ -4093,11 +4267,11 @@ var setupCloudRun = function (instance, context) { return __awaiter(void 0, void
4093
4267
  description: "This service account deploys to google cloud",
4094
4268
  name: "cl-d",
4095
4269
  // TODO: run.admin is a bit much, would be better to follow https://stackoverflow.com/questions/55788714/deploying-to-cloud-run-with-a-custom-service-account-failed-with-iam-serviceacco
4096
- roles: [
4270
+ roles: __spreadArray([
4097
4271
  "roles/artifactregistry.repoAdmin",
4098
4272
  "roles/run.admin",
4099
- "roles/iam.serviceAccountUser",
4100
- ]
4273
+ "roles/iam.serviceAccountUser"
4274
+ ], (config.cloudSql ? ["roles/cloudsql.admin"] : []), true)
4101
4275
  }, pipeline_1.GCLOUD_DEPLOY_CREDENTIALS_KEY)];
4102
4276
  case 3:
4103
4277
  _b.sent();
@@ -4173,10 +4347,10 @@ var pipeline_1 = __nccwpck_require__(25355);
4173
4347
  var setupCloudSQL = function (instance, context) { return __awaiter(void 0, void 0, void 0, function () {
4174
4348
  var config;
4175
4349
  return __generator(this, function (_a) {
4176
- if (!(0, pipeline_1.hasCloudSQL)(context)) {
4350
+ if (!(0, pipeline_1.hasKubernetesCloudSQL)(context)) {
4177
4351
  throw new Error("cannot setup cloudsql, as it has none");
4178
4352
  }
4179
- config = (0, pipeline_1.getCloudSQLConfig)(context);
4353
+ config = (0, pipeline_1.getKubernetesCloudSQLConfig)(context);
4180
4354
  instance.log("");
4181
4355
  instance.log("! make sure to provide cloudsqlProxyCredentials for the cloud sql service account in " +
4182
4356
  config.projectId);
@@ -4255,7 +4429,7 @@ var setupContext = function (instance, context) { return __awaiter(void 0, void
4255
4429
  _a.sent();
4256
4430
  _a.label = 2;
4257
4431
  case 2:
4258
- if (!(0, pipeline_1.hasCloudSQL)(context)) return [3 /*break*/, 4];
4432
+ if (!(0, pipeline_1.hasKubernetesCloudSQL)(context)) return [3 /*break*/, 4];
4259
4433
  return [4 /*yield*/, (0, setupCloudSQL_1.setupCloudSQL)(instance, context)];
4260
4434
  case 3:
4261
4435
  _a.sent();
@@ -7136,7 +7310,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7136
7310
  return (mod && mod.__esModule) ? mod : { "default": mod };
7137
7311
  };
7138
7312
  exports.__esModule = true;
7139
- exports.upsertAllVariables = exports.getVariableValueByRawName = exports.getAllVariables = exports.getProjectInfo = exports.doGitlabRequest = exports.getGitlabToken = exports.setupGitlabToken = exports.hasGitlabToken = void 0;
7313
+ exports.upsertAllVariables = exports.clearBackups = exports.getVariableValueByRawName = exports.getAllVariables = exports.getProjectInfo = exports.doGitlabRequest = exports.getGitlabToken = exports.setupGitlabToken = exports.hasGitlabToken = void 0;
7140
7314
  var pipeline_1 = __nccwpck_require__(25355);
7141
7315
  var child_process_promise_1 = __nccwpck_require__(75763);
7142
7316
  var lodash_1 = __nccwpck_require__(23255);
@@ -7210,28 +7384,31 @@ var getGitlabToken = function (vorpal) { return __awaiter(void 0, void 0, void 0
7210
7384
  });
7211
7385
  }); };
7212
7386
  exports.getGitlabToken = getGitlabToken;
7213
- var doGitlabRequest = function (vorpal, path, data, update) {
7387
+ var doGitlabRequest = function (vorpal, path, data, method) {
7214
7388
  if (data === void 0) { data = undefined; }
7389
+ if (method === void 0) { method = "GET"; }
7215
7390
  return __awaiter(void 0, void 0, void 0, function () {
7216
- var rootToken, method, result, _a, _b, _c, _d, _e;
7391
+ var rootToken, result, _a, _b, _c, _d, _e;
7217
7392
  return __generator(this, function (_f) {
7218
7393
  switch (_f.label) {
7219
7394
  case 0: return [4 /*yield*/, (0, exports.getGitlabToken)(vorpal)];
7220
7395
  case 1:
7221
7396
  rootToken = _f.sent();
7222
- method = data ? (update ? "PUT" : "POST") : "GET";
7223
7397
  return [4 /*yield*/, (0, node_fetch_1["default"])("https://git.panter.ch/api/v4/".concat(path), {
7224
7398
  method: method,
7225
7399
  headers: {
7226
7400
  "Content-Type": "application/json",
7227
7401
  "Private-Token": rootToken
7228
7402
  },
7229
- body: JSON.stringify(data)
7403
+ body: data ? JSON.stringify(data) : undefined
7230
7404
  })];
7231
7405
  case 2:
7232
7406
  result = _f.sent();
7233
7407
  if (result.status >= 200 && result.status < 400) {
7234
- return [2 /*return*/, result.json()];
7408
+ if (result.headers.get("content-type") === "application/json") {
7409
+ return [2 /*return*/, result.json()];
7410
+ }
7411
+ return [2 /*return*/, null];
7235
7412
  }
7236
7413
  if (result.status === 404) {
7237
7414
  throw new Error("not found");
@@ -7313,7 +7490,7 @@ var createVariable = function (vorpal, projectId, key, value, masked, environmen
7313
7490
  value: value,
7314
7491
  masked: masked && isMaskable(value),
7315
7492
  environment_scope: environment_scope
7316
- })];
7493
+ }, "POST")];
7317
7494
  case 1: return [2 /*return*/, _a.sent()];
7318
7495
  }
7319
7496
  });
@@ -7327,12 +7504,20 @@ var updateVariable = function (vorpal, projectId, key, value, masked) {
7327
7504
  case 0: return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal, "projects/".concat(projectId, "/variables/").concat(key), {
7328
7505
  value: value,
7329
7506
  masked: masked && isMaskable(value)
7330
- }, true)];
7507
+ }, "PUT")];
7331
7508
  case 1: return [2 /*return*/, _a.sent()];
7332
7509
  }
7333
7510
  });
7334
7511
  });
7335
7512
  };
7513
+ var deleteVariable = function (vorpal, projectId, key) { return __awaiter(void 0, void 0, void 0, function () {
7514
+ return __generator(this, function (_a) {
7515
+ switch (_a.label) {
7516
+ case 0: return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal, "projects/".concat(projectId, "/variables/").concat(key), undefined, "DELETE")];
7517
+ case 1: return [2 /*return*/, _a.sent()];
7518
+ }
7519
+ });
7520
+ }); };
7336
7521
  var getAllCatladderEnvVarsInGitlab = function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
7337
7522
  var allVariables;
7338
7523
  return __generator(this, function (_a) {
@@ -7362,6 +7547,46 @@ var getAllCatladderEnvVarsInGitlab = function (vorpal) { return __awaiter(void 0
7362
7547
  }
7363
7548
  });
7364
7549
  }); };
7550
+ var getBackupKey = function (fullKey, timestamp) {
7551
+ return "".concat(fullKey, "_backup_").concat(timestamp);
7552
+ };
7553
+ var clearBackups = function (vorpal, keep) { return __awaiter(void 0, void 0, void 0, function () {
7554
+ var existingVariables, id, _i, _a, _b, key, backups, backupsSorted, toDelete, _c, toDelete_1, timestamp;
7555
+ return __generator(this, function (_d) {
7556
+ switch (_d.label) {
7557
+ case 0: return [4 /*yield*/, getAllCatladderEnvVarsInGitlab(vorpal)];
7558
+ case 1:
7559
+ existingVariables = _d.sent();
7560
+ return [4 /*yield*/, (0, exports.getProjectInfo)(vorpal)];
7561
+ case 2:
7562
+ id = (_d.sent()).id;
7563
+ _i = 0, _a = Object.entries(existingVariables);
7564
+ _d.label = 3;
7565
+ case 3:
7566
+ if (!(_i < _a.length)) return [3 /*break*/, 8];
7567
+ _b = _a[_i], key = _b[0], backups = _b[1].backups;
7568
+ backupsSorted = backups.sort(function (a, b) { return b - a; });
7569
+ toDelete = backupsSorted.slice(keep);
7570
+ _c = 0, toDelete_1 = toDelete;
7571
+ _d.label = 4;
7572
+ case 4:
7573
+ if (!(_c < toDelete_1.length)) return [3 /*break*/, 7];
7574
+ timestamp = toDelete_1[_c];
7575
+ return [4 /*yield*/, deleteVariable(vorpal, id, getBackupKey(key, timestamp))];
7576
+ case 5:
7577
+ _d.sent();
7578
+ _d.label = 6;
7579
+ case 6:
7580
+ _c++;
7581
+ return [3 /*break*/, 4];
7582
+ case 7:
7583
+ _i++;
7584
+ return [3 /*break*/, 3];
7585
+ case 8: return [2 /*return*/];
7586
+ }
7587
+ });
7588
+ }); };
7589
+ exports.clearBackups = clearBackups;
7365
7590
  var upsertAllVariables = function (vorpal, variables, env, componentName, backup, masked // FIXME: would be better to have this per variable
7366
7591
  ) {
7367
7592
  if (backup === void 0) { backup = true; }
@@ -7394,7 +7619,7 @@ var upsertAllVariables = function (vorpal, variables, env, componentName, backup
7394
7619
  case 4:
7395
7620
  _d.sent();
7396
7621
  if (!backup) return [3 /*break*/, 6];
7397
- return [4 /*yield*/, createVariable(vorpal, id, fullKey + "_backup_" + new Date().getTime(), oldValue, masked, "_backup")];
7622
+ return [4 /*yield*/, createVariable(vorpal, id, getBackupKey(fullKey, new Date().getTime()), oldValue, masked, "_backup")];
7398
7623
  case 5:
7399
7624
  _d.sent();
7400
7625
  _d.label = 6;
@@ -349475,8 +349700,6 @@ var lodash_1 = __nccwpck_require__(23255);
349475
349700
 
349476
349701
  var __1 = __nccwpck_require__(25355);
349477
349702
 
349478
- var reportingJob_1 = __nccwpck_require__(89572);
349479
-
349480
349703
  var utils_1 = __nccwpck_require__(37461);
349481
349704
 
349482
349705
  var yarn_1 = __nccwpck_require__(10464);
@@ -349486,12 +349709,11 @@ var constants_1 = __nccwpck_require__(11542);
349486
349709
  var getBuildInfo_1 = __nccwpck_require__(9197);
349487
349710
 
349488
349711
  var createBuildJob = function (context, _a) {
349489
- var _b, _c, _d;
349712
+ var _b, _c;
349490
349713
 
349491
349714
  var script = _a.script,
349492
349715
  variables = _a.variables,
349493
- artifacts = _a.artifacts,
349494
- def = __rest(_a, ["script", "variables", "artifacts"]);
349716
+ def = __rest(_a, ["script", "variables"]);
349495
349717
 
349496
349718
  return (0, lodash_1.merge)({
349497
349719
  name: constants_1.APP_BUILD_JOB_NAME,
@@ -349503,7 +349725,7 @@ var createBuildJob = function (context, _a) {
349503
349725
  variables: __assign(__assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
349504
349726
  script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, getBuildInfo_1.getBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_c = (0, utils_1.ensureArray)(script)) !== null && _c !== void 0 ? _c : []), false),
349505
349727
  artifacts: {
349506
- paths: __spreadArray([context.componentConfig.dir + "/__build_info.json", context.componentConfig.dir + "/" + reportingJob_1.INVENTORY_ARTIFACTS_DIR], __read((_d = artifacts === null || artifacts === void 0 ? void 0 : artifacts.paths) !== null && _d !== void 0 ? _d : []), false)
349728
+ paths: [context.componentConfig.dir + "/__build_info.json"]
349507
349729
  }
349508
349730
  }, def);
349509
349731
  };
@@ -349531,7 +349753,7 @@ exports.getBuildInfo = getBuildInfo;
349531
349753
 
349532
349754
  /***/ }),
349533
349755
 
349534
- /***/ 33219:
349756
+ /***/ 62644:
349535
349757
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
349536
349758
 
349537
349759
  "use strict";
@@ -349551,15 +349773,177 @@ var __assign = this && this.__assign || function () {
349551
349773
  return __assign.apply(this, arguments);
349552
349774
  };
349553
349775
 
349554
- var __rest = this && this.__rest || function (s, e) {
349555
- var t = {};
349776
+ var __read = this && this.__read || function (o, n) {
349777
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
349778
+ if (!m) return o;
349779
+ var i = m.call(o),
349780
+ r,
349781
+ ar = [],
349782
+ e;
349556
349783
 
349557
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
349784
+ try {
349785
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
349786
+ } catch (error) {
349787
+ e = {
349788
+ error: error
349789
+ };
349790
+ } finally {
349791
+ try {
349792
+ if (r && !r.done && (m = i["return"])) m.call(i);
349793
+ } finally {
349794
+ if (e) throw e.error;
349795
+ }
349796
+ }
349558
349797
 
349559
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
349560
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
349798
+ return ar;
349799
+ };
349800
+
349801
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
349802
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
349803
+ if (ar || !(i in from)) {
349804
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
349805
+ ar[i] = from[i];
349806
+ }
349561
349807
  }
349562
- return t;
349808
+ return to.concat(ar || Array.prototype.slice.call(from));
349809
+ };
349810
+
349811
+ exports.__esModule = true;
349812
+ exports.createCustomBuildJobs = void 0;
349813
+
349814
+ var path_1 = __nccwpck_require__(71017);
349815
+
349816
+ var utils_1 = __nccwpck_require__(37461);
349817
+
349818
+ var constants_1 = __nccwpck_require__(11542);
349819
+
349820
+ var createBuildJob_1 = __nccwpck_require__(58063);
349821
+
349822
+ var docker_1 = __nccwpck_require__(33219);
349823
+
349824
+ var types_1 = __nccwpck_require__(71197);
349825
+
349826
+ var RUNNER_BUILD_VARIABLES = {
349827
+ KUBERNETES_CPU_REQUEST: "0.5",
349828
+ KUBERNETES_CPU_LIMIT: "2",
349829
+ KUBERNETES_MEMORY_REQUEST: "2Gi",
349830
+ KUBERNETES_MEMORY_LIMIT: "4Gi"
349831
+ };
349832
+
349833
+ var createCustomBuildJobs = function (context) {
349834
+ var _a, _b, _c, _d;
349835
+
349836
+ var buildConfig = context.componentConfig.build;
349837
+
349838
+ if (!(0, types_1.isOfBuildType)(buildConfig, "custom")) {
349839
+ throw new Error("deploy config is not custom");
349840
+ }
349841
+
349842
+ var appBuildJob = buildConfig.buildCommand !== null ? (0, createBuildJob_1.createBuildJob)(context, {
349843
+ image: buildConfig.jobImage,
349844
+ variables: __assign({}, RUNNER_BUILD_VARIABLES),
349845
+ script: __spreadArray([], __read((_a = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _a !== void 0 ? _a : []), false),
349846
+ artifacts: {
349847
+ paths: __spreadArray([(0, path_1.join)(context.componentConfig.dir, "__build_info.json"), (0, path_1.join)(context.componentConfig.dir, "dist")], __read((_c = (_b = buildConfig.artifactsPaths) === null || _b === void 0 ? void 0 : _b.map(function (path) {
349848
+ return (0, path_1.join)(context.componentConfig.dir, path);
349849
+ })) !== null && _c !== void 0 ? _c : []), false)
349850
+ }
349851
+ }) : null;
349852
+ return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), __read((0, docker_1.requiresDockerBuild)(context) ? [(0, docker_1.createDockerBuildJobDefault)(context, {
349853
+ script: [((_d = buildConfig.docker) === null || _d === void 0 ? void 0 : _d.type) === "nginx" ? "ensureNginxDockerfile" : "" // e.g. custom,
349854
+ ].filter(Boolean),
349855
+ variables: {},
349856
+ needs: appBuildJob ? [constants_1.APP_BUILD_JOB_NAME] : []
349857
+ })] : []), false);
349858
+ };
349859
+
349860
+ exports.createCustomBuildJobs = createCustomBuildJobs;
349861
+
349862
+ /***/ }),
349863
+
349864
+ /***/ 53437:
349865
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
349866
+
349867
+ "use strict";
349868
+
349869
+
349870
+ var __read = this && this.__read || function (o, n) {
349871
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
349872
+ if (!m) return o;
349873
+ var i = m.call(o),
349874
+ r,
349875
+ ar = [],
349876
+ e;
349877
+
349878
+ try {
349879
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
349880
+ } catch (error) {
349881
+ e = {
349882
+ error: error
349883
+ };
349884
+ } finally {
349885
+ try {
349886
+ if (r && !r.done && (m = i["return"])) m.call(i);
349887
+ } finally {
349888
+ if (e) throw e.error;
349889
+ }
349890
+ }
349891
+
349892
+ return ar;
349893
+ };
349894
+
349895
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
349896
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
349897
+ if (ar || !(i in from)) {
349898
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
349899
+ ar[i] = from[i];
349900
+ }
349901
+ }
349902
+ return to.concat(ar || Array.prototype.slice.call(from));
349903
+ };
349904
+
349905
+ exports.__esModule = true;
349906
+ exports.createCustomJobs = void 0;
349907
+
349908
+ var buildJob_1 = __nccwpck_require__(62644);
349909
+
349910
+ var createCustomJobs = function (context) {
349911
+ return __spreadArray([], __read((0, buildJob_1.createCustomBuildJobs)(context)), false);
349912
+ };
349913
+
349914
+ exports.createCustomJobs = createCustomJobs;
349915
+
349916
+ /***/ }),
349917
+
349918
+ /***/ 33219:
349919
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
349920
+
349921
+ "use strict";
349922
+
349923
+
349924
+ var __assign = this && this.__assign || function () {
349925
+ __assign = Object.assign || function (t) {
349926
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
349927
+ s = arguments[i];
349928
+
349929
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
349930
+ }
349931
+
349932
+ return t;
349933
+ };
349934
+
349935
+ return __assign.apply(this, arguments);
349936
+ };
349937
+
349938
+ var __rest = this && this.__rest || function (s, e) {
349939
+ var t = {};
349940
+
349941
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
349942
+
349943
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
349944
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
349945
+ }
349946
+ return t;
349563
349947
  };
349564
349948
 
349565
349949
  var __read = this && this.__read || function (o, n) {
@@ -349736,6 +350120,8 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
349736
350120
  exports.__esModule = true;
349737
350121
  exports.BUILD_TYPES = void 0;
349738
350122
 
350123
+ var custom_1 = __nccwpck_require__(53437);
350124
+
349739
350125
  var node_1 = __nccwpck_require__(66994);
349740
350126
 
349741
350127
  __exportStar(__nccwpck_require__(71197), exports);
@@ -349775,6 +350161,12 @@ exports.BUILD_TYPES = {
349775
350161
  startCommand: "node main.js"
349776
350162
  };
349777
350163
  }
350164
+ },
350165
+ custom: {
350166
+ jobs: custom_1.createCustomJobs,
350167
+ defaults: function () {
350168
+ return {};
350169
+ }
349778
350170
  }
349779
350171
  };
349780
350172
 
@@ -349856,10 +350248,8 @@ var constants_2 = __nccwpck_require__(69284);
349856
350248
 
349857
350249
  var yarn_1 = __nccwpck_require__(10464);
349858
350250
 
349859
- var reportingJob_1 = __nccwpck_require__(89572);
349860
-
349861
350251
  var createNodeBuildJobs = function (context) {
349862
- var _a, _b, _c, _d, _e, _f, _g;
350252
+ var _a, _b, _c, _d, _e;
349863
350253
 
349864
350254
  var buildConfig = context.componentConfig.build;
349865
350255
 
@@ -349868,17 +350258,14 @@ var createNodeBuildJobs = function (context) {
349868
350258
  }
349869
350259
 
349870
350260
  var yarnInstall = (0, yarn_1.getYarnInstall)(context);
349871
- var yarnReportDependenciesListCommand = ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) ? "npm ls --depth 0 --json -prod | jq '.dependencies | to_entries | .[] | {artifact: .key, version: .value.version, type: \"npm\"}'" : "yarn info --json -A| jq '{version: .children.Version, artifact: .value, type: \"npm\" }'";
349872
- var debugcom = ((_b = context.packageManagerInfo) === null || _b === void 0 ? void 0 : _b.isClassic) ? "npm ls --depth 0 --json -prod" : "yarn info --json -A";
349873
- var yarnReportDependenciesCommand = ["mkdir -p ".concat(reportingJob_1.INVENTORY_ARTIFACTS_DIR_DEPENDENCIES), yarnReportDependenciesListCommand + " > " + reportingJob_1.INVENTORY_ARTIFACTS_DIR_DEPENDENCIES + "/app.jsonl"];
349874
350261
  var appBuildJob = buildConfig.buildCommand !== null ? (0, createBuildJob_1.createBuildJob)(context, {
349875
350262
  variables: __assign({}, constants_2.NODE_RUNNER_BUILD_VARIABLES),
349876
350263
  cache: __spreadArray(__spreadArray([], __read((0, cache_1.getNodeCache)(context)), false), __read((0, cache_1.getNextCache)(context)), false),
349877
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(yarnInstall), false), __read((_c = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _c !== void 0 ? _c : []), false), [debugcom], false), __read(yarnReportDependenciesCommand), false),
350264
+ script: __spreadArray(__spreadArray([], __read(yarnInstall), false), __read((_a = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _a !== void 0 ? _a : []), false),
349878
350265
  artifacts: {
349879
- paths: __spreadArray([(0, path_1.join)(context.componentConfig.dir, "dist"), (0, path_1.join)(context.componentConfig.dir, ".next")], __read((_e = (_d = buildConfig.artifactsPaths) === null || _d === void 0 ? void 0 : _d.map(function (path) {
350266
+ paths: __spreadArray([(0, path_1.join)(context.componentConfig.dir, "__build_info.json"), (0, path_1.join)(context.componentConfig.dir, "dist"), (0, path_1.join)(context.componentConfig.dir, ".next")], __read((_c = (_b = buildConfig.artifactsPaths) === null || _b === void 0 ? void 0 : _b.map(function (path) {
349880
350267
  return (0, path_1.join)(context.componentConfig.dir, path);
349881
- })) !== null && _e !== void 0 ? _e : []), false)
350268
+ })) !== null && _c !== void 0 ? _c : []), false)
349882
350269
  }
349883
350270
  }) : null;
349884
350271
  return __spreadArray(__spreadArray([], __read(appBuildJob ? [appBuildJob] : []), false), __read((0, docker_1.requiresDockerBuild)(context) ? [(0, docker_1.createDockerBuildJobDefault)(context, {
@@ -349893,9 +350280,9 @@ var createNodeBuildJobs = function (context) {
349893
350280
  prodOnly: true,
349894
350281
  noScripts: true
349895
350282
  }),
349896
- DOCKER_COPY_WORKSPACE_FILES: (_g = (_f = context.packageManagerInfo) === null || _f === void 0 ? void 0 : _f.pathsToCopyInDocker.map(function (dir) {
350283
+ DOCKER_COPY_WORKSPACE_FILES: (_e = (_d = context.packageManagerInfo) === null || _d === void 0 ? void 0 : _d.pathsToCopyInDocker.map(function (dir) {
349897
350284
  return "COPY --chown=node:node ".concat(dir, " /app/").concat(dir);
349898
- })) === null || _g === void 0 ? void 0 : _g.join("\n")
350285
+ })) === null || _e === void 0 ? void 0 : _e.join("\n")
349899
350286
  },
349900
350287
  needs: appBuildJob ? [constants_1.APP_BUILD_JOB_NAME] : []
349901
350288
  })] : []), false);
@@ -349952,14 +350339,21 @@ exports.getNextCache = exports.getNodeCache = exports.getNodeModulesCache = expo
349952
350339
  var path_1 = __nccwpck_require__(71017);
349953
350340
 
349954
350341
  var getYarnCache = function (context, policy) {
350342
+ var _a;
350343
+
349955
350344
  if (policy === void 0) {
349956
350345
  policy = "pull-push";
349957
350346
  }
349958
350347
 
349959
- return [{
350348
+ var componentIsInWorkspace = (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace;
350349
+ return [componentIsInWorkspace ? {
349960
350350
  key: "yarn",
349961
350351
  policy: policy,
349962
350352
  paths: [".yarn"]
350353
+ } : {
350354
+ key: context.componentConfig.dir + "-yarn",
350355
+ policy: policy,
350356
+ paths: [(0, path_1.join)(context.componentConfig.dir, ".yarn")]
349963
350357
  }];
349964
350358
  };
349965
350359
 
@@ -350367,7 +350761,7 @@ var getYarnInstallCommand = function (context, options) {
350367
350761
 
350368
350762
  return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
350369
350763
  });
350370
- return (options === null || options === void 0 ? void 0 : options.prodOnly) ? "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "").concat(doesNotShipWithBuiltInPlugins ? "yarn plugin import workspace-tools && " : " ", "yarn workspaces focus --production") // needs yarn plugin import workspace-tools
350764
+ return (options === null || options === void 0 ? void 0 : options.prodOnly) ? "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "").concat(doesNotShipWithBuiltInPlugins ? "yarn plugin import workspace-tools && " : " ", "yarn workspaces focus --production && yarn rebuild") // needs yarn plugin import workspace-tools
350371
350765
  : "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "", "yarn install --immutable");
350372
350766
  };
350373
350767
 
@@ -350611,31 +351005,75 @@ exports.readConfigSync = readConfigSync;
350611
351005
 
350612
351006
  exports.__esModule = true;
350613
351007
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
350614
- exports.PIPELINE_IMAGE_TAG = "inventory-2f61feef" || 0;
351008
+ exports.PIPELINE_IMAGE_TAG = "jdbc-e0855190" || 0;
350615
351009
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
350616
351010
 
350617
351011
  /***/ }),
350618
351012
 
350619
- /***/ 60740:
350620
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
351013
+ /***/ 25706:
351014
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
350621
351015
 
350622
351016
  "use strict";
350623
351017
 
350624
351018
 
350625
- var __assign = this && this.__assign || function () {
350626
- __assign = Object.assign || function (t) {
350627
- for (var s, i = 1, n = arguments.length; i < n; i++) {
350628
- s = arguments[i];
351019
+ exports.__esModule = true;
351020
+ exports.getEnvConfig = void 0;
350629
351021
 
350630
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
350631
- }
351022
+ var utils_1 = __nccwpck_require__(37461);
350632
351023
 
350633
- return t;
350634
- };
351024
+ var getEnvConfig = function (config, componentName, env) {
351025
+ var _a, _b;
350635
351026
 
350636
- return __assign.apply(this, arguments);
351027
+ var defaultConfig = config.components[componentName];
351028
+
351029
+ if (!defaultConfig) {
351030
+ throw new Error("unknown component " + componentName);
351031
+ }
351032
+
351033
+ var envCustomizations = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
351034
+
351035
+ if (envCustomizations === false) {
351036
+ throw new Error("env is disabled: " + env);
351037
+ }
351038
+
351039
+ return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
351040
+ };
351041
+
351042
+ exports.getEnvConfig = getEnvConfig;
351043
+
351044
+ /***/ }),
351045
+
351046
+ /***/ 94811:
351047
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
351048
+
351049
+ "use strict";
351050
+
351051
+
351052
+ exports.__esModule = true;
351053
+ exports.getEnvType = void 0;
351054
+
351055
+ var types_1 = __nccwpck_require__(71753);
351056
+
351057
+ var getEnvType = function (env, envConfig) {
351058
+ if (envConfig.type) return envConfig.type;
351059
+
351060
+ if ((0, types_1.isKnowEnvType)(env)) {
351061
+ return env;
351062
+ }
351063
+
351064
+ throw new Error("unknown env type: " + env);
350637
351065
  };
350638
351066
 
351067
+ exports.getEnvType = getEnvType;
351068
+
351069
+ /***/ }),
351070
+
351071
+ /***/ 60740:
351072
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
351073
+
351074
+ "use strict";
351075
+
351076
+
350639
351077
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
350640
351078
  function adopt(value) {
350641
351079
  return value instanceof P ? value : new P(function (resolve) {
@@ -350777,201 +351215,28 @@ var __generator = this && this.__generator || function (thisArg, body) {
350777
351215
  }
350778
351216
  };
350779
351217
 
350780
- var __read = this && this.__read || function (o, n) {
350781
- var m = typeof Symbol === "function" && o[Symbol.iterator];
350782
- if (!m) return o;
350783
- var i = m.call(o),
350784
- r,
350785
- ar = [],
350786
- e;
350787
-
350788
- try {
350789
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
350790
- } catch (error) {
350791
- e = {
350792
- error: error
350793
- };
350794
- } finally {
350795
- try {
350796
- if (r && !r.done && (m = i["return"])) m.call(i);
350797
- } finally {
350798
- if (e) throw e.error;
350799
- }
350800
- }
350801
-
350802
- return ar;
350803
- };
350804
-
350805
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
350806
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
350807
- if (ar || !(i in from)) {
350808
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
350809
- ar[i] = from[i];
350810
- }
350811
- }
350812
- return to.concat(ar || Array.prototype.slice.call(from));
350813
- };
350814
-
350815
- var __importDefault = this && this.__importDefault || function (mod) {
350816
- return mod && mod.__esModule ? mod : {
350817
- "default": mod
350818
- };
350819
- };
350820
-
350821
351218
  exports.__esModule = true;
350822
- exports.getEnvironment = exports.getSecretVarNameForContext = exports.getSecretVarName = void 0;
350823
-
350824
- var lodash_1 = __nccwpck_require__(23255);
350825
-
350826
- var slugify_1 = __importDefault(__nccwpck_require__(44035));
350827
-
350828
- var deploy_1 = __nccwpck_require__(90223);
350829
-
350830
- var types_1 = __nccwpck_require__(63109);
350831
-
350832
- var config_1 = __nccwpck_require__(19997);
350833
-
350834
- var utils_1 = __nccwpck_require__(37461);
350835
-
350836
- var resolveReferences_1 = __nccwpck_require__(80928);
350837
-
350838
- var sanitizeForEnVar = function (s) {
350839
- return s.replace(/-/g, "_");
350840
- };
350841
-
350842
- var getSecretVarName = function (env, componentName, key) {
350843
- return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
350844
- }; // remove dash from component name
350845
-
350846
-
350847
- exports.getSecretVarName = getSecretVarName;
350848
-
350849
- var addIndexVar = function (vars) {
350850
- return __assign(__assign({}, vars), {
350851
- _ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
350852
- });
350853
- };
351219
+ exports.getEnvironment = void 0;
350854
351220
 
350855
- var getSecretVarNameForContext = function (context, key) {
350856
- return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
350857
- };
350858
-
350859
- exports.getSecretVarNameForContext = getSecretVarNameForContext;
351221
+ var getEnvironmentContext_1 = __nccwpck_require__(95141);
350860
351222
 
350861
- var getEnvironment = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
350862
- ) {
350863
- if (alreadyVisited === void 0) {
350864
- alreadyVisited = {};
350865
- }
351223
+ var getEnvironmentVariables_1 = __nccwpck_require__(76602);
350866
351224
 
351225
+ var getEnvironment = function (config, componentName, env, commitInfo) {
350867
351226
  return __awaiter(void 0, void 0, void 0, function () {
350868
- var defaultConfig, envConfig, mergedConfig, envType, basePredefinedVariables, gitlabEnvironmentName, environmentSlug, predefinedVariables, host, url, fullName, devLocalConfig, port, componentSlug, envInUrl, domainCanonical, HOST_CANONICAL, KUBE_APP_NAME_PREFIX, KUBE_APP_NAME, KUBE_NAMESPACE, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
351227
+ var _a, envVars, secretEnvVarKeys, host, url, envContext, envType;
350869
351228
 
350870
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
350871
-
350872
- return __generator(this, function (_o) {
350873
- switch (_o.label) {
351229
+ return __generator(this, function (_b) {
351230
+ switch (_b.label) {
350874
351231
  case 0:
350875
- defaultConfig = config.components[componentName];
350876
-
350877
- if (!defaultConfig) {
350878
- throw new Error("unknown component " + componentName);
350879
- }
350880
-
350881
- envConfig = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
350882
-
350883
- if (envConfig === false) {
350884
- throw new Error("env is disabled: " + env);
350885
- }
350886
-
350887
- mergedConfig = (0, utils_1.mergeWithMergingArrays)(defaultConfig, envConfig);
350888
- envType = (_c = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _c !== void 0 ? _c : (0, config_1.isKnowEnvType)(env) ? env : null;
350889
-
350890
- if (!envType) {
350891
- throw new Error("Missing type in environment " + env + " in component " + componentName);
350892
- }
350893
-
350894
- basePredefinedVariables = {
350895
- ENV_SHORT: env,
350896
- APP_DIR: mergedConfig.dir,
350897
- ENV_TYPE: envType
350898
- };
350899
- gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
350900
- environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
350901
- fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
350902
-
350903
- if (envType === "local") {
350904
- devLocalConfig = mergedConfig;
350905
- port = (_d = devLocalConfig.port) !== null && _d !== void 0 ? _d : 3000;
350906
- host = "localhost:" + port;
350907
- url = "http://" + host;
350908
- predefinedVariables = {
350909
- ENV_SHORT: "local",
350910
- ROOT_URL: url,
350911
- PORT: port.toString()
350912
- };
350913
- } else {
350914
- componentSlug = (0, slugify_1["default"])(componentName);
350915
- envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
350916
- domainCanonical = (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy) && (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy.type) === "kubernetes" && ((_e = mergedConfig.deploy.cluster) === null || _e === void 0 ? void 0 : _e.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
350917
- config.domainCanonical || "panter.cloud";
350918
- HOST_CANONICAL = (0, types_1.isOfDeployType)(mergedConfig.deploy, "google-cloudrun") ? fullName.toLowerCase() + "-" + process.env[(0, exports.getSecretVarName)(env, componentName, deploy_1.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)] : "".concat(componentSlug, ".").concat(envInUrl, ".").concat(config.appName, ".").concat(config.customerName, ".").concat(domainCanonical);
350919
- host = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.host) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
350920
- url = "https://".concat(host);
350921
- KUBE_APP_NAME_PREFIX = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-") : "";
350922
- KUBE_APP_NAME = "".concat(KUBE_APP_NAME_PREFIX).concat(componentName);
350923
- KUBE_NAMESPACE = (0, deploy_1.getKubernetesNamespace)(config, env);
350924
- predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
350925
- HOST_CANONICAL: HOST_CANONICAL,
350926
- HOST: host,
350927
- ROOT_URL: url,
350928
- KUBE_NAMESPACE: KUBE_NAMESPACE,
350929
- KUBE_APP_NAME: KUBE_APP_NAME,
350930
- KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX
350931
- });
350932
- }
350933
-
350934
- publicEnvVarsRaw = (_h = (_g = mergedConfig.vars) === null || _g === void 0 ? void 0 : _g.public) !== null && _h !== void 0 ? _h : {};
350935
- additionalSecretKeys = mergedConfig.deploy ? deploy_1.DEPLOY_TYPES[mergedConfig.deploy.type].additionalSecretKeys( // eslint-disable-next-line @typescript-eslint/no-explicit-any
350936
- mergedConfig.deploy) : [];
350937
- secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_k = (_j = mergedConfig.vars) === null || _j === void 0 ? void 0 : _j.secret) !== null && _k !== void 0 ? _k : []), false), __read(additionalSecretKeys), false);
350938
- secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
350939
- return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
350940
- }));
350941
- legacyFromComponents = (_m = (_l = mergedConfig.vars) === null || _l === void 0 ? void 0 : _l.fromComponents) !== null && _m !== void 0 ? _m : {};
350942
- publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
350943
- publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
350944
- var _b = __read(_a, 2),
350945
- key = _b[0],
350946
- value = _b[1];
350947
-
350948
- return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
350949
- }));
350950
- envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
350951
351232
  return [4
350952
351233
  /*yield*/
350953
- , (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (componentName, variableName, alreadyVisited) {
350954
- return __awaiter(void 0, void 0, void 0, function () {
350955
- var envVars;
350956
- return __generator(this, function (_a) {
350957
- switch (_a.label) {
350958
- case 0:
350959
- return [4
350960
- /*yield*/
350961
- , (0, exports.getEnvironment)(config, componentName, env, commitInfo, alreadyVisited)];
350962
-
350963
- case 1:
350964
- envVars = _a.sent().envVars;
350965
- return [2
350966
- /*return*/
350967
- , envVars[variableName]];
350968
- }
350969
- });
350970
- });
350971
- }, alreadyVisited)];
351234
+ , (0, getEnvironmentVariables_1.getEnvironmentVariables)(config, componentName, env, commitInfo)];
350972
351235
 
350973
351236
  case 1:
350974
- envVars = _o.sent();
351237
+ _a = _b.sent(), envVars = _a.envVars, secretEnvVarKeys = _a.secretEnvVarKeys, host = _a.host, url = _a.url;
351238
+ envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
351239
+ envType = envContext.envType;
350975
351240
  return [2
350976
351241
  /*return*/
350977
351242
  , {
@@ -350979,11 +351244,11 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
350979
351244
  host: host,
350980
351245
  url: url,
350981
351246
  gitlabEnvironment: {
350982
- name: gitlabEnvironmentName,
351247
+ name: envContext.gitlabEnvironmentName,
350983
351248
  url: url
350984
351249
  },
350985
- fullName: fullName,
350986
- slug: environmentSlug,
351250
+ fullName: envContext.fullName,
351251
+ slug: envContext.environmentSlug,
350987
351252
  shortName: env,
350988
351253
  envVars: envVars,
350989
351254
  secretEnvVarKeys: secretEnvVarKeys
@@ -350997,6 +351262,378 @@ exports.getEnvironment = getEnvironment;
350997
351262
 
350998
351263
  /***/ }),
350999
351264
 
351265
+ /***/ 95141:
351266
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
351267
+
351268
+ "use strict";
351269
+
351270
+
351271
+ exports.__esModule = true;
351272
+ exports.getEnvironmentContext = void 0;
351273
+
351274
+ var getEnvConfig_1 = __nccwpck_require__(25706);
351275
+
351276
+ var getEnvType_1 = __nccwpck_require__(94811);
351277
+
351278
+ var getEnvironmentSlug = function (envConfig, env, componentName, commitInfo) {
351279
+ var envType = (0, getEnvType_1.getEnvType)(env, envConfig);
351280
+ return envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
351281
+ };
351282
+
351283
+ var getEnvironmentContext = function (config, env, componentName, commitInfo) {
351284
+ var envConfigRaw = (0, getEnvConfig_1.getEnvConfig)(config, componentName, env);
351285
+ var envType = (0, getEnvType_1.getEnvType)(env, envConfigRaw);
351286
+ var environmentSlug = getEnvironmentSlug(envConfigRaw, env, componentName, commitInfo);
351287
+ var gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
351288
+ var fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
351289
+ return {
351290
+ envConfigRaw: envConfigRaw,
351291
+ deployConfigRaw: envConfigRaw.deploy,
351292
+ buildConfigRaw: envConfigRaw.build,
351293
+ environmentSlug: environmentSlug,
351294
+ gitlabEnvironmentName: gitlabEnvironmentName,
351295
+ fullName: fullName,
351296
+ envType: envType,
351297
+ commitInfo: commitInfo,
351298
+ componentName: componentName,
351299
+ env: env,
351300
+ fullConfig: config
351301
+ };
351302
+ };
351303
+
351304
+ exports.getEnvironmentContext = getEnvironmentContext;
351305
+
351306
+ /***/ }),
351307
+
351308
+ /***/ 76602:
351309
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
351310
+
351311
+ "use strict";
351312
+
351313
+
351314
+ var __assign = this && this.__assign || function () {
351315
+ __assign = Object.assign || function (t) {
351316
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
351317
+ s = arguments[i];
351318
+
351319
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
351320
+ }
351321
+
351322
+ return t;
351323
+ };
351324
+
351325
+ return __assign.apply(this, arguments);
351326
+ };
351327
+
351328
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
351329
+ function adopt(value) {
351330
+ return value instanceof P ? value : new P(function (resolve) {
351331
+ resolve(value);
351332
+ });
351333
+ }
351334
+
351335
+ return new (P || (P = Promise))(function (resolve, reject) {
351336
+ function fulfilled(value) {
351337
+ try {
351338
+ step(generator.next(value));
351339
+ } catch (e) {
351340
+ reject(e);
351341
+ }
351342
+ }
351343
+
351344
+ function rejected(value) {
351345
+ try {
351346
+ step(generator["throw"](value));
351347
+ } catch (e) {
351348
+ reject(e);
351349
+ }
351350
+ }
351351
+
351352
+ function step(result) {
351353
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
351354
+ }
351355
+
351356
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
351357
+ });
351358
+ };
351359
+
351360
+ var __generator = this && this.__generator || function (thisArg, body) {
351361
+ var _ = {
351362
+ label: 0,
351363
+ sent: function () {
351364
+ if (t[0] & 1) throw t[1];
351365
+ return t[1];
351366
+ },
351367
+ trys: [],
351368
+ ops: []
351369
+ },
351370
+ f,
351371
+ y,
351372
+ t,
351373
+ g;
351374
+ return g = {
351375
+ next: verb(0),
351376
+ "throw": verb(1),
351377
+ "return": verb(2)
351378
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
351379
+ return this;
351380
+ }), g;
351381
+
351382
+ function verb(n) {
351383
+ return function (v) {
351384
+ return step([n, v]);
351385
+ };
351386
+ }
351387
+
351388
+ function step(op) {
351389
+ if (f) throw new TypeError("Generator is already executing.");
351390
+
351391
+ while (_) try {
351392
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
351393
+ if (y = 0, t) op = [op[0] & 2, t.value];
351394
+
351395
+ switch (op[0]) {
351396
+ case 0:
351397
+ case 1:
351398
+ t = op;
351399
+ break;
351400
+
351401
+ case 4:
351402
+ _.label++;
351403
+ return {
351404
+ value: op[1],
351405
+ done: false
351406
+ };
351407
+
351408
+ case 5:
351409
+ _.label++;
351410
+ y = op[1];
351411
+ op = [0];
351412
+ continue;
351413
+
351414
+ case 7:
351415
+ op = _.ops.pop();
351416
+
351417
+ _.trys.pop();
351418
+
351419
+ continue;
351420
+
351421
+ default:
351422
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
351423
+ _ = 0;
351424
+ continue;
351425
+ }
351426
+
351427
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
351428
+ _.label = op[1];
351429
+ break;
351430
+ }
351431
+
351432
+ if (op[0] === 6 && _.label < t[1]) {
351433
+ _.label = t[1];
351434
+ t = op;
351435
+ break;
351436
+ }
351437
+
351438
+ if (t && _.label < t[2]) {
351439
+ _.label = t[2];
351440
+
351441
+ _.ops.push(op);
351442
+
351443
+ break;
351444
+ }
351445
+
351446
+ if (t[2]) _.ops.pop();
351447
+
351448
+ _.trys.pop();
351449
+
351450
+ continue;
351451
+ }
351452
+
351453
+ op = body.call(thisArg, _);
351454
+ } catch (e) {
351455
+ op = [6, e];
351456
+ y = 0;
351457
+ } finally {
351458
+ f = t = 0;
351459
+ }
351460
+
351461
+ if (op[0] & 5) throw op[1];
351462
+ return {
351463
+ value: op[0] ? op[1] : void 0,
351464
+ done: true
351465
+ };
351466
+ }
351467
+ };
351468
+
351469
+ var __read = this && this.__read || function (o, n) {
351470
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
351471
+ if (!m) return o;
351472
+ var i = m.call(o),
351473
+ r,
351474
+ ar = [],
351475
+ e;
351476
+
351477
+ try {
351478
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
351479
+ } catch (error) {
351480
+ e = {
351481
+ error: error
351482
+ };
351483
+ } finally {
351484
+ try {
351485
+ if (r && !r.done && (m = i["return"])) m.call(i);
351486
+ } finally {
351487
+ if (e) throw e.error;
351488
+ }
351489
+ }
351490
+
351491
+ return ar;
351492
+ };
351493
+
351494
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
351495
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
351496
+ if (ar || !(i in from)) {
351497
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
351498
+ ar[i] = from[i];
351499
+ }
351500
+ }
351501
+ return to.concat(ar || Array.prototype.slice.call(from));
351502
+ };
351503
+
351504
+ exports.__esModule = true;
351505
+ exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironmentVariables = void 0;
351506
+
351507
+ var lodash_1 = __nccwpck_require__(23255);
351508
+
351509
+ var deploy_1 = __nccwpck_require__(90223);
351510
+
351511
+ var getEnvironmentContext_1 = __nccwpck_require__(95141);
351512
+
351513
+ var resolveReferences_1 = __nccwpck_require__(80928);
351514
+
351515
+ var getEnvironmentVariables = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
351516
+ ) {
351517
+ if (alreadyVisited === void 0) {
351518
+ alreadyVisited = {};
351519
+ }
351520
+
351521
+ return __awaiter(void 0, void 0, void 0, function () {
351522
+ var environmentContext, envConfigRaw, deployConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
351523
+
351524
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
351525
+
351526
+ return __generator(this, function (_k) {
351527
+ switch (_k.label) {
351528
+ case 0:
351529
+ environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
351530
+ envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, envType = environmentContext.envType;
351531
+ basePredefinedVariables = {
351532
+ ENV_SHORT: env,
351533
+ APP_DIR: envConfigRaw.dir,
351534
+ ENV_TYPE: envType
351535
+ };
351536
+
351537
+ if (envType === "local") {
351538
+ devLocalConfig = envConfigRaw;
351539
+ port = (_a = devLocalConfig.port) !== null && _a !== void 0 ? _a : 3000;
351540
+ host = "localhost:" + port;
351541
+ url = "http://" + host;
351542
+ predefinedVariables = {
351543
+ ENV_SHORT: "local",
351544
+ ROOT_URL: url,
351545
+ PORT: port.toString()
351546
+ };
351547
+ } else {
351548
+ additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
351549
+ host = (_c = (_b = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _b !== void 0 ? _b : additionalEnvVars.HOST_CANONICAL) !== null && _c !== void 0 ? _c : "unknown-host.example.com";
351550
+ url = "https://".concat(host);
351551
+ predefinedVariables = __assign(__assign(__assign({}, basePredefinedVariables), {
351552
+ HOST: host,
351553
+ ROOT_URL: url
351554
+ }), additionalEnvVars);
351555
+ }
351556
+
351557
+ publicEnvVarsRaw = (_e = (_d = envConfigRaw.vars) === null || _d === void 0 ? void 0 : _d.public) !== null && _e !== void 0 ? _e : {};
351558
+ additionalSecretKeys = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(environmentContext) : [];
351559
+ secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.secret) !== null && _g !== void 0 ? _g : []), false), __read(additionalSecretKeys), false);
351560
+ secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
351561
+ return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
351562
+ }));
351563
+ legacyFromComponents = (_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.fromComponents) !== null && _j !== void 0 ? _j : {};
351564
+ publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
351565
+ publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
351566
+ var _b = __read(_a, 2),
351567
+ key = _b[0],
351568
+ value = _b[1];
351569
+
351570
+ return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
351571
+ }));
351572
+ envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
351573
+ return [4
351574
+ /*yield*/
351575
+ , (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, variableName, alreadyVisited) {
351576
+ return __awaiter(void 0, void 0, void 0, function () {
351577
+ var otherEnvVars;
351578
+ return __generator(this, function (_a) {
351579
+ switch (_a.label) {
351580
+ case 0:
351581
+ return [4
351582
+ /*yield*/
351583
+ , (0, exports.getEnvironmentVariables)(config, otherComponentName, env, commitInfo, alreadyVisited)];
351584
+
351585
+ case 1:
351586
+ otherEnvVars = _a.sent().envVars;
351587
+ return [2
351588
+ /*return*/
351589
+ , otherEnvVars[variableName]];
351590
+ }
351591
+ });
351592
+ });
351593
+ }, alreadyVisited)];
351594
+
351595
+ case 1:
351596
+ envVars = _k.sent();
351597
+ return [2
351598
+ /*return*/
351599
+ , {
351600
+ envVars: envVars,
351601
+ secretEnvVarKeys: secretEnvVarKeys,
351602
+ host: host,
351603
+ url: url
351604
+ }];
351605
+ }
351606
+ });
351607
+ });
351608
+ };
351609
+
351610
+ exports.getEnvironmentVariables = getEnvironmentVariables;
351611
+
351612
+ var sanitizeForEnVar = function (s) {
351613
+ return s.replace(/-/g, "_");
351614
+ };
351615
+
351616
+ var getSecretVarName = function (env, componentName, key) {
351617
+ return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
351618
+ }; // remove dash from component name
351619
+
351620
+
351621
+ exports.getSecretVarName = getSecretVarName;
351622
+
351623
+ var addIndexVar = function (vars) {
351624
+ return __assign(__assign({}, vars), {
351625
+ _ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
351626
+ });
351627
+ };
351628
+
351629
+ var getSecretVarNameForContext = function (context, key) {
351630
+ return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
351631
+ };
351632
+
351633
+ exports.getSecretVarNameForContext = getSecretVarNameForContext;
351634
+
351635
+ /***/ }),
351636
+
351000
351637
  /***/ 30486:
351001
351638
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
351002
351639
 
@@ -351228,34 +351865,30 @@ var utils_1 = __nccwpck_require__(37461);
351228
351865
 
351229
351866
  var getEnvironment_1 = __nccwpck_require__(60740);
351230
351867
 
351868
+ var getEnvironmentContext_1 = __nccwpck_require__(95141);
351869
+
351231
351870
  __exportStar(__nccwpck_require__(60740), exports);
351232
351871
 
351872
+ __exportStar(__nccwpck_require__(76602), exports);
351873
+
351233
351874
  var createContext = function (config, componentName, env, commitInfo, packageManagerInfo) {
351234
351875
  return __awaiter(void 0, void 0, void 0, function () {
351235
- var rawConfig, envConfig, componentConfigWithoutDefaults, defaults, componentConfig;
351876
+ var envContext, componentConfigWithoutDefaults, defaults, componentConfig;
351236
351877
 
351237
351878
  var _a;
351238
351879
 
351239
- var _b, _c;
351240
-
351241
- return __generator(this, function (_d) {
351242
- switch (_d.label) {
351880
+ return __generator(this, function (_b) {
351881
+ switch (_b.label) {
351243
351882
  case 0:
351244
351883
  if (!/^[a-z0-9-]+$/.test(componentName)) {
351245
351884
  throw new Error("componentName may only contain lower case letters, numbers and -");
351246
351885
  }
351247
351886
 
351248
- rawConfig = config.components[componentName];
351249
-
351250
- if (!rawConfig) {
351251
- throw new Error("unknown component " + componentName);
351252
- }
351253
-
351254
- envConfig = (_c = (_b = rawConfig.env) === null || _b === void 0 ? void 0 : _b[env]) !== null && _c !== void 0 ? _c : {};
351255
- componentConfigWithoutDefaults = (0, utils_1.mergeWithMergingArrays)(rawConfig, envConfig);
351887
+ envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
351888
+ componentConfigWithoutDefaults = envContext.envConfigRaw;
351256
351889
  defaults = componentConfigWithoutDefaults.deploy ? {
351257
- build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(),
351258
- deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults()
351890
+ build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(envContext),
351891
+ deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults(envContext)
351259
351892
  } : {
351260
351893
  build: {},
351261
351894
  deploy: {}
@@ -351273,7 +351906,7 @@ var createContext = function (config, componentName, env, commitInfo, packageMan
351273
351906
  case 1:
351274
351907
  return [2
351275
351908
  /*return*/
351276
- , (_a.environment = _d.sent(), _a.commitInfo = commitInfo, _a.packageManagerInfo = packageManagerInfo, _a)];
351909
+ , (_a.environment = _b.sent(), _a.commitInfo = commitInfo, _a.packageManagerInfo = packageManagerInfo, _a)];
351277
351910
  }
351278
351911
  });
351279
351912
  });
@@ -351812,115 +352445,392 @@ var __read = this && this.__read || function (o, n) {
351812
352445
  return ar;
351813
352446
  };
351814
352447
 
351815
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
351816
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
351817
- if (ar || !(i in from)) {
351818
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
351819
- ar[i] = from[i];
351820
- }
351821
- }
351822
- return to.concat(ar || Array.prototype.slice.call(from));
351823
- };
351824
-
352448
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
352449
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
352450
+ if (ar || !(i in from)) {
352451
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
352452
+ ar[i] = from[i];
352453
+ }
352454
+ }
352455
+ return to.concat(ar || Array.prototype.slice.call(from));
352456
+ };
352457
+
352458
+ exports.__esModule = true;
352459
+ exports.createGoogleCloudRunDeployJobs = void 0;
352460
+
352461
+ var js_yaml_1 = __nccwpck_require__(3618);
352462
+
352463
+ var lodash_1 = __nccwpck_require__(23255);
352464
+
352465
+ var _1 = __nccwpck_require__(81344);
352466
+
352467
+ var docker_1 = __nccwpck_require__(33219);
352468
+
352469
+ var getLabels_1 = __nccwpck_require__(30486);
352470
+
352471
+ var runner_1 = __nccwpck_require__(55071);
352472
+
352473
+ var base_1 = __nccwpck_require__(89177);
352474
+
352475
+ var types_1 = __nccwpck_require__(63109);
352476
+
352477
+ var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(22607);
352478
+
352479
+ var database_1 = __nccwpck_require__(41384);
352480
+
352481
+ var gitlab_1 = __nccwpck_require__(84997);
352482
+
352483
+ var createGoogleCloudRunDeployJobs = function (context) {
352484
+ var _a;
352485
+
352486
+ var deployConfig = context.componentConfig.deploy;
352487
+
352488
+ if (deployConfig === false) {
352489
+ return [];
352490
+ }
352491
+
352492
+ if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
352493
+ // should not happen
352494
+ throw new Error("deploy config is wrong");
352495
+ }
352496
+
352497
+ var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
352498
+ var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
352499
+ var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
352500
+ var gcloudImageName = "".concat(dockerUrl, "/$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG");
352501
+
352502
+ var pushImageToArtifactsRegistry = __spreadArray(__spreadArray([docker_1.gitlabDockerLogin], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), ["gcloud auth configure-docker ".concat(deployConfig.region, "-docker.pkg.dev"), "docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG ".concat(gcloudImageName), "docker push ".concat(gcloudImageName)], false);
352503
+
352504
+ var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
352505
+ var labelsString = Object.entries((0, getLabels_1.getLabels)(context)).map(function (_a) {
352506
+ var _b = __read(_a, 2),
352507
+ key = _b[0],
352508
+ value = _b[1];
352509
+
352510
+ return "".concat(key, "=").concat(value);
352511
+ }).join(",");
352512
+ var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
352513
+ var cloudRunArgs = deployConfig.cloudSql ? "--set-cloudsql-instances=".concat(deployConfig.cloudSql.instanceConnectionName) : "";
352514
+ var commonDeployArgs = "--image ".concat(gcloudImageName, " ").concat(commonArgs, " ").concat(cloudRunArgs, " --labels ").concat(labelsString);
352515
+ var serviceName = context.environment.fullName.toLowerCase();
352516
+
352517
+ var getServiceDeployScript = function (service) {
352518
+ var _a;
352519
+
352520
+ var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
352521
+ var commandArg = command ? "--command=\"".concat(command.split(" ").join(","), "\"") : "";
352522
+ return "gcloud run deploy ".concat(serviceName, " ").concat(commandArg, " ").concat(commonDeployArgs, " --env-vars-file=____envvars.yaml --allow-unauthenticated");
352523
+ };
352524
+
352525
+ var getJobCreateScripts = function (jobName, job) {
352526
+ // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
352527
+ // lucky, update on the other hand accepts it... so let's just imediatly update it
352528
+ // also we cannot upsert a job, so we have to create it and catch the error and then update
352529
+ var args = "".concat(jobName, " --command=\"").concat(job.command.split(" ").join(","), "\" ").concat(commonDeployArgs, " --memory=").concat(job.memory || "512Mi");
352530
+ return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["gcloud beta run jobs create ".concat(args)])), false), ["gcloud beta run jobs update ".concat(args, " --env-vars-file=____envvars.yaml")], false);
352531
+ };
352532
+
352533
+ var getJobRunScript = function (jobName) {
352534
+ return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgs);
352535
+ };
352536
+
352537
+ var getFullJobName = function (name) {
352538
+ return context.environment.fullName.toLowerCase() + "-" + name.toLowerCase();
352539
+ };
352540
+
352541
+ var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {}) // filter out disabled jobs
352542
+ .filter(function (entry) {
352543
+ return Boolean(entry[1]);
352544
+ }).map(function (_a) {
352545
+ var _b = __read(_a, 2),
352546
+ name = _b[0],
352547
+ job = _b[1];
352548
+
352549
+ return [getFullJobName(name), job];
352550
+ });
352551
+
352552
+ var cloudRunDeployScripts = __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
352553
+ : []), false), __read(jobsWithNames.map(function (_a) {
352554
+ var _b = __read(_a, 2),
352555
+ name = _b[0],
352556
+ job = _b[1];
352557
+
352558
+ return getJobCreateScripts(name, job);
352559
+ }).flat()), false), __read(jobsWithNames.filter(function (_a) {
352560
+ var _b = __read(_a, 2),
352561
+ job = _b[1];
352562
+
352563
+ return job.when === "preDeploy";
352564
+ }).map(function (_a) {
352565
+ var _b = __read(_a, 1),
352566
+ name = _b[0];
352567
+
352568
+ return getJobRunScript(name);
352569
+ })), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(jobsWithNames.filter(function (_a) {
352570
+ var _b = __read(_a, 2),
352571
+ job = _b[1];
352572
+
352573
+ return job.when === "postDeploy";
352574
+ }).map(function (_a) {
352575
+ var _b = __read(_a, 1),
352576
+ name = _b[0];
352577
+
352578
+ return getJobRunScript(name);
352579
+ })), false), ["docker image rm ".concat(gcloudImageName)], false);
352580
+
352581
+ var cloudRunStopScripts = __spreadArray(__spreadArray(__spreadArray([], __read(deployConfig.service !== false ? ["gcloud run services delete ".concat(serviceName, " ").concat(commonArgs)] : []), false), __read(jobsWithNames.map(function (_a) {
352582
+ var _b = __read(_a, 1),
352583
+ name = _b[0];
352584
+
352585
+ return "gcloud beta run jobs delete ".concat(name, " ").concat(commonArgs);
352586
+ })), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false);
352587
+
352588
+ var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
352589
+ return [(0, lodash_1.merge)({}, baseDeploymentJob, (0, docker_1.getDockerJobBaseProps)(context), {
352590
+ artifacts: {
352591
+ paths: ["____envvars.yaml"]
352592
+ },
352593
+ variables: {
352594
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
352595
+ ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
352596
+ lineWidth: -1,
352597
+ quotingType: "'",
352598
+ forceQuotes: true
352599
+ })
352600
+ },
352601
+ image: (0, runner_1.getRunnerImage)("gcloud"),
352602
+ script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeployScripts), false)
352603
+ }), (0, lodash_1.merge)({}, baseStopJob, {
352604
+ image: (0, runner_1.getRunnerImage)("gcloud"),
352605
+ variables: {
352606
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1"
352607
+ },
352608
+ script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(cloudRunStopScripts), false)
352609
+ })];
352610
+ };
352611
+
352612
+ exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
352613
+
352614
+ /***/ }),
352615
+
352616
+ /***/ 81344:
352617
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
352618
+
352619
+ "use strict";
352620
+
352621
+
352622
+ var __assign = this && this.__assign || function () {
352623
+ __assign = Object.assign || function (t) {
352624
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
352625
+ s = arguments[i];
352626
+
352627
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
352628
+ }
352629
+
352630
+ return t;
352631
+ };
352632
+
352633
+ return __assign.apply(this, arguments);
352634
+ };
352635
+
352636
+ var __read = this && this.__read || function (o, n) {
352637
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
352638
+ if (!m) return o;
352639
+ var i = m.call(o),
352640
+ r,
352641
+ ar = [],
352642
+ e;
352643
+
352644
+ try {
352645
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
352646
+ } catch (error) {
352647
+ e = {
352648
+ error: error
352649
+ };
352650
+ } finally {
352651
+ try {
352652
+ if (r && !r.done && (m = i["return"])) m.call(i);
352653
+ } finally {
352654
+ if (e) throw e.error;
352655
+ }
352656
+ }
352657
+
352658
+ return ar;
352659
+ };
352660
+
352661
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
352662
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
352663
+ if (ar || !(i in from)) {
352664
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
352665
+ ar[i] = from[i];
352666
+ }
352667
+ }
352668
+ return to.concat(ar || Array.prototype.slice.call(from));
352669
+ };
352670
+
352671
+ exports.__esModule = true;
352672
+ exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
352673
+
352674
+ var context_1 = __nccwpck_require__(22041);
352675
+
352676
+ var gitlab_1 = __nccwpck_require__(84997);
352677
+
352678
+ var deployJob_1 = __nccwpck_require__(82256);
352679
+
352680
+ exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
352681
+ exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
352682
+
352683
+ var getCloudSqlVariables = function (_a) {
352684
+ var _b;
352685
+
352686
+ var deployConfigRaw = _a.deployConfigRaw,
352687
+ environmentSlug = _a.environmentSlug,
352688
+ env = _a.env,
352689
+ componentName = _a.componentName,
352690
+ fullConfig = _a.fullConfig;
352691
+
352692
+ if (deployConfigRaw && deployConfigRaw.cloudSql) {
352693
+ var DB_NAME = [(_b = deployConfigRaw.cloudSql.dbNamePrefix) !== null && _b !== void 0 ? _b : "".concat(fullConfig.customerName, "-").concat(fullConfig.appName), environmentSlug].filter(Boolean).join("-");
352694
+ return {
352695
+ CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
352696
+ DB_NAME: DB_NAME,
352697
+ DB_USER: "postgres",
352698
+ DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
352699
+ DATABASE_URL: "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME",
352700
+ DATABASE_JDBC_URL: "jdbc:postgresql:///$DB_NAME?cloudSqlInstance=$CLOUD_SQL_INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=$DB_USER&password=$DB_PASSWORD"
352701
+ };
352702
+ }
352703
+
352704
+ return {};
352705
+ };
352706
+
352707
+ exports.GCLOUD_RUN_DEPLOY_TYPE = {
352708
+ jobs: deployJob_1.createGoogleCloudRunDeployJobs,
352709
+ defaults: function (_a) {
352710
+ var deployConfigRaw = _a.deployConfigRaw,
352711
+ envType = _a.envType;
352712
+
352713
+ if (deployConfigRaw && deployConfigRaw.cloudSql) {
352714
+ return {
352715
+ cloudSql: {
352716
+ deleteDatabaseOnStop: envType === "review"
352717
+ }
352718
+ };
352719
+ }
352720
+
352721
+ return {};
352722
+ },
352723
+ additionalSecretKeys: function (ctx) {
352724
+ return __spreadArray([exports.GCLOUD_DEPLOY_CREDENTIALS_KEY], __read(ctx.deployConfigRaw && ctx.deployConfigRaw.cloudSql ? ["DB_PASSWORD"] : []), false);
352725
+ },
352726
+ getAdditionalEnvVars: function (ctx) {
352727
+ var fullName = ctx.fullName,
352728
+ env = ctx.env,
352729
+ componentName = ctx.componentName,
352730
+ deployConfigRaw = ctx.deployConfigRaw;
352731
+ var HOST_CANONICAL = fullName.toLowerCase() + "-" + process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)];
352732
+ var jobTriggers = deployConfigRaw && deployConfigRaw.jobs ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(function (_a) {
352733
+ var _b = __read(_a, 2),
352734
+ name = _b[0],
352735
+ job = _b[1];
352736
+
352737
+ return ["CLOUD_RUN_JOB_TRIGGER_URL_" + (0, gitlab_1.sanitizeForBashVariable)(name), "https://".concat(deployConfigRaw.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfigRaw.projectId, "/jobs/").concat(name, ":run")];
352738
+ })) : {};
352739
+ return __assign(__assign({
352740
+ HOST_CANONICAL: HOST_CANONICAL
352741
+ }, getCloudSqlVariables(ctx)), jobTriggers);
352742
+ }
352743
+ };
352744
+
352745
+ /***/ }),
352746
+
352747
+ /***/ 41384:
352748
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
352749
+
352750
+ "use strict";
352751
+
352752
+
352753
+ var __read = this && this.__read || function (o, n) {
352754
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
352755
+ if (!m) return o;
352756
+ var i = m.call(o),
352757
+ r,
352758
+ ar = [],
352759
+ e;
352760
+
352761
+ try {
352762
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
352763
+ } catch (error) {
352764
+ e = {
352765
+ error: error
352766
+ };
352767
+ } finally {
352768
+ try {
352769
+ if (r && !r.done && (m = i["return"])) m.call(i);
352770
+ } finally {
352771
+ if (e) throw e.error;
352772
+ }
352773
+ }
352774
+
352775
+ return ar;
352776
+ };
352777
+
351825
352778
  exports.__esModule = true;
351826
- exports.createDeployJob = void 0;
351827
-
351828
- var js_yaml_1 = __nccwpck_require__(3618);
351829
-
351830
- var lodash_1 = __nccwpck_require__(23255);
351831
-
351832
- var _1 = __nccwpck_require__(81344);
351833
-
351834
- var docker_1 = __nccwpck_require__(33219);
352779
+ exports.getDatabaseCreateScript = exports.getDatabaseDeleteScript = void 0;
351835
352780
 
351836
- var getLabels_1 = __nccwpck_require__(30486);
352781
+ var gitlab_1 = __nccwpck_require__(84997);
351837
352782
 
351838
- var runner_1 = __nccwpck_require__(55071);
351839
-
351840
- var base_1 = __nccwpck_require__(89177);
351841
-
351842
- var types_1 = __nccwpck_require__(63109);
351843
-
351844
- var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(22607);
351845
-
351846
- var createDeployJob = function (context) {
351847
- var deployConfig = context.componentConfig.deploy;
352783
+ var getDatabaseDeleteScript = function (context, deployConfig) {
352784
+ var _a;
351848
352785
 
351849
- if (deployConfig === false) {
351850
- return [];
352786
+ if (!deployConfig.cloudSql || !deployConfig.cloudSql.deleteDatabaseOnStop) {
352787
+ throw new Error("not possible");
351851
352788
  }
351852
352789
 
351853
- if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
351854
- // should not happen
351855
- throw new Error("deploy config is not custom");
352790
+ var DB_NAME = ((_a = context.environment.envVars) !== null && _a !== void 0 ? _a : {}).DB_NAME;
352791
+
352792
+ if (!DB_NAME) {
352793
+ throw new Error("error: env vars did not specify DB_NAME");
351856
352794
  }
351857
352795
 
351858
- var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
351859
- var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
351860
- var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
351861
- var gcloudImageName = "".concat(dockerUrl, "/$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG");
352796
+ var _b = __read(deployConfig.cloudSql.instanceConnectionName.split(":"), 3),
352797
+ projectId = _b[0],
352798
+ region = _b[1],
352799
+ instanceId = _b[2]; // unfortunatly the database cannot be deleted right after the service has stopped, as it might still have connections
352800
+ // we have to repeate this process
351862
352801
 
351863
- var pushImageToArtifactsRegistry = __spreadArray(__spreadArray([docker_1.gitlabDockerLogin], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), ["gcloud auth configure-docker ".concat(deployConfig.region, "-docker.pkg.dev"), "docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG ".concat(gcloudImageName), "docker push ".concat(gcloudImageName)], false);
351864
352802
 
351865
- var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
351866
- var serviceName = context.environment.fullName.toLowerCase();
351867
- var labelsString = Object.entries((0, getLabels_1.getLabels)(context)).map(function (_a) {
351868
- var _b = __read(_a, 2),
351869
- key = _b[0],
351870
- value = _b[1];
351871
-
351872
- return "".concat(key, "=").concat(value);
351873
- }).join(",");
351874
- var command = context.componentConfig.build.startCommand ? "--command=\"".concat(context.componentConfig.build.startCommand.split(" ").join(","), "\"") : ""; // TODO: split secrets out
351875
-
351876
- var cloudRunDeploy = ["echo \"$ENV_VARS\" > ____envvars.yaml", "gcloud run deploy ".concat(serviceName, " --image ").concat(gcloudImageName, " --region=").concat(deployConfig.region, " --allow-unauthenticated --project ").concat(deployConfig.projectId, " ").concat(command, " --env-vars-file=____envvars.yaml --labels ").concat(labelsString), "docker image rm ".concat(gcloudImageName)];
351877
- var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
351878
- return [(0, lodash_1.merge)({}, baseDeploymentJob, (0, docker_1.getDockerJobBaseProps)(context), {
351879
- artifacts: {
351880
- paths: ["____envvars.yaml"]
351881
- },
351882
- variables: {
351883
- ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
351884
- lineWidth: -1,
351885
- quotingType: "'",
351886
- forceQuotes: true
351887
- })
351888
- },
351889
- image: (0, runner_1.getRunnerImage)("gcloud"),
351890
- script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeploy), false)
351891
- }), (0, lodash_1.merge)({}, baseStopJob, {
351892
- image: (0, runner_1.getRunnerImage)("gcloud"),
351893
- script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), ["gcloud run services delete ".concat(serviceName, " --project ").concat(deployConfig.projectId, " --region=").concat(deployConfig.region, " --quiet")], false)
352803
+ return ["echo \"deleting database ".concat(DB_NAME, "...\""), "echo \"\uD83D\uDC46 this can take multiple attemps (3-5min), because google cloud run may still have a connection to the database after the cloud run service is shut down\"", (0, gitlab_1.repeatOnFailure)("gcloud sql databases delete ".concat(DB_NAME, " --instance=").concat(instanceId, " --project ").concat(projectId), {
352804
+ pauseInSeconds: 10
351894
352805
  })];
351895
352806
  };
351896
352807
 
351897
- exports.createDeployJob = createDeployJob;
352808
+ exports.getDatabaseDeleteScript = getDatabaseDeleteScript;
351898
352809
 
351899
- /***/ }),
352810
+ var getDatabaseCreateScript = function (context, deployConfig) {
352811
+ var _a;
351900
352812
 
351901
- /***/ 81344:
351902
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
352813
+ if (!deployConfig.cloudSql) {
352814
+ throw new Error("not possible");
352815
+ }
351903
352816
 
351904
- "use strict";
352817
+ var DB_NAME = ((_a = context.environment.envVars) !== null && _a !== void 0 ? _a : {}).DB_NAME;
351905
352818
 
352819
+ if (!DB_NAME) {
352820
+ throw new Error("error: env vars did not specify DB_NAME");
352821
+ }
351906
352822
 
351907
- exports.__esModule = true;
351908
- exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
352823
+ var _b = __read(deployConfig.cloudSql.instanceConnectionName.split(":"), 3),
352824
+ projectId = _b[0],
352825
+ region = _b[1],
352826
+ instanceId = _b[2]; // may fail if it already exists
351909
352827
 
351910
- var deployJob_1 = __nccwpck_require__(82256);
351911
352828
 
351912
- exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
351913
- exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
351914
- exports.GCLOUD_RUN_DEPLOY_TYPE = {
351915
- jobs: deployJob_1.createDeployJob,
351916
- defaults: function () {
351917
- return {};
351918
- },
351919
- additionalSecretKeys: function () {
351920
- return [exports.GCLOUD_DEPLOY_CREDENTIALS_KEY];
351921
- }
352829
+ return (0, gitlab_1.allowFailureInScripts)(["echo \"ensuring Database...\"", "gcloud sql databases create ".concat(DB_NAME, " --instance=").concat(instanceId, " --project ").concat(projectId)]);
351922
352830
  };
351923
352831
 
352832
+ exports.getDatabaseCreateScript = getDatabaseCreateScript;
352833
+
351924
352834
  /***/ }),
351925
352835
 
351926
352836
  /***/ 22607:
@@ -351944,43 +352854,6 @@ exports.gcloudServiceAccountLoginCommands = gcloudServiceAccountLoginCommands;
351944
352854
 
351945
352855
  /***/ }),
351946
352856
 
351947
- /***/ 13539:
351948
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
351949
-
351950
- "use strict";
351951
-
351952
-
351953
- exports.__esModule = true;
351954
- exports.getCloudSQLConfig = exports.hasCloudSQL = void 0;
351955
-
351956
- var types_1 = __nccwpck_require__(63109);
351957
-
351958
- var hasCloudSQL = function (context) {
351959
- var _a, _b;
351960
-
351961
- if ((0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
351962
- return (_b = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.cloudsql) === null || _b === void 0 ? void 0 : _b.enabled;
351963
- }
351964
-
351965
- return false;
351966
- };
351967
-
351968
- exports.hasCloudSQL = hasCloudSQL;
351969
-
351970
- var getCloudSQLConfig = function (context) {
351971
- var _a;
351972
-
351973
- if ((0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
351974
- return (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.cloudsql;
351975
- }
351976
-
351977
- throw new Error("cannot get cloud sql config");
351978
- };
351979
-
351980
- exports.getCloudSQLConfig = getCloudSQLConfig;
351981
-
351982
- /***/ }),
351983
-
351984
352857
  /***/ 16531:
351985
352858
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
351986
352859
 
@@ -352074,6 +352947,9 @@ exports.CUSTOM_DEPLOY_TYPE = {
352074
352947
  },
352075
352948
  additionalSecretKeys: function () {
352076
352949
  return [];
352950
+ },
352951
+ getAdditionalEnvVars: function () {
352952
+ return {};
352077
352953
  }
352078
352954
  };
352079
352955
 
@@ -352137,6 +353013,9 @@ exports.DOCKER_TAG_DEPLOY_TYPE = {
352137
353013
  },
352138
353014
  additionalSecretKeys: function () {
352139
353015
  return [];
353016
+ },
353017
+ getAdditionalEnvVars: function () {
353018
+ return {};
352140
353019
  }
352141
353020
  };
352142
353021
 
@@ -352176,21 +353055,19 @@ var dockerTag_1 = __nccwpck_require__(18990);
352176
353055
 
352177
353056
  var kubernetes_1 = __nccwpck_require__(95682);
352178
353057
 
353058
+ __exportStar(__nccwpck_require__(81344), exports);
353059
+
352179
353060
  __exportStar(__nccwpck_require__(95682), exports);
352180
353061
 
352181
353062
  __exportStar(__nccwpck_require__(63109), exports);
352182
353063
 
352183
353064
  __exportStar(__nccwpck_require__(92757), exports);
352184
353065
 
352185
- __exportStar(__nccwpck_require__(13539), exports);
352186
-
352187
- __exportStar(__nccwpck_require__(81344), exports);
352188
-
352189
353066
  exports.DEPLOY_TYPES = {
352190
353067
  kubernetes: kubernetes_1.KUBERNETES_DEPLOY_TYPE,
352191
353068
  custom: custom_1.CUSTOM_DEPLOY_TYPE,
352192
- "google-cloudrun": cloudRun_1.GCLOUD_RUN_DEPLOY_TYPE,
352193
- dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE
353069
+ dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE,
353070
+ "google-cloudrun": cloudRun_1.GCLOUD_RUN_DEPLOY_TYPE
352194
353071
  };
352195
353072
 
352196
353073
  /***/ }),
@@ -352204,20 +353081,26 @@ exports.DEPLOY_TYPES = {
352204
353081
  exports.__esModule = true;
352205
353082
  exports.additionalKubernetesSecretKeys = void 0;
352206
353083
 
352207
- var additionalKubernetesSecretKeys = function (config) {
352208
- var _a, _b, _c, _d;
353084
+ var additionalKubernetesSecretKeys = function (_a) {
353085
+ var _b, _c, _d, _e;
353086
+
353087
+ var deployConfigRaw = _a.deployConfigRaw;
353088
+
353089
+ if (!deployConfigRaw) {
353090
+ return [];
353091
+ }
352209
353092
 
352210
353093
  var keys = [];
352211
353094
 
352212
- if ((_b = (_a = config.values) === null || _a === void 0 ? void 0 : _a.mongodb) === null || _b === void 0 ? void 0 : _b.enabled) {
353095
+ if ((_c = (_b = deployConfigRaw.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) {
352213
353096
  keys.push("MONGODB_ROOT_PASSWORD");
352214
353097
 
352215
- if (config.values.mongodb.architecture === "replicaset") {
353098
+ if (deployConfigRaw.values.mongodb.architecture === "replicaset") {
352216
353099
  keys.push("MONGODB_REPLICASET_KEY");
352217
353100
  }
352218
353101
  }
352219
353102
 
352220
- if ((_d = (_c = config.values) === null || _c === void 0 ? void 0 : _c.cloudsql) === null || _d === void 0 ? void 0 : _d.enabled) {
353103
+ if ((_e = (_d = deployConfigRaw.values) === null || _d === void 0 ? void 0 : _d.cloudsql) === null || _e === void 0 ? void 0 : _e.enabled) {
352221
353104
  keys.push("POSTGRESQL_PASSWORD");
352222
353105
  keys.push("cloudsqlProxyCredentials");
352223
353106
  }
@@ -352229,21 +353112,47 @@ exports.additionalKubernetesSecretKeys = additionalKubernetesSecretKeys;
352229
353112
 
352230
353113
  /***/ }),
352231
353114
 
352232
- /***/ 395:
353115
+ /***/ 11925:
352233
353116
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
352234
353117
 
352235
353118
  "use strict";
352236
353119
 
352237
353120
 
352238
353121
  exports.__esModule = true;
352239
- exports.createCloudsqlBaseConfig = void 0;
353122
+ exports.createCloudsqlBaseConfig = exports.getKubernetesCloudSQLConfig = exports.hasKubernetesCloudSQL = void 0;
352240
353123
 
352241
- var __1 = __nccwpck_require__(25355);
353124
+ var context_1 = __nccwpck_require__(22041);
353125
+
353126
+ var types_1 = __nccwpck_require__(63109);
353127
+
353128
+ var hasKubernetesCloudSQL = function (context) {
353129
+ var _a, _b;
353130
+
353131
+ if ((0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
353132
+ return (_b = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.cloudsql) === null || _b === void 0 ? void 0 : _b.enabled;
353133
+ }
353134
+
353135
+ return false;
353136
+ };
353137
+
353138
+ exports.hasKubernetesCloudSQL = hasKubernetesCloudSQL;
353139
+
353140
+ var getKubernetesCloudSQLConfig = function (context) {
353141
+ var _a;
353142
+
353143
+ if ((0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
353144
+ return (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.cloudsql;
353145
+ }
353146
+
353147
+ throw new Error("cannot get cloud sql config");
353148
+ };
353149
+
353150
+ exports.getKubernetesCloudSQLConfig = getKubernetesCloudSQLConfig;
352242
353151
 
352243
353152
  var createCloudsqlBaseConfig = function (context) {
352244
353153
  return {
352245
353154
  cloudsql: {
352246
- proxyCredentials: "$".concat((0, __1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"))
353155
+ proxyCredentials: "$".concat((0, context_1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"))
352247
353156
  }
352248
353157
  };
352249
353158
  };
@@ -352387,24 +353296,78 @@ exports.createKubernetesDeployJobs = createKubernetesDeployJobs;
352387
353296
  /***/ }),
352388
353297
 
352389
353298
  /***/ 95682:
352390
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
353299
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
352391
353300
 
352392
353301
  "use strict";
352393
353302
 
352394
353303
 
353304
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
353305
+ if (k2 === undefined) k2 = k;
353306
+ Object.defineProperty(o, k2, {
353307
+ enumerable: true,
353308
+ get: function () {
353309
+ return m[k];
353310
+ }
353311
+ });
353312
+ } : function (o, m, k, k2) {
353313
+ if (k2 === undefined) k2 = k;
353314
+ o[k2] = m[k];
353315
+ });
353316
+
353317
+ var __exportStar = this && this.__exportStar || function (m, exports) {
353318
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
353319
+ };
353320
+
353321
+ var __importDefault = this && this.__importDefault || function (mod) {
353322
+ return mod && mod.__esModule ? mod : {
353323
+ "default": mod
353324
+ };
353325
+ };
353326
+
352395
353327
  exports.__esModule = true;
352396
353328
  exports.KUBERNETES_DEPLOY_TYPE = void 0;
352397
353329
 
353330
+ var slugify_1 = __importDefault(__nccwpck_require__(44035));
353331
+
353332
+ var __1 = __nccwpck_require__(90223);
353333
+
352398
353334
  var additionalSecretKeys_1 = __nccwpck_require__(75775);
352399
353335
 
352400
353336
  var deployJob_1 = __nccwpck_require__(9792);
352401
353337
 
353338
+ __exportStar(__nccwpck_require__(11925), exports);
353339
+
352402
353340
  exports.KUBERNETES_DEPLOY_TYPE = {
352403
353341
  jobs: deployJob_1.createKubernetesDeployJobs,
352404
353342
  defaults: function () {
352405
353343
  return {};
352406
353344
  },
352407
- additionalSecretKeys: additionalSecretKeys_1.additionalKubernetesSecretKeys
353345
+ additionalSecretKeys: additionalSecretKeys_1.additionalKubernetesSecretKeys,
353346
+ getAdditionalEnvVars: function (_a) {
353347
+ var _b;
353348
+
353349
+ var componentName = _a.componentName,
353350
+ fullConfig = _a.fullConfig,
353351
+ deployConfigRaw = _a.deployConfigRaw,
353352
+ env = _a.env,
353353
+ envType = _a.envType,
353354
+ commitInfo = _a.commitInfo;
353355
+ var KUBE_APP_NAME_PREFIX = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-") : "";
353356
+ var KUBE_APP_NAME = "".concat(KUBE_APP_NAME_PREFIX).concat(componentName);
353357
+ var KUBE_NAMESPACE = (0, __1.getKubernetesNamespace)(fullConfig, env);
353358
+ var componentSlug = (0, slugify_1["default"])(componentName);
353359
+ var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
353360
+ var domainCanonical = deployConfigRaw && ((_b = deployConfigRaw.cluster) === null || _b === void 0 ? void 0 : _b.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
353361
+ fullConfig.domainCanonical || "panter.cloud";
353362
+ var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(fullConfig.appName, ".").concat(fullConfig.customerName, ".").concat(domainCanonical); // default for kubernetes and rest
353363
+
353364
+ return {
353365
+ KUBE_NAMESPACE: KUBE_NAMESPACE,
353366
+ KUBE_APP_NAME: KUBE_APP_NAME,
353367
+ KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX,
353368
+ HOST_CANONICAL: HOST_CANONICAL
353369
+ };
353370
+ }
352408
353371
  };
352409
353372
 
352410
353373
  /***/ }),
@@ -352530,11 +353493,9 @@ var lodash_1 = __nccwpck_require__(23255);
352530
353493
 
352531
353494
  var utils_1 = __nccwpck_require__(37461);
352532
353495
 
352533
- var cloudSql_1 = __nccwpck_require__(13539);
352534
-
352535
353496
  var types_1 = __nccwpck_require__(63109);
352536
353497
 
352537
- var cloudsql_1 = __nccwpck_require__(395);
353498
+ var cloudSql_1 = __nccwpck_require__(11925);
352538
353499
 
352539
353500
  var kubeEnv_1 = __nccwpck_require__(19449);
352540
353501
 
@@ -352600,7 +353561,7 @@ var createKubeValues = function (context) {
352600
353561
  var defaultKubeValues = (0, lodash_1.merge)({
352601
353562
  env: env,
352602
353563
  application: createAppConfig(context, application)
352603
- }, (0, cloudSql_1.hasCloudSQL)(context) ? (0, cloudsql_1.createCloudsqlBaseConfig)(context) : {}, ((_b = (_a = deployConfig.values) === null || _a === void 0 ? void 0 : _a.mongodb) === null || _b === void 0 ? void 0 : _b.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
353564
+ }, (0, cloudSql_1.hasKubernetesCloudSQL)(context) ? (0, cloudSql_1.createCloudsqlBaseConfig)(context) : {}, ((_b = (_a = deployConfig.values) === null || _a === void 0 ? void 0 : _a.mongodb) === null || _b === void 0 ? void 0 : _b.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
352604
353565
  var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, rest));
352605
353566
  return kubeValues;
352606
353567
  };
@@ -352973,57 +353934,6 @@ __exportStar(__nccwpck_require__(90223), exports);
352973
353934
 
352974
353935
  /***/ }),
352975
353936
 
352976
- /***/ 89572:
352977
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
352978
-
352979
- "use strict";
352980
-
352981
-
352982
- exports.__esModule = true;
352983
- exports.createInventoryReporitngJob = exports.INVENTORY_ARTIFACTS_DIR_DEPENDENCIES = exports.INVENTORY_ARTIFACTS_DIR = void 0;
352984
-
352985
- var lodash_1 = __nccwpck_require__(23255);
352986
-
352987
- var path_1 = __nccwpck_require__(71017);
352988
-
352989
- exports.INVENTORY_ARTIFACTS_DIR = "__cl__reporting";
352990
- exports.INVENTORY_ARTIFACTS_DIR_DEPENDENCIES = (0, path_1.join)(exports.INVENTORY_ARTIFACTS_DIR, "dependencies");
352991
-
352992
- var createInventoryReporitngJob = function (context) {
352993
- var inventoryTemplate = {
352994
- repository: {
352995
- projectId: process.env.CI_PROJECT_ID,
352996
- url: process.env.CI_PROJECT_URL
352997
- },
352998
- appName: context.fullConfig.appName,
352999
- customerName: context.fullConfig.customerName,
353000
- componentName: context.componentName,
353001
- environment: (0, lodash_1.pick)(context.environment, ["shortName", "fullName", "host", "url"]),
353002
- build: context.componentConfig.build,
353003
- deploy: context.componentConfig.deploy,
353004
- packageManager: context.packageManagerInfo
353005
- };
353006
- var printReportComand = "echo '".concat(JSON.stringify(inventoryTemplate), "' | jq --argjson dependencies \"$(cat ").concat(exports.INVENTORY_ARTIFACTS_DIR_DEPENDENCIES, "/* | jq -n '. |= [inputs]')\" '. + {dependencies: $dependencies}'");
353007
- return {
353008
- envMode: "jobPerEnv",
353009
- name: "inventory:reporting",
353010
- stage: "reporting",
353011
- variables: {},
353012
- script: ["cd ".concat(context.componentConfig.dir), printReportComand],
353013
- needsStages: [{
353014
- stage: "build",
353015
- artifacts: true
353016
- }, {
353017
- stage: "deploy",
353018
- artifacts: true
353019
- }]
353020
- };
353021
- };
353022
-
353023
- exports.createInventoryReporitngJob = createInventoryReporitngJob;
353024
-
353025
- /***/ }),
353026
-
353027
353937
  /***/ 78974:
353028
353938
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
353029
353939
 
@@ -353526,8 +354436,6 @@ var context_1 = __nccwpck_require__(22041);
353526
354436
 
353527
354437
  var deploy_1 = __nccwpck_require__(90223);
353528
354438
 
353529
- var reportingJob_1 = __nccwpck_require__(89572);
353530
-
353531
354439
  var utils_1 = __nccwpck_require__(37461);
353532
354440
 
353533
354441
  var makeGitlabJob_1 = __nccwpck_require__(15715);
@@ -353564,8 +354472,7 @@ var createRawJobs = function (context) {
353564
354472
  var buildJobs = build_1.BUILD_TYPES[context.componentConfig.build.type].jobs(context);
353565
354473
  var deployJobs = deploy_1.DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context);
353566
354474
  var customJobs = getCustomJobs(context);
353567
- var reportInventoryJob = (0, reportingJob_1.createInventoryReporitngJob)(context);
353568
- return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false), __read(customJobs), false), [reportInventoryJob], false);
354475
+ return __spreadArray(__spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false), __read(customJobs), false);
353569
354476
  };
353570
354477
 
353571
354478
  var getFullJobName = function (name, componentName, env) {
@@ -354388,7 +355295,7 @@ __exportStar(__nccwpck_require__(63146), exports);
354388
355295
 
354389
355296
  exports.__esModule = true;
354390
355297
  exports.BASE_STAGES = void 0;
354391
- exports.BASE_STAGES = ["setup", "test", "build", "deploy", "verify", "rollback", "stop", "reporting"];
355298
+ exports.BASE_STAGES = ["setup", "test", "build", "deploy", "verify", "rollback", "stop"];
354392
355299
 
354393
355300
  /***/ }),
354394
355301
 
@@ -354402,6 +355309,71 @@ exports.__esModule = true;
354402
355309
 
354403
355310
  /***/ }),
354404
355311
 
355312
+ /***/ 84997:
355313
+ /***/ (function(__unused_webpack_module, exports) {
355314
+
355315
+ "use strict";
355316
+
355317
+
355318
+ var __read = this && this.__read || function (o, n) {
355319
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
355320
+ if (!m) return o;
355321
+ var i = m.call(o),
355322
+ r,
355323
+ ar = [],
355324
+ e;
355325
+
355326
+ try {
355327
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
355328
+ } catch (error) {
355329
+ e = {
355330
+ error: error
355331
+ };
355332
+ } finally {
355333
+ try {
355334
+ if (r && !r.done && (m = i["return"])) m.call(i);
355335
+ } finally {
355336
+ if (e) throw e.error;
355337
+ }
355338
+ }
355339
+
355340
+ return ar;
355341
+ };
355342
+
355343
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
355344
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
355345
+ if (ar || !(i in from)) {
355346
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
355347
+ ar[i] = from[i];
355348
+ }
355349
+ }
355350
+ return to.concat(ar || Array.prototype.slice.call(from));
355351
+ };
355352
+
355353
+ exports.__esModule = true;
355354
+ exports.repeatOnFailure = exports.sanitizeForBashVariable = exports.allowFailureInScripts = void 0;
355355
+
355356
+ var allowFailureInScripts = function (script) {
355357
+ return __spreadArray(__spreadArray(["set +e"], __read(script), false), ["set -e" // reenable
355358
+ ], false);
355359
+ };
355360
+
355361
+ exports.allowFailureInScripts = allowFailureInScripts;
355362
+
355363
+ var sanitizeForBashVariable = function (name) {
355364
+ return name.replace(/-/g, "_");
355365
+ };
355366
+
355367
+ exports.sanitizeForBashVariable = sanitizeForBashVariable;
355368
+
355369
+ var repeatOnFailure = function (command, options) {
355370
+ return "\n until ".concat(command, " &> /dev/null\n do\n echo \"Trying again.\"\n sleep ").concat(options.pauseInSeconds, "\n done\n ");
355371
+ };
355372
+
355373
+ exports.repeatOnFailure = repeatOnFailure;
355374
+
355375
+ /***/ }),
355376
+
354405
355377
  /***/ 37461:
354406
355378
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
354407
355379