@catladder/pipeline 0.0.0-main-e651ab49 → 0.0.0-main-0009a81d

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.
@@ -28177,7 +28177,7 @@ exports.readConfigSync = readConfigSync;
28177
28177
 
28178
28178
  exports.__esModule = true;
28179
28179
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
28180
- exports.PIPELINE_IMAGE_TAG = "main-e651ab49" || 0;
28180
+ exports.PIPELINE_IMAGE_TAG = "main-0009a81d" || 0;
28181
28181
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
28182
28182
 
28183
28183
  /***/ }),
@@ -28378,52 +28378,19 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
28378
28378
  return to.concat(ar || Array.prototype.slice.call(from));
28379
28379
  };
28380
28380
 
28381
- var __importDefault = this && this.__importDefault || function (mod) {
28382
- return mod && mod.__esModule ? mod : {
28383
- "default": mod
28384
- };
28385
- };
28386
-
28387
28381
  exports.__esModule = true;
28388
- exports.getEnvironment = exports.getSecretVarNameForContext = exports.getSecretVarName = void 0;
28382
+ exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironment = void 0;
28389
28383
 
28390
28384
  var lodash_1 = __nccwpck_require__(3255);
28391
28385
 
28392
- var slugify_1 = __importDefault(__nccwpck_require__(4035));
28393
-
28394
28386
  var deploy_1 = __nccwpck_require__(1264);
28395
28387
 
28396
- var types_1 = __nccwpck_require__(4436);
28397
-
28398
28388
  var config_1 = __nccwpck_require__(325);
28399
28389
 
28400
28390
  var utils_1 = __nccwpck_require__(1815);
28401
28391
 
28402
28392
  var resolveReferences_1 = __nccwpck_require__(540);
28403
28393
 
28404
- var sanitizeForEnVar = function (s) {
28405
- return s.replace(/-/g, "_");
28406
- };
28407
-
28408
- var getSecretVarName = function (env, componentName, key) {
28409
- return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
28410
- }; // remove dash from component name
28411
-
28412
-
28413
- exports.getSecretVarName = getSecretVarName;
28414
-
28415
- var addIndexVar = function (vars) {
28416
- return __assign(__assign({}, vars), {
28417
- _ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
28418
- });
28419
- };
28420
-
28421
- var getSecretVarNameForContext = function (context, key) {
28422
- return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
28423
- };
28424
-
28425
- exports.getSecretVarNameForContext = getSecretVarNameForContext;
28426
-
28427
28394
  var getEnvironment = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
28428
28395
  ) {
28429
28396
  if (alreadyVisited === void 0) {
@@ -28431,27 +28398,15 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
28431
28398
  }
28432
28399
 
28433
28400
  return __awaiter(void 0, void 0, void 0, function () {
28434
- 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;
28401
+ var envConfig, envType, basePredefinedVariables, gitlabEnvironmentName, environmentSlug, predefinedVariables, host, url, fullName, envVarContext, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
28435
28402
 
28436
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
28403
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
28437
28404
 
28438
- return __generator(this, function (_o) {
28439
- switch (_o.label) {
28405
+ return __generator(this, function (_l) {
28406
+ switch (_l.label) {
28440
28407
  case 0:
28441
- defaultConfig = config.components[componentName];
28442
-
28443
- if (!defaultConfig) {
28444
- throw new Error("unknown component " + componentName);
28445
- }
28446
-
28447
- envConfig = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
28448
-
28449
- if (envConfig === false) {
28450
- throw new Error("env is disabled: " + env);
28451
- }
28452
-
28453
- mergedConfig = (0, utils_1.mergeWithMergingArrays)(defaultConfig, envConfig);
28454
- envType = (_c = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _c !== void 0 ? _c : (0, config_1.isKnowEnvType)(env) ? env : null;
28408
+ envConfig = getEnvConfig(config, componentName, env);
28409
+ envType = (_a = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _a !== void 0 ? _a : (0, config_1.isKnowEnvType)(env) ? env : null;
28455
28410
 
28456
28411
  if (!envType) {
28457
28412
  throw new Error("Missing type in environment " + env + " in component " + componentName);
@@ -28459,16 +28414,25 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
28459
28414
 
28460
28415
  basePredefinedVariables = {
28461
28416
  ENV_SHORT: env,
28462
- APP_DIR: mergedConfig.dir,
28417
+ APP_DIR: envConfig.dir,
28463
28418
  ENV_TYPE: envType
28464
28419
  };
28465
28420
  gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
28466
28421
  environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
28467
28422
  fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
28423
+ envVarContext = {
28424
+ deployConfig: envConfig.deploy,
28425
+ fullName: fullName,
28426
+ envType: envType,
28427
+ commitInfo: commitInfo,
28428
+ componentName: componentName,
28429
+ env: env,
28430
+ fullConfig: config
28431
+ };
28468
28432
 
28469
28433
  if (envType === "local") {
28470
- devLocalConfig = mergedConfig;
28471
- port = (_d = devLocalConfig.port) !== null && _d !== void 0 ? _d : 3000;
28434
+ devLocalConfig = envConfig;
28435
+ port = (_b = devLocalConfig.port) !== null && _b !== void 0 ? _b : 3000;
28472
28436
  host = "localhost:" + port;
28473
28437
  url = "http://" + host;
28474
28438
  predefinedVariables = {
@@ -28477,34 +28441,22 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
28477
28441
  PORT: port.toString()
28478
28442
  };
28479
28443
  } else {
28480
- componentSlug = (0, slugify_1["default"])(componentName);
28481
- envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
28482
- 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
28483
- config.domainCanonical || "panter.cloud";
28484
- 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);
28485
- host = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.host) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
28444
+ additionalEnvVars = envConfig.deploy ? deploy_1.DEPLOY_TYPES[envConfig.deploy.type].getAdditionalEnvVars(envVarContext) : {};
28445
+ host = (_d = (_c = envConfig === null || envConfig === void 0 ? void 0 : envConfig.host) !== null && _c !== void 0 ? _c : additionalEnvVars.HOST_CANONICAL) !== null && _d !== void 0 ? _d : "unknown-host.example.com";
28486
28446
  url = "https://".concat(host);
28487
- KUBE_APP_NAME_PREFIX = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-") : "";
28488
- KUBE_APP_NAME = "".concat(KUBE_APP_NAME_PREFIX).concat(componentName);
28489
- KUBE_NAMESPACE = (0, deploy_1.getKubernetesNamespace)(config, env);
28490
- predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
28491
- HOST_CANONICAL: HOST_CANONICAL,
28447
+ predefinedVariables = __assign(__assign(__assign({}, basePredefinedVariables), {
28492
28448
  HOST: host,
28493
- ROOT_URL: url,
28494
- KUBE_NAMESPACE: KUBE_NAMESPACE,
28495
- KUBE_APP_NAME: KUBE_APP_NAME,
28496
- KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX
28497
- });
28449
+ ROOT_URL: url
28450
+ }), additionalEnvVars);
28498
28451
  }
28499
28452
 
28500
- publicEnvVarsRaw = (_h = (_g = mergedConfig.vars) === null || _g === void 0 ? void 0 : _g.public) !== null && _h !== void 0 ? _h : {};
28501
- additionalSecretKeys = mergedConfig.deploy ? deploy_1.DEPLOY_TYPES[mergedConfig.deploy.type].additionalSecretKeys( // eslint-disable-next-line @typescript-eslint/no-explicit-any
28502
- mergedConfig.deploy) : [];
28503
- 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);
28453
+ publicEnvVarsRaw = (_f = (_e = envConfig.vars) === null || _e === void 0 ? void 0 : _e.public) !== null && _f !== void 0 ? _f : {};
28454
+ additionalSecretKeys = envConfig.deploy ? deploy_1.DEPLOY_TYPES[envConfig.deploy.type].additionalSecretKeys(envVarContext) : [];
28455
+ secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_h = (_g = envConfig.vars) === null || _g === void 0 ? void 0 : _g.secret) !== null && _h !== void 0 ? _h : []), false), __read(additionalSecretKeys), false);
28504
28456
  secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
28505
28457
  return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
28506
28458
  }));
28507
- legacyFromComponents = (_m = (_l = mergedConfig.vars) === null || _l === void 0 ? void 0 : _l.fromComponents) !== null && _m !== void 0 ? _m : {};
28459
+ legacyFromComponents = (_k = (_j = envConfig.vars) === null || _j === void 0 ? void 0 : _j.fromComponents) !== null && _k !== void 0 ? _k : {};
28508
28460
  publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
28509
28461
  publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
28510
28462
  var _b = __read(_a, 2),
@@ -28537,7 +28489,7 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
28537
28489
  }, alreadyVisited)];
28538
28490
 
28539
28491
  case 1:
28540
- envVars = _o.sent();
28492
+ envVars = _l.sent();
28541
28493
  return [2
28542
28494
  /*return*/
28543
28495
  , {
@@ -28561,6 +28513,47 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
28561
28513
 
28562
28514
  exports.getEnvironment = getEnvironment;
28563
28515
 
28516
+ var sanitizeForEnVar = function (s) {
28517
+ return s.replace(/-/g, "_");
28518
+ };
28519
+
28520
+ var getSecretVarName = function (env, componentName, key) {
28521
+ return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
28522
+ }; // remove dash from component name
28523
+
28524
+
28525
+ exports.getSecretVarName = getSecretVarName;
28526
+
28527
+ var addIndexVar = function (vars) {
28528
+ return __assign(__assign({}, vars), {
28529
+ _ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
28530
+ });
28531
+ };
28532
+
28533
+ var getSecretVarNameForContext = function (context, key) {
28534
+ return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
28535
+ };
28536
+
28537
+ exports.getSecretVarNameForContext = getSecretVarNameForContext;
28538
+
28539
+ var getEnvConfig = function (config, componentName, env) {
28540
+ var _a, _b;
28541
+
28542
+ var defaultConfig = config.components[componentName];
28543
+
28544
+ if (!defaultConfig) {
28545
+ throw new Error("unknown component " + componentName);
28546
+ }
28547
+
28548
+ var envCustomizations = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
28549
+
28550
+ if (envCustomizations === false) {
28551
+ throw new Error("env is disabled: " + env);
28552
+ }
28553
+
28554
+ return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
28555
+ };
28556
+
28564
28557
  /***/ }),
28565
28558
 
28566
28559
  /***/ 2101:
@@ -29389,7 +29382,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
29389
29382
  };
29390
29383
 
29391
29384
  exports.__esModule = true;
29392
- exports.createDeployJob = void 0;
29385
+ exports.createGoogleCloudRunDeployJobs = void 0;
29393
29386
 
29394
29387
  var js_yaml_1 = __nccwpck_require__(3618);
29395
29388
 
@@ -29409,7 +29402,9 @@ var types_1 = __nccwpck_require__(4436);
29409
29402
 
29410
29403
  var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(818);
29411
29404
 
29412
- var createDeployJob = function (context) {
29405
+ var createGoogleCloudRunDeployJobs = function (context) {
29406
+ var _a, _b;
29407
+
29413
29408
  var deployConfig = context.componentConfig.deploy;
29414
29409
 
29415
29410
  if (deployConfig === false) {
@@ -29418,7 +29413,7 @@ var createDeployJob = function (context) {
29418
29413
 
29419
29414
  if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
29420
29415
  // should not happen
29421
- throw new Error("deploy config is not custom");
29416
+ throw new Error("deploy config is wrong");
29422
29417
  }
29423
29418
 
29424
29419
  var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
@@ -29429,7 +29424,6 @@ var createDeployJob = function (context) {
29429
29424
  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);
29430
29425
 
29431
29426
  var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
29432
- var serviceName = context.environment.fullName.toLowerCase();
29433
29427
  var labelsString = Object.entries((0, getLabels_1.getLabels)(context)).map(function (_a) {
29434
29428
  var _b = __read(_a, 2),
29435
29429
  key = _b[0],
@@ -29437,15 +29431,77 @@ var createDeployJob = function (context) {
29437
29431
 
29438
29432
  return "".concat(key, "=").concat(value);
29439
29433
  }).join(",");
29440
- var command = context.componentConfig.build.startCommand ? "--command=\"".concat(context.componentConfig.build.startCommand.split(" ").join(","), "\"") : ""; // TODO: split secrets out
29434
+ var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
29435
+ var commonDeployArgs = "--image ".concat(gcloudImageName, " ").concat(commonArgs, " --labels ").concat(labelsString);
29436
+ var serviceName = context.environment.fullName.toLowerCase();
29437
+
29438
+ var getServiceDeployScript = function (service) {
29439
+ var _a;
29440
+
29441
+ var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
29442
+ var commandArg = command ? "--command=\"".concat(command.split(" ").join(","), "\"") : "";
29443
+ return "gcloud run deploy ".concat(serviceName, " ").concat(commandArg, " ").concat(commonDeployArgs, " --env-vars-file=____envvars.yaml --allow-unauthenticated");
29444
+ };
29445
+
29446
+ var getJobDeployScripts = function (jobName, job) {
29447
+ // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
29448
+ // lucky, update on the other hand accepts it... so let's just imediatly update it
29449
+ // also we cannot upsert a job, so we have to create it and catch the error and then update
29450
+ var args = "".concat(jobName, " --command=\"").concat(job.command.split(" ").join(","), "\" ").concat(commonDeployArgs);
29451
+ return ["set +e", "gcloud beta run jobs create ".concat(args), "set -e", "gcloud beta run jobs update ".concat(args, " --env-vars-file=____envvars.yaml")];
29452
+ };
29453
+
29454
+ var getJobRunScript = function (jobName) {
29455
+ return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgs);
29456
+ };
29457
+
29458
+ var getFullJobName = function (name) {
29459
+ return context.environment.fullName.toLowerCase() + "-" + name;
29460
+ };
29461
+
29462
+ var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
29463
+ var _b = __read(_a, 2),
29464
+ name = _b[0],
29465
+ job = _b[1];
29466
+
29467
+ return [getFullJobName(name), job];
29468
+ });
29469
+
29470
+ var cloudRunDeployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(jobsWithNames.map(function (_a) {
29471
+ var _b = __read(_a, 2),
29472
+ name = _b[0],
29473
+ job = _b[1];
29474
+
29475
+ return getJobDeployScripts(name, job);
29476
+ }).flat()), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(jobsWithNames.filter(function (_a) {
29477
+ var _b = __read(_a, 2),
29478
+ name = _b[0],
29479
+ job = _b[1];
29480
+
29481
+ return job.when === "postDeploy";
29482
+ }).map(function (_a) {
29483
+ var _b = __read(_a, 2),
29484
+ name = _b[0],
29485
+ job = _b[1];
29486
+
29487
+ return getJobRunScript(name);
29488
+ })), false), ["docker image rm ".concat(gcloudImageName)], false);
29489
+
29490
+ var cloudRunStopScripts = __spreadArray(__spreadArray([], __read(deployConfig.service !== false ? ["gcloud run services delete ".concat(serviceName)] : []), false), __read(Object.entries((_b = deployConfig.jobs) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
29491
+ var _b = __read(_a, 2),
29492
+ jobName = _b[0],
29493
+ job = _b[1];
29494
+
29495
+ return "gcloud beta run jobs delete ".concat(jobName);
29496
+ })), false);
29441
29497
 
29442
- 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)];
29443
29498
  var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
29444
29499
  return [(0, lodash_1.merge)({}, baseDeploymentJob, (0, docker_1.getDockerJobBaseProps)(context), {
29445
29500
  artifacts: {
29446
29501
  paths: ["____envvars.yaml"]
29447
29502
  },
29448
29503
  variables: {
29504
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
29449
29505
  ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
29450
29506
  lineWidth: -1,
29451
29507
  quotingType: "'",
@@ -29453,37 +29509,98 @@ var createDeployJob = function (context) {
29453
29509
  })
29454
29510
  },
29455
29511
  image: (0, runner_1.getRunnerImage)("gcloud"),
29456
- script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeploy), false)
29512
+ script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeployScripts), false)
29457
29513
  }), (0, lodash_1.merge)({}, baseStopJob, {
29458
29514
  image: (0, runner_1.getRunnerImage)("gcloud"),
29459
- 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)
29515
+ variables: {
29516
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1"
29517
+ },
29518
+ script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(cloudRunStopScripts), false)
29460
29519
  })];
29461
29520
  };
29462
29521
 
29463
- exports.createDeployJob = createDeployJob;
29522
+ exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
29464
29523
 
29465
29524
  /***/ }),
29466
29525
 
29467
29526
  /***/ 8718:
29468
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
29527
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
29469
29528
 
29470
29529
  "use strict";
29471
29530
 
29472
29531
 
29532
+ var __assign = this && this.__assign || function () {
29533
+ __assign = Object.assign || function (t) {
29534
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
29535
+ s = arguments[i];
29536
+
29537
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
29538
+ }
29539
+
29540
+ return t;
29541
+ };
29542
+
29543
+ return __assign.apply(this, arguments);
29544
+ };
29545
+
29546
+ var __read = this && this.__read || function (o, n) {
29547
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
29548
+ if (!m) return o;
29549
+ var i = m.call(o),
29550
+ r,
29551
+ ar = [],
29552
+ e;
29553
+
29554
+ try {
29555
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
29556
+ } catch (error) {
29557
+ e = {
29558
+ error: error
29559
+ };
29560
+ } finally {
29561
+ try {
29562
+ if (r && !r.done && (m = i["return"])) m.call(i);
29563
+ } finally {
29564
+ if (e) throw e.error;
29565
+ }
29566
+ }
29567
+
29568
+ return ar;
29569
+ };
29570
+
29473
29571
  exports.__esModule = true;
29474
29572
  exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
29475
29573
 
29574
+ var context_1 = __nccwpck_require__(7123);
29575
+
29476
29576
  var deployJob_1 = __nccwpck_require__(5565);
29477
29577
 
29478
29578
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
29479
29579
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
29480
29580
  exports.GCLOUD_RUN_DEPLOY_TYPE = {
29481
- jobs: deployJob_1.createDeployJob,
29581
+ jobs: deployJob_1.createGoogleCloudRunDeployJobs,
29482
29582
  defaults: function () {
29483
29583
  return {};
29484
29584
  },
29485
29585
  additionalSecretKeys: function () {
29486
29586
  return [exports.GCLOUD_DEPLOY_CREDENTIALS_KEY];
29587
+ },
29588
+ getAdditionalEnvVars: function (_a) {
29589
+ var fullName = _a.fullName,
29590
+ env = _a.env,
29591
+ componentName = _a.componentName,
29592
+ deployConfig = _a.deployConfig;
29593
+ var HOST_CANONICAL = fullName.toLowerCase() + "-" + process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)];
29594
+ var jobTriggers = deployConfig && deployConfig.jobs ? Object.fromEntries(Object.entries(deployConfig.jobs).map(function (_a) {
29595
+ var _b = __read(_a, 2),
29596
+ name = _b[0],
29597
+ job = _b[1];
29598
+
29599
+ return ["CLOUD_RUN_JOB_TRIGGER_URL_" + name, "https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(name, ":run")];
29600
+ })) : {};
29601
+ return __assign({
29602
+ HOST_CANONICAL: HOST_CANONICAL
29603
+ }, jobTriggers);
29487
29604
  }
29488
29605
  };
29489
29606
 
@@ -29640,6 +29757,9 @@ exports.CUSTOM_DEPLOY_TYPE = {
29640
29757
  },
29641
29758
  additionalSecretKeys: function () {
29642
29759
  return [];
29760
+ },
29761
+ getAdditionalEnvVars: function () {
29762
+ return {};
29643
29763
  }
29644
29764
  };
29645
29765
 
@@ -29703,6 +29823,9 @@ exports.DOCKER_TAG_DEPLOY_TYPE = {
29703
29823
  },
29704
29824
  additionalSecretKeys: function () {
29705
29825
  return [];
29826
+ },
29827
+ getAdditionalEnvVars: function () {
29828
+ return {};
29706
29829
  }
29707
29830
  };
29708
29831
 
@@ -29755,8 +29878,8 @@ __exportStar(__nccwpck_require__(8718), exports);
29755
29878
  exports.DEPLOY_TYPES = {
29756
29879
  kubernetes: kubernetes_1.KUBERNETES_DEPLOY_TYPE,
29757
29880
  custom: custom_1.CUSTOM_DEPLOY_TYPE,
29758
- "google-cloudrun": cloudRun_1.GCLOUD_RUN_DEPLOY_TYPE,
29759
- dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE
29881
+ dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE,
29882
+ "google-cloudrun": cloudRun_1.GCLOUD_RUN_DEPLOY_TYPE
29760
29883
  };
29761
29884
 
29762
29885
  /***/ }),
@@ -29770,20 +29893,26 @@ exports.DEPLOY_TYPES = {
29770
29893
  exports.__esModule = true;
29771
29894
  exports.additionalKubernetesSecretKeys = void 0;
29772
29895
 
29773
- var additionalKubernetesSecretKeys = function (config) {
29774
- var _a, _b, _c, _d;
29896
+ var additionalKubernetesSecretKeys = function (_a) {
29897
+ var _b, _c, _d, _e;
29898
+
29899
+ var deployConfig = _a.deployConfig;
29900
+
29901
+ if (!deployConfig) {
29902
+ return [];
29903
+ }
29775
29904
 
29776
29905
  var keys = [];
29777
29906
 
29778
- if ((_b = (_a = config.values) === null || _a === void 0 ? void 0 : _a.mongodb) === null || _b === void 0 ? void 0 : _b.enabled) {
29907
+ if ((_c = (_b = deployConfig.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) {
29779
29908
  keys.push("MONGODB_ROOT_PASSWORD");
29780
29909
 
29781
- if (config.values.mongodb.architecture === "replicaset") {
29910
+ if (deployConfig.values.mongodb.architecture === "replicaset") {
29782
29911
  keys.push("MONGODB_REPLICASET_KEY");
29783
29912
  }
29784
29913
  }
29785
29914
 
29786
- if ((_d = (_c = config.values) === null || _c === void 0 ? void 0 : _c.cloudsql) === null || _d === void 0 ? void 0 : _d.enabled) {
29915
+ if ((_e = (_d = deployConfig.values) === null || _d === void 0 ? void 0 : _d.cloudsql) === null || _e === void 0 ? void 0 : _e.enabled) {
29787
29916
  keys.push("POSTGRESQL_PASSWORD");
29788
29917
  keys.push("cloudsqlProxyCredentials");
29789
29918
  }
@@ -29953,14 +30082,24 @@ exports.createKubernetesDeployJobs = createKubernetesDeployJobs;
29953
30082
  /***/ }),
29954
30083
 
29955
30084
  /***/ 2964:
29956
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
30085
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
29957
30086
 
29958
30087
  "use strict";
29959
30088
 
29960
30089
 
30090
+ var __importDefault = this && this.__importDefault || function (mod) {
30091
+ return mod && mod.__esModule ? mod : {
30092
+ "default": mod
30093
+ };
30094
+ };
30095
+
29961
30096
  exports.__esModule = true;
29962
30097
  exports.KUBERNETES_DEPLOY_TYPE = void 0;
29963
30098
 
30099
+ var slugify_1 = __importDefault(__nccwpck_require__(4035));
30100
+
30101
+ var __1 = __nccwpck_require__(1264);
30102
+
29964
30103
  var additionalSecretKeys_1 = __nccwpck_require__(7746);
29965
30104
 
29966
30105
  var deployJob_1 = __nccwpck_require__(2525);
@@ -29970,7 +30109,32 @@ exports.KUBERNETES_DEPLOY_TYPE = {
29970
30109
  defaults: function () {
29971
30110
  return {};
29972
30111
  },
29973
- additionalSecretKeys: additionalSecretKeys_1.additionalKubernetesSecretKeys
30112
+ additionalSecretKeys: additionalSecretKeys_1.additionalKubernetesSecretKeys,
30113
+ getAdditionalEnvVars: function (_a) {
30114
+ var _b;
30115
+
30116
+ var componentName = _a.componentName,
30117
+ fullConfig = _a.fullConfig,
30118
+ deployConfig = _a.deployConfig,
30119
+ env = _a.env,
30120
+ envType = _a.envType,
30121
+ commitInfo = _a.commitInfo;
30122
+ var KUBE_APP_NAME_PREFIX = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-") : "";
30123
+ var KUBE_APP_NAME = "".concat(KUBE_APP_NAME_PREFIX).concat(componentName);
30124
+ var KUBE_NAMESPACE = (0, __1.getKubernetesNamespace)(fullConfig, env);
30125
+ var componentSlug = (0, slugify_1["default"])(componentName);
30126
+ var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
30127
+ var domainCanonical = deployConfig && ((_b = deployConfig.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
30128
+ fullConfig.domainCanonical || "panter.cloud";
30129
+ var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(fullConfig.appName, ".").concat(fullConfig.customerName, ".").concat(domainCanonical); // default for kubernetes and rest
30130
+
30131
+ return {
30132
+ KUBE_NAMESPACE: KUBE_NAMESPACE,
30133
+ KUBE_APP_NAME: KUBE_APP_NAME,
30134
+ KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX,
30135
+ HOST_CANONICAL: HOST_CANONICAL
30136
+ };
30137
+ }
29974
30138
  };
29975
30139
 
29976
30140
  /***/ }),
package/dist/constants.js CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
5
- exports.PIPELINE_IMAGE_TAG = "main-e651ab49" || "";
5
+ exports.PIPELINE_IMAGE_TAG = "main-0009a81d" || "";
6
6
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
@@ -1,5 +1,5 @@
1
1
  import type { Config } from "../types/config";
2
2
  import type { CommitInfo, Context, Environment } from "../types/context";
3
+ export declare const getEnvironment: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, alreadyVisited?: Record<string, Record<string, boolean>>) => Promise<Environment>;
3
4
  export declare const getSecretVarName: (env: string, componentName: string, key: string) => string;
4
- export declare const getSecretVarNameForContext: (context: Context, key: string) => string;
5
- export declare const getEnvironment: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, alreadyVisited?: Record<string, Record<string, boolean>>) => Promise<Environment>;
5
+ export declare const getSecretVarNameForContext: (context: Context, key: string) => string;