@catladder/pipeline 0.0.0-refactor-gcloud-api-5bd4bbed → 0.0.0-refactor-gitlab-jobs-9e285eaf

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 (84) hide show
  1. package/dist/build/custom/buildJob.js +1 -0
  2. package/dist/build/index.js +7 -1
  3. package/dist/build/rails/build.js +41 -16
  4. package/dist/build/rails/index.d.ts +2 -2
  5. package/dist/build/types.d.ts +36 -4
  6. package/dist/bundles/catladder-gitlab/index.js +512 -205
  7. package/dist/constants.js +1 -1
  8. package/dist/context/__tests__/resolveReferences.test.js +15 -20
  9. package/dist/context/getEnvironment.js +1 -0
  10. package/dist/context/getEnvironmentContext.js +5 -3
  11. package/dist/context/getEnvironmentVariables.js +2 -2
  12. package/dist/context/resolveReferences.d.ts +1 -1
  13. package/dist/context/resolveReferences.js +3 -1
  14. package/dist/deploy/base.js +1 -1
  15. package/dist/deploy/cloudRun/deployJob.js +9 -7
  16. package/dist/deploy/cloudRun/index.js +7 -6
  17. package/dist/deploy/cloudRun/utils/createArgsString.d.ts +1 -1
  18. package/dist/deploy/cloudRun/utils/createArgsString.js +6 -1
  19. package/dist/deploy/kubernetes/deployJob.js +4 -4
  20. package/dist/deploy/kubernetes/kubeValues.d.ts +3 -0
  21. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +3 -0
  22. package/dist/deploy/types/custom.d.ts +2 -1
  23. package/dist/deploy/types/googleCloudRun.d.ts +11 -2
  24. package/dist/deploy/types/kubernetes.d.ts +11 -0
  25. package/dist/pipeline/createAllJobs.d.ts +8 -0
  26. package/dist/pipeline/createAllJobs.js +164 -0
  27. package/dist/pipeline/createChildPipeline.js +24 -48
  28. package/dist/pipeline/createJobsForComponent.d.ts +3 -0
  29. package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -105
  30. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
  31. package/dist/pipeline/gitlab/createGitlabJobs.js +256 -0
  32. package/dist/pipeline/index.d.ts +1 -1
  33. package/dist/pipeline/index.js +1 -1
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/dist/types/context.d.ts +1 -0
  36. package/dist/types/environmentContext.d.ts +7 -0
  37. package/dist/types/gitlab-types.d.ts +25 -1
  38. package/dist/types/jobs.d.ts +9 -2
  39. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +1572 -0
  40. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +1572 -0
  41. package/examples/__snapshots__/cloud-run-non-public.ts.snap +48 -48
  42. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3116 -0
  43. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +108 -108
  44. package/examples/__snapshots__/custom-build-job.ts.snap +48 -48
  45. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +24 -24
  46. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
  47. package/examples/cloud-run-memory-limit.ts +28 -0
  48. package/examples/cloud-run-no-cpu-throttling.ts +33 -0
  49. package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
  50. package/examples/cloud-run-with-sql.ts +1 -1
  51. package/examples/rails-k8s-with-worker.ts +95 -0
  52. package/package.json +1 -1
  53. package/src/build/custom/buildJob.ts +1 -0
  54. package/src/build/index.ts +7 -1
  55. package/src/build/rails/build.ts +17 -10
  56. package/src/build/rails/index.ts +2 -2
  57. package/src/build/types.ts +40 -5
  58. package/src/context/__tests__/resolveReferences.test.ts +15 -30
  59. package/src/context/getEnvironment.ts +1 -0
  60. package/src/context/getEnvironmentContext.ts +6 -6
  61. package/src/context/getEnvironmentVariables.ts +7 -5
  62. package/src/context/resolveReferences.ts +3 -6
  63. package/src/deploy/base.ts +1 -1
  64. package/src/deploy/cloudRun/deployJob.ts +9 -11
  65. package/src/deploy/cloudRun/index.ts +5 -4
  66. package/src/deploy/cloudRun/utils/createArgsString.ts +9 -2
  67. package/src/deploy/kubernetes/deployJob.ts +1 -1
  68. package/src/deploy/types/custom.ts +2 -1
  69. package/src/deploy/types/googleCloudRun.ts +14 -2
  70. package/src/deploy/types/kubernetes.ts +12 -0
  71. package/src/pipeline/createAllJobs.ts +38 -0
  72. package/src/pipeline/createChildPipeline.ts +6 -22
  73. package/src/pipeline/createJobsForComponent.ts +64 -0
  74. package/src/pipeline/gitlab/createGitlabJobs.ts +147 -0
  75. package/src/pipeline/index.ts +1 -1
  76. package/src/types/context.ts +1 -0
  77. package/src/types/environmentContext.ts +7 -0
  78. package/src/types/gitlab-types.ts +18 -1
  79. package/src/types/jobs.ts +11 -2
  80. package/dist/pipeline/createJobs.d.ts +0 -3
  81. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
  82. package/dist/pipeline/gitlab/makeGitlabJob.js +0 -44
  83. package/src/pipeline/createJobs.ts +0 -199
  84. package/src/pipeline/gitlab/makeGitlabJob.ts +0 -23
@@ -27071,6 +27071,7 @@ var createCustomBuildJobs = function (context) {
27071
27071
  var appBuildJob = buildConfig.buildCommand !== null ? (0, createBuildJob_1.createBuildJob)(context, {
27072
27072
  image: buildConfig.jobImage,
27073
27073
  variables: __assign({}, RUNNER_BUILD_VARIABLES),
27074
+ cache: buildConfig.jobCache,
27074
27075
  services: buildConfig.jobServices,
27075
27076
  script: __spreadArray([], __read((_a = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _a !== void 0 ? _a : []), false),
27076
27077
  artifacts: {
@@ -27352,7 +27353,13 @@ exports.BUILD_TYPES = {
27352
27353
  rails: {
27353
27354
  jobs: rails_1.createRailsJobs,
27354
27355
  defaults: function () {
27355
- return {};
27356
+ return {
27357
+ startCommand: "/cnb/process/web",
27358
+ cnbBuilder: {
27359
+ image: "heroku/buildpacks:20",
27360
+ packVersion: "0.28.0"
27361
+ }
27362
+ };
27356
27363
  }
27357
27364
  }
27358
27365
  };
@@ -27882,31 +27889,56 @@ exports.getYarnInstall = getYarnInstall;
27882
27889
  "use strict";
27883
27890
 
27884
27891
 
27885
- var __assign = this && this.__assign || function () {
27886
- __assign = Object.assign || function (t) {
27887
- for (var s, i = 1, n = arguments.length; i < n; i++) {
27888
- s = arguments[i];
27889
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
27892
+ var __read = this && this.__read || function (o, n) {
27893
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
27894
+ if (!m) return o;
27895
+ var i = m.call(o),
27896
+ r,
27897
+ ar = [],
27898
+ e;
27899
+ try {
27900
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
27901
+ } catch (error) {
27902
+ e = {
27903
+ error: error
27904
+ };
27905
+ } finally {
27906
+ try {
27907
+ if (r && !r.done && (m = i["return"])) m.call(i);
27908
+ } finally {
27909
+ if (e) throw e.error;
27890
27910
  }
27891
- return t;
27892
- };
27893
- return __assign.apply(this, arguments);
27911
+ }
27912
+ return ar;
27894
27913
  };
27895
27914
  exports.__esModule = true;
27896
27915
  exports.createRailsBuildJobs = void 0;
27916
+ var types_1 = __nccwpck_require__(6575);
27897
27917
  var docker_1 = __nccwpck_require__(9953);
27898
27918
  var createRailsBuildJobs = function (context) {
27919
+ var _a, _b, _c, _d, _e, _f;
27920
+ var buildConfig = context.componentConfig.build;
27921
+ if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
27922
+ // should not happen
27923
+ throw new Error("build type is not rails");
27924
+ }
27925
+ var cnbConf = buildConfig.cnbBuilder;
27926
+ // backwards compatabilty with CNB_ENV_VARS
27927
+ // TODO: remove when all projects are migrated
27928
+ var packEnvArgs = (_c = (_b = (_a = buildConfig.extraVars) === null || _a === void 0 ? void 0 : _a.CNB_ENV_VARS) === null || _b === void 0 ? void 0 : _b.split(" ").map(function (v) {
27929
+ return "--env '".concat(v, "'");
27930
+ })) !== null && _c !== void 0 ? _c : Object.entries((_d = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _d !== void 0 ? _d : {}).map(function (_a) {
27931
+ var _b = __read(_a, 2),
27932
+ k = _b[0],
27933
+ v = _b[1];
27934
+ return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
27935
+ });
27899
27936
  return [(0, docker_1.createDockerBuildJobBase)(context, {
27900
- variables: __assign({
27901
- CNB_BUILDER: "heroku/buildpacks:18",
27902
- CNB_ENV_VARS: "BUNDLE_GIT__PANTER__CH",
27903
- CNB_EXTRA_ARGS: "",
27904
- CNB_PACK_VERSION: "0.20.0"
27905
- }, context.componentConfig.build.extraVars),
27937
+ variables: context.componentConfig.build.extraVars,
27906
27938
  // custom script
27907
- script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v$CNB_PACK_VERSION/pack-v$CNB_PACK_VERSION-linux.tgz | tar -zx --directory /usr/local/bin pack", "chmod +x /usr/local/bin/pack",
27939
+ script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
27908
27940
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
27909
- "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "for v in $CNB_ENV_VARS; do env_args=\"$env_args --env $v\"; done", "pack build $DOCKER_IMAGE:$DOCKER_IMAGE_TAG --builder $CNB_BUILDER --publish --cache-image $DOCKER_CACHE_IMAGE $env_args $CNB_EXTRA_ARGS"]
27941
+ "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs.join(" "), " ").concat((_f = (_e = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _e === void 0 ? void 0 : _e.join(" ")) !== null && _f !== void 0 ? _f : "")]
27910
27942
  })];
27911
27943
  };
27912
27944
  exports.createRailsBuildJobs = createRailsBuildJobs;
@@ -28318,7 +28350,7 @@ exports.readConfigSync = readConfigSync;
28318
28350
 
28319
28351
  exports.__esModule = true;
28320
28352
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
28321
- exports.PIPELINE_IMAGE_TAG = "refactor-gcloud-api-5bd4bbed" || 0;
28353
+ exports.PIPELINE_IMAGE_TAG = "refactor-gitlab-jobs-9e285eaf" || 0;
28322
28354
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
28323
28355
 
28324
28356
  /***/ }),
@@ -28513,6 +28545,7 @@ var getEnvironment = function (config, componentName, env, commitInfo) {
28513
28545
  url: url
28514
28546
  },
28515
28547
  fullName: envContext.fullName,
28548
+ slugPrefix: envContext.environmentSlugPrefix,
28516
28549
  slug: envContext.environmentSlug,
28517
28550
  shortName: env,
28518
28551
  envVars: envVars,
@@ -28536,20 +28569,22 @@ exports.__esModule = true;
28536
28569
  exports.getEnvironmentContext = void 0;
28537
28570
  var getEnvConfig_1 = __nccwpck_require__(1691);
28538
28571
  var getEnvType_1 = __nccwpck_require__(2187);
28539
- var getEnvironmentSlug = function (envConfig, env, componentName, commitInfo) {
28572
+ var getEnvironmentSlugPrefix = function (envConfig, env, commitInfo) {
28540
28573
  var envType = (0, getEnvType_1.getEnvType)(env, envConfig);
28541
- return envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
28574
+ return envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug) : "".concat(env);
28542
28575
  };
28543
28576
  var getEnvironmentContext = function (config, env, componentName, commitInfo) {
28544
28577
  var envConfigRaw = (0, getEnvConfig_1.getEnvConfig)(config, componentName, env);
28545
28578
  var envType = (0, getEnvType_1.getEnvType)(env, envConfigRaw);
28546
- var environmentSlug = getEnvironmentSlug(envConfigRaw, env, componentName, commitInfo);
28579
+ var environmentSlugPrefix = getEnvironmentSlugPrefix(envConfigRaw, env, commitInfo);
28580
+ var environmentSlug = "".concat(environmentSlugPrefix, "-").concat(componentName);
28547
28581
  var gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
28548
28582
  var fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
28549
28583
  return {
28550
28584
  envConfigRaw: envConfigRaw,
28551
28585
  deployConfigRaw: envConfigRaw.deploy,
28552
28586
  buildConfigRaw: envConfigRaw.build,
28587
+ environmentSlugPrefix: environmentSlugPrefix,
28553
28588
  environmentSlug: environmentSlug,
28554
28589
  gitlabEnvironmentName: gitlabEnvironmentName,
28555
28590
  fullName: fullName,
@@ -28785,7 +28820,7 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
28785
28820
  return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
28786
28821
  }));
28787
28822
  envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
28788
- return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, variableName, alreadyVisited) {
28823
+ return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, alreadyVisited) {
28789
28824
  return __awaiter(void 0, void 0, void 0, function () {
28790
28825
  var otherEnvVars;
28791
28826
  return __generator(this, function (_a) {
@@ -28794,7 +28829,7 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
28794
28829
  return [4 /*yield*/, (0, exports.getEnvironmentVariables)(config, otherComponentName, env, commitInfo, alreadyVisited)];
28795
28830
  case 1:
28796
28831
  otherEnvVars = _a.sent().envVars;
28797
- return [2 /*return*/, otherEnvVars[variableName]];
28832
+ return [2 /*return*/, otherEnvVars];
28798
28833
  }
28799
28834
  });
28800
28835
  });
@@ -29242,7 +29277,9 @@ var resolveReferences = function (vars, getOtherVariables, alreadyVisitedBase) {
29242
29277
 
29243
29278
  newAlreadyVisited = (0, lodash_1.merge)({}, alreadyVisited, (_c = {}, _c[componentName] = (_d = {}, _d[variableName] = true, _d), _c));
29244
29279
  if (!componentName) return [3 /*break*/, 2];
29245
- return [4 /*yield*/, getOtherVariables === null || getOtherVariables === void 0 ? void 0 : getOtherVariables(componentName, variableName, newAlreadyVisited)];
29280
+ return [4 /*yield*/, getOtherVariables === null || getOtherVariables === void 0 ? void 0 : getOtherVariables(componentName, newAlreadyVisited).then(function (r) {
29281
+ return r === null || r === void 0 ? void 0 : r[variableName];
29282
+ })];
29246
29283
  case 1:
29247
29284
  _a = (_f = _g.sent()) !== null && _f !== void 0 ? _f : null;
29248
29285
  return [3 /*break*/, 3];
@@ -29375,7 +29412,7 @@ var getBaseDeploymentJob = function (context) {
29375
29412
  return {
29376
29413
  name: exports.DEPLOY_JOB_NAME,
29377
29414
  envMode: "stagePerEnv",
29378
- needsOtherComponent: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
29415
+ needs: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
29379
29416
  return {
29380
29417
  componentName: c,
29381
29418
  job: exports.DEPLOY_JOB_NAME,
@@ -29576,19 +29613,21 @@ var createGoogleCloudRunDeployJobs = function (context) {
29576
29613
  };
29577
29614
  });
29578
29615
  var getServiceDeployScript = function (service, nameSuffix) {
29579
- var _a, _b;
29616
+ var _a, _b, _c, _d;
29580
29617
  var customConfig = service !== true ? service : undefined;
29581
29618
  var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
29582
29619
  var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
29583
- command: command ? '"' + command.split(" ").join(",") + '"' : undefined
29620
+ // command as empty string resets it to default (uses the image's entrypoint)
29621
+ command: command ? '"' + command.split(" ").join(",") + '"' : '""'
29584
29622
  }, commonDeployArgs), {
29585
29623
  "env-vars-file": "____envvars.yaml",
29586
- "min-instances": customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances,
29587
- "max-instances": customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances,
29588
- "no-cpu-throttling": customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling
29624
+ "min-instances": (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _b !== void 0 ? _b : 0,
29625
+ "max-instances": (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances) !== null && _c !== void 0 ? _c : 100,
29626
+ "cpu-throttling": (customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling) !== true,
29627
+ memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
29628
+ "allow-unauthenticated": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _d !== void 0 ? _d : true
29589
29629
  }));
29590
- var authenticationString = ((_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _b !== void 0 ? _b : true) ? "--allow-unauthenticated" : "--no-allow-unauthenticated";
29591
- return "gcloud run deploy ".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "", " ").concat(argsString, " ").concat(authenticationString);
29630
+ return "gcloud run deploy ".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "", " ").concat(argsString);
29592
29631
  };
29593
29632
  var getJobCreateScriptsForJob = function (jobName, job) {
29594
29633
  // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
@@ -29749,15 +29788,15 @@ var jobName_1 = __nccwpck_require__(9357);
29749
29788
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
29750
29789
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
29751
29790
  var getCloudSqlVariables = function (_a) {
29752
- var _b, _c, _d;
29791
+ var _b, _c, _d, _e;
29753
29792
  var deployConfigRaw = _a.deployConfigRaw,
29754
- environmentSlug = _a.environmentSlug,
29793
+ environmentSlugPrefix = _a.environmentSlugPrefix,
29755
29794
  env = _a.env,
29756
29795
  componentName = _a.componentName,
29757
29796
  fullConfig = _a.fullConfig;
29758
29797
  if (deployConfigRaw && deployConfigRaw.cloudSql) {
29759
- var DB_NAME = [(_b = deployConfigRaw.cloudSql.dbNamePrefix) !== null && _b !== void 0 ? _b : "".concat(fullConfig.customerName, "-").concat(fullConfig.appName), environmentSlug].filter(Boolean).join("-");
29760
- var additionalQueryParamsString = Object.entries((_c = deployConfigRaw.cloudSql.dbAdditionalQueryParams) !== null && _c !== void 0 ? _c : {}).map(function (_a) {
29798
+ var DB_NAME = [(_b = deployConfigRaw.cloudSql.dbNamePrefix) !== null && _b !== void 0 ? _b : "".concat(fullConfig.customerName, "-").concat(fullConfig.appName), environmentSlugPrefix, (_c = deployConfigRaw.cloudSql.dbBaseName) !== null && _c !== void 0 ? _c : componentName].filter(Boolean).join("-");
29799
+ var additionalQueryParamsString = Object.entries((_d = deployConfigRaw.cloudSql.dbAdditionalQueryParams) !== null && _d !== void 0 ? _d : {}).map(function (_a) {
29761
29800
  var _b = __read(_a, 2),
29762
29801
  key = _b[0],
29763
29802
  value = _b[1];
@@ -29766,7 +29805,7 @@ var getCloudSqlVariables = function (_a) {
29766
29805
  return {
29767
29806
  CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
29768
29807
  DB_NAME: DB_NAME,
29769
- DB_USER: (_d = deployConfigRaw.cloudSql.dbUser) !== null && _d !== void 0 ? _d : "postgres",
29808
+ DB_USER: (_e = deployConfigRaw.cloudSql.dbUser) !== null && _e !== void 0 ? _e : "postgres",
29770
29809
  DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
29771
29810
  DATABASE_URL: "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME".concat(additionalQueryParamsString),
29772
29811
  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".concat(additionalQueryParamsString)
@@ -29792,11 +29831,12 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
29792
29831
  return __spreadArray([exports.GCLOUD_DEPLOY_CREDENTIALS_KEY], __read(ctx.deployConfigRaw && ctx.deployConfigRaw.cloudSql ? ["DB_PASSWORD"] : []), false);
29793
29832
  },
29794
29833
  getAdditionalEnvVars: function (ctx) {
29834
+ var _a;
29795
29835
  var fullName = ctx.fullName,
29796
29836
  env = ctx.env,
29797
29837
  componentName = ctx.componentName,
29798
29838
  deployConfigRaw = ctx.deployConfigRaw;
29799
- var HOST_CANONICAL = fullName.toLowerCase() + "-" + process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)];
29839
+ var HOST_CANONICAL = fullName.toLowerCase() + "-" + ((_a = process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)]) !== null && _a !== void 0 ? _a : "unknown-host.example.com");
29800
29840
  var jobTriggers = deployConfigRaw && deployConfigRaw.jobs ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(function (_a) {
29801
29841
  var _b = __read(_a, 2),
29802
29842
  name = _b[0],
@@ -29861,7 +29901,12 @@ var createArgsString = function (args) {
29861
29901
  var _b = __read(_a, 2),
29862
29902
  key = _b[0],
29863
29903
  value = _b[1];
29864
- return "--".concat(key).concat(value !== true ? "=".concat(value) : "");
29904
+ if (value === true) {
29905
+ return "--".concat(key);
29906
+ } else if (value === false) {
29907
+ return "--no-".concat(key);
29908
+ }
29909
+ return "--".concat(key, "=").concat(value);
29865
29910
  }).join(" ");
29866
29911
  };
29867
29912
  exports.createArgsString = createArgsString;
@@ -30281,7 +30326,7 @@ var base_1 = __nccwpck_require__(1188);
30281
30326
  var types_1 = __nccwpck_require__(4436);
30282
30327
  var kubeValues_1 = __nccwpck_require__(2830);
30283
30328
  var createKubernetesDeployJobs = function (context) {
30284
- var _a, _b;
30329
+ var _a, _b, _c;
30285
30330
  var deployConfig = context.componentConfig.deploy;
30286
30331
  if (deployConfig === false) {
30287
30332
  return [];
@@ -30305,10 +30350,10 @@ var createKubernetesDeployJobs = function (context) {
30305
30350
  quotingType: "'",
30306
30351
  forceQuotes: true
30307
30352
  }),
30308
- HELM_GITLAB_CHART_NAME: "the-panter-chart",
30309
- HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_a = deployConfig.additionalHelmArgs) !== null && _a !== void 0 ? _a : []), false).join(" "),
30353
+ HELM_GITLAB_CHART_NAME: (_a = deployConfig.chartName) !== null && _a !== void 0 ? _a : "/helm-charts/the-panter-chart",
30354
+ HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_b = deployConfig.additionalHelmArgs) !== null && _b !== void 0 ? _b : []), false).join(" "),
30310
30355
  COMPONENT_NAME: context.componentName,
30311
- BUILD_ID: (_b = context.commitInfo) === null || _b === void 0 ? void 0 : _b.buildId
30356
+ BUILD_ID: (_c = context.commitInfo) === null || _c === void 0 ? void 0 : _c.buildId
30312
30357
  })
30313
30358
  };
30314
30359
  var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
@@ -31201,22 +31246,183 @@ exports.getBaseCommitInfo = getBaseCommitInfo;
31201
31246
 
31202
31247
  /***/ }),
31203
31248
 
31204
- /***/ 4244:
31249
+ /***/ 6579:
31205
31250
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
31206
31251
 
31207
31252
  "use strict";
31208
31253
 
31209
31254
 
31210
- var __assign = this && this.__assign || function () {
31211
- __assign = Object.assign || function (t) {
31212
- for (var s, i = 1, n = arguments.length; i < n; i++) {
31213
- s = arguments[i];
31214
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
31255
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
31256
+ function adopt(value) {
31257
+ return value instanceof P ? value : new P(function (resolve) {
31258
+ resolve(value);
31259
+ });
31260
+ }
31261
+ return new (P || (P = Promise))(function (resolve, reject) {
31262
+ function fulfilled(value) {
31263
+ try {
31264
+ step(generator.next(value));
31265
+ } catch (e) {
31266
+ reject(e);
31267
+ }
31215
31268
  }
31216
- return t;
31217
- };
31218
- return __assign.apply(this, arguments);
31269
+ function rejected(value) {
31270
+ try {
31271
+ step(generator["throw"](value));
31272
+ } catch (e) {
31273
+ reject(e);
31274
+ }
31275
+ }
31276
+ function step(result) {
31277
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
31278
+ }
31279
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31280
+ });
31281
+ };
31282
+ var __generator = this && this.__generator || function (thisArg, body) {
31283
+ var _ = {
31284
+ label: 0,
31285
+ sent: function () {
31286
+ if (t[0] & 1) throw t[1];
31287
+ return t[1];
31288
+ },
31289
+ trys: [],
31290
+ ops: []
31291
+ },
31292
+ f,
31293
+ y,
31294
+ t,
31295
+ g;
31296
+ return g = {
31297
+ next: verb(0),
31298
+ "throw": verb(1),
31299
+ "return": verb(2)
31300
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
31301
+ return this;
31302
+ }), g;
31303
+ function verb(n) {
31304
+ return function (v) {
31305
+ return step([n, v]);
31306
+ };
31307
+ }
31308
+ function step(op) {
31309
+ if (f) throw new TypeError("Generator is already executing.");
31310
+ while (_) try {
31311
+ 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;
31312
+ if (y = 0, t) op = [op[0] & 2, t.value];
31313
+ switch (op[0]) {
31314
+ case 0:
31315
+ case 1:
31316
+ t = op;
31317
+ break;
31318
+ case 4:
31319
+ _.label++;
31320
+ return {
31321
+ value: op[1],
31322
+ done: false
31323
+ };
31324
+ case 5:
31325
+ _.label++;
31326
+ y = op[1];
31327
+ op = [0];
31328
+ continue;
31329
+ case 7:
31330
+ op = _.ops.pop();
31331
+ _.trys.pop();
31332
+ continue;
31333
+ default:
31334
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
31335
+ _ = 0;
31336
+ continue;
31337
+ }
31338
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
31339
+ _.label = op[1];
31340
+ break;
31341
+ }
31342
+ if (op[0] === 6 && _.label < t[1]) {
31343
+ _.label = t[1];
31344
+ t = op;
31345
+ break;
31346
+ }
31347
+ if (t && _.label < t[2]) {
31348
+ _.label = t[2];
31349
+ _.ops.push(op);
31350
+ break;
31351
+ }
31352
+ if (t[2]) _.ops.pop();
31353
+ _.trys.pop();
31354
+ continue;
31355
+ }
31356
+ op = body.call(thisArg, _);
31357
+ } catch (e) {
31358
+ op = [6, e];
31359
+ y = 0;
31360
+ } finally {
31361
+ f = t = 0;
31362
+ }
31363
+ if (op[0] & 5) throw op[1];
31364
+ return {
31365
+ value: op[0] ? op[1] : void 0,
31366
+ done: true
31367
+ };
31368
+ }
31219
31369
  };
31370
+ exports.__esModule = true;
31371
+ exports.createAllJobs = void 0;
31372
+ var config_1 = __nccwpck_require__(8906);
31373
+ var createJobsForComponent_1 = __nccwpck_require__(5327);
31374
+ var createAllJobs = function (config, trigger) {
31375
+ return __awaiter(void 0, void 0, void 0, function () {
31376
+ var _a, _b;
31377
+ return __generator(this, function (_c) {
31378
+ switch (_c.label) {
31379
+ case 0:
31380
+ _b = (_a = Object).fromEntries;
31381
+ return [4 /*yield*/, Promise.all(Object.keys(config.components).map(function (componentName) {
31382
+ return __awaiter(void 0, void 0, void 0, function () {
31383
+ var envs, _a, _b, _c;
31384
+ return __generator(this, function (_d) {
31385
+ switch (_d.label) {
31386
+ case 0:
31387
+ envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
31388
+ _a = [componentName];
31389
+ _c = (_b = Object).fromEntries;
31390
+ return [4 /*yield*/, Promise.all(envs.map(function (env) {
31391
+ return __awaiter(void 0, void 0, void 0, function () {
31392
+ var _a;
31393
+ return __generator(this, function (_b) {
31394
+ switch (_b.label) {
31395
+ case 0:
31396
+ _a = [env];
31397
+ return [4 /*yield*/, (0, createJobsForComponent_1.createJobsForComponent)(config, componentName, env, trigger)];
31398
+ case 1:
31399
+ return [2 /*return*/, _a.concat([_b.sent()])];
31400
+ }
31401
+ });
31402
+ });
31403
+ }))];
31404
+ case 1:
31405
+ return [2 /*return*/, _a.concat([_c.apply(_b, [_d.sent()])])];
31406
+ }
31407
+ });
31408
+ });
31409
+ }))];
31410
+ case 1:
31411
+ return [2 /*return*/, _b.apply(_a, [_c.sent()])];
31412
+ }
31413
+ });
31414
+ });
31415
+ };
31416
+ exports.createAllJobs = createAllJobs;
31417
+
31418
+ /***/ }),
31419
+
31420
+ /***/ 4244:
31421
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
31422
+
31423
+ "use strict";
31424
+
31425
+
31220
31426
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
31221
31427
  function adopt(value) {
31222
31428
  return value instanceof P ? value : new P(function (resolve) {
@@ -31369,54 +31575,40 @@ var config_1 = __nccwpck_require__(8906);
31369
31575
  var rules_1 = __nccwpck_require__(1410);
31370
31576
  var runner_1 = __nccwpck_require__(7666);
31371
31577
  var jobs_1 = __nccwpck_require__(9072);
31372
- var createJobs_1 = __nccwpck_require__(1820);
31578
+ var createAllJobs_1 = __nccwpck_require__(6579);
31579
+ var createGitlabJobs_1 = __nccwpck_require__(5569);
31373
31580
  var createChildPipeline = function (type, trigger, config) {
31374
31581
  return __awaiter(void 0, void 0, void 0, function () {
31375
- var components, jobs, allEnvs, stages, pipeline;
31376
- return __generator(this, function (_a) {
31377
- switch (_a.label) {
31582
+ var jobs, allEnvs, stages, pipeline;
31583
+ var _a;
31584
+ return __generator(this, function (_b) {
31585
+ switch (_b.label) {
31378
31586
  case 0:
31379
- components = Object.keys(config.components);
31380
- return [4 /*yield*/, components.reduce(function (acc, componentName) {
31381
- return __awaiter(void 0, void 0, void 0, function () {
31382
- var envs, _a, _b;
31383
- return __generator(this, function (_c) {
31384
- switch (_c.label) {
31385
- case 0:
31386
- envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
31387
- _a = [{}];
31388
- return [4 /*yield*/, acc];
31389
- case 1:
31390
- _b = [__assign.apply(void 0, _a.concat([_c.sent()]))];
31391
- return [4 /*yield*/, (0, createJobs_1.createJobs)(type, envs, config, componentName, trigger)];
31392
- case 2:
31393
- return [2 /*return*/, __assign.apply(void 0, _b.concat([_c.sent()]))];
31394
- }
31395
- });
31396
- });
31397
- }, Promise.resolve({}))];
31587
+ return [4 /*yield*/, (0, createAllJobs_1.createAllJobs)(config, trigger)];
31398
31588
  case 1:
31399
- jobs = _a.sent();
31589
+ jobs = _b.sent();
31400
31590
  allEnvs = (0, config_1.getAllEnvsInAllComponents)(config);
31401
31591
  stages = jobs_1.BASE_STAGES.reduce(function (acc, baseStage) {
31402
31592
  return __spreadArray(__spreadArray(__spreadArray([], __read(acc), false), [baseStage], false), __read(allEnvs.map(function (e) {
31403
31593
  return "".concat(baseStage, " ").concat(e);
31404
31594
  })), false);
31405
31595
  }, []);
31406
- if (type === "gitlab") {
31407
- pipeline = {
31408
- image: (0, runner_1.getRunnerImage)("jobs-default"),
31409
- variables: {
31410
- FF_USE_FASTZIP: "true"
31411
- },
31412
- workflow: {
31413
- rules: rules_1.RULES_ALWAYS
31414
- },
31415
- stages: stages,
31416
- jobs: jobs
31417
- };
31418
- return [2 /*return*/, pipeline];
31419
- }
31596
+ if (!(type === "gitlab")) return [3 /*break*/, 3];
31597
+ _a = {
31598
+ image: (0, runner_1.getRunnerImage)("jobs-default"),
31599
+ variables: {
31600
+ FF_USE_FASTZIP: "true"
31601
+ },
31602
+ workflow: {
31603
+ rules: rules_1.RULES_ALWAYS
31604
+ },
31605
+ stages: stages
31606
+ };
31607
+ return [4 /*yield*/, (0, createGitlabJobs_1.createGitlabJobs)(jobs)];
31608
+ case 2:
31609
+ pipeline = (_a.jobs = _b.sent(), _a);
31610
+ return [2 /*return*/, pipeline];
31611
+ case 3:
31420
31612
  throw new Error("".concat(type, " is not supported"));
31421
31613
  }
31422
31614
  });
@@ -31426,7 +31618,7 @@ exports.createChildPipeline = createChildPipeline;
31426
31618
 
31427
31619
  /***/ }),
31428
31620
 
31429
- /***/ 1820:
31621
+ /***/ 5327:
31430
31622
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
31431
31623
 
31432
31624
  "use strict";
@@ -31597,14 +31789,12 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
31597
31789
  return to.concat(ar || Array.prototype.slice.call(from));
31598
31790
  };
31599
31791
  exports.__esModule = true;
31600
- exports.createJobs = void 0;
31792
+ exports.createJobsForComponent = void 0;
31601
31793
  var lodash_1 = __nccwpck_require__(3255);
31602
31794
  var build_1 = __nccwpck_require__(2004);
31603
31795
  var context_1 = __nccwpck_require__(7123);
31604
31796
  var deploy_1 = __nccwpck_require__(1264);
31605
- var utils_1 = __nccwpck_require__(1815);
31606
31797
  var getCommitInfo_1 = __nccwpck_require__(802);
31607
- var makeGitlabJob_1 = __nccwpck_require__(726);
31608
31798
  var packageManager_1 = __nccwpck_require__(3214);
31609
31799
  var injectDefaultVarsInCustomJobs = function (context, jobs) {
31610
31800
  return jobs.map(function (_a) {
@@ -31632,76 +31822,9 @@ var createRawJobs = function (context) {
31632
31822
  var customJobs = getCustomJobs(context);
31633
31823
  return __spreadArray(__spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false), __read(customJobs), false);
31634
31824
  };
31635
- var getFullJobName = function (name, componentName, env) {
31636
- if (env) {
31637
- return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
31638
- }
31639
- return "".concat(componentName, " ").concat(name);
31640
- };
31641
- var getFullReferencedJobName = function (referencedJobName, componentName, env, allRawJobs) {
31642
- var referencedJob = allRawJobs.find(function (j) {
31643
- return j.name === referencedJobName;
31644
- });
31645
- if (!referencedJob) {
31646
- throw new Error("unknown job referenced: " + referencedJobName);
31647
- }
31648
- var envToSet = referencedJob.envMode !== "none" ? env : null;
31649
- return getFullJobName(referencedJobName, componentName, envToSet);
31650
- };
31651
- // replaces references to other jobs with the full name
31652
- // the full name contains the componentname and the env name (if any)
31653
- var replaceReferences = function (job, componentName, env, allRawJobs) {
31654
- var _a, _b, _c;
31655
- var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
31656
- var needsFromNeeds = (_a = job.needs) === null || _a === void 0 ? void 0 : _a.map(function (n) {
31657
- return (0, lodash_1.isObject)(n) ? {
31658
- job: getFullReferencedJobName(n.job, componentName, env, allRawJobs),
31659
- artifacts: n.artifacts
31660
- } : getFullReferencedJobName(n, componentName, env, allRawJobs);
31661
- });
31662
- var needsFromOtherComponents = (_b = job.needsOtherComponent) === null || _b === void 0 ? void 0 : _b.map(function (other) {
31663
- return {
31664
- artifacts: other.artifacts,
31665
- job: getFullReferencedJobName(other.job, other.componentName, env, allRawJobs)
31666
- };
31667
- });
31668
- var needs = __spreadArray(__spreadArray([], __read(needsFromNeeds !== null && needsFromNeeds !== void 0 ? needsFromNeeds : []), false), __read(needsFromOtherComponents !== null && needsFromOtherComponents !== void 0 ? needsFromOtherComponents : []), false);
31669
- return __assign(__assign({}, job), {
31670
- stage: stage,
31671
- needs: needs,
31672
- environment: ((_c = job.environment) === null || _c === void 0 ? void 0 : _c.on_stop) ? __assign(__assign({}, job.environment), {
31673
- on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allRawJobs)
31674
- }) : job.environment
31675
- });
31676
- };
31677
- // this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
31678
- var addStageNeeds = function (jobs) {
31679
- // when a job defines needsStages, we add these as needs
31680
- return jobs.map(function (job) {
31681
- var _a;
31682
- if (!job.needsStages || job.needsStages.length === 0) {
31683
- return job;
31684
- }
31685
- var neededJobs = jobs.map(function (j) {
31686
- var _a, _b;
31687
- var neededStage = (_a = job.needsStages) === null || _a === void 0 ? void 0 : _a.find(function (s) {
31688
- return j.stage === s.stage;
31689
- });
31690
- if (neededStage) {
31691
- return {
31692
- job: j.name,
31693
- artifacts: (_b = neededStage.artifacts) !== null && _b !== void 0 ? _b : false
31694
- };
31695
- }
31696
- }).filter(utils_1.notNil);
31697
- return __assign(__assign({}, job), {
31698
- needs: __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
31699
- });
31700
- });
31701
- };
31702
- var createJobs = function (type, envs, config, componentName, trigger) {
31825
+ var createJobsForComponent = function (config, componentName, env, trigger) {
31703
31826
  return __awaiter(void 0, void 0, void 0, function () {
31704
- var commitInfo, _a, packageManagerInfo;
31827
+ var commitInfo, _a, packageManagerInfo, context;
31705
31828
  return __generator(this, function (_b) {
31706
31829
  switch (_b.label) {
31707
31830
  case 0:
@@ -31714,47 +31837,19 @@ var createJobs = function (type, envs, config, componentName, trigger) {
31714
31837
  return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfo)(config, componentName)];
31715
31838
  case 2:
31716
31839
  packageManagerInfo = _b.sent();
31717
- return [2 /*return*/, envs.reduce(function (acc, env) {
31718
- return __awaiter(void 0, void 0, void 0, function () {
31719
- var context, jobs, result, _a, _b, _c, _d, _e;
31720
- return __generator(this, function (_f) {
31721
- switch (_f.label) {
31722
- case 0:
31723
- return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
31724
- case 1:
31725
- context = _f.sent();
31726
- jobs = addStageNeeds(createRawJobs(context));
31727
- _a = [{}];
31728
- return [4 /*yield*/, acc];
31729
- case 2:
31730
- _b = [__assign.apply(void 0, _a.concat([_f.sent()]))];
31731
- _d = (_c = jobs).reduce;
31732
- _e = [function (acc, job) {
31733
- var _a;
31734
- var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
31735
- var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
31736
- if (type === "gitlab") {
31737
- return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
31738
- }
31739
- throw new Error("not supported");
31740
- }];
31741
- return [4 /*yield*/, Promise.resolve({})];
31742
- case 3:
31743
- result = __assign.apply(void 0, _b.concat([_d.apply(_c, _e.concat([_f.sent()]))]));
31744
- return [2 /*return*/, result];
31745
- }
31746
- });
31747
- });
31748
- }, {})];
31840
+ return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
31841
+ case 3:
31842
+ context = _b.sent();
31843
+ return [2 /*return*/, createRawJobs(context)];
31749
31844
  }
31750
31845
  });
31751
31846
  });
31752
31847
  };
31753
- exports.createJobs = createJobs;
31848
+ exports.createJobsForComponent = createJobsForComponent;
31754
31849
 
31755
31850
  /***/ }),
31756
31851
 
31757
- /***/ 726:
31852
+ /***/ 5569:
31758
31853
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
31759
31854
 
31760
31855
  "use strict";
@@ -31770,6 +31865,121 @@ var __assign = this && this.__assign || function () {
31770
31865
  };
31771
31866
  return __assign.apply(this, arguments);
31772
31867
  };
31868
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
31869
+ function adopt(value) {
31870
+ return value instanceof P ? value : new P(function (resolve) {
31871
+ resolve(value);
31872
+ });
31873
+ }
31874
+ return new (P || (P = Promise))(function (resolve, reject) {
31875
+ function fulfilled(value) {
31876
+ try {
31877
+ step(generator.next(value));
31878
+ } catch (e) {
31879
+ reject(e);
31880
+ }
31881
+ }
31882
+ function rejected(value) {
31883
+ try {
31884
+ step(generator["throw"](value));
31885
+ } catch (e) {
31886
+ reject(e);
31887
+ }
31888
+ }
31889
+ function step(result) {
31890
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
31891
+ }
31892
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31893
+ });
31894
+ };
31895
+ var __generator = this && this.__generator || function (thisArg, body) {
31896
+ var _ = {
31897
+ label: 0,
31898
+ sent: function () {
31899
+ if (t[0] & 1) throw t[1];
31900
+ return t[1];
31901
+ },
31902
+ trys: [],
31903
+ ops: []
31904
+ },
31905
+ f,
31906
+ y,
31907
+ t,
31908
+ g;
31909
+ return g = {
31910
+ next: verb(0),
31911
+ "throw": verb(1),
31912
+ "return": verb(2)
31913
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
31914
+ return this;
31915
+ }), g;
31916
+ function verb(n) {
31917
+ return function (v) {
31918
+ return step([n, v]);
31919
+ };
31920
+ }
31921
+ function step(op) {
31922
+ if (f) throw new TypeError("Generator is already executing.");
31923
+ while (_) try {
31924
+ 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;
31925
+ if (y = 0, t) op = [op[0] & 2, t.value];
31926
+ switch (op[0]) {
31927
+ case 0:
31928
+ case 1:
31929
+ t = op;
31930
+ break;
31931
+ case 4:
31932
+ _.label++;
31933
+ return {
31934
+ value: op[1],
31935
+ done: false
31936
+ };
31937
+ case 5:
31938
+ _.label++;
31939
+ y = op[1];
31940
+ op = [0];
31941
+ continue;
31942
+ case 7:
31943
+ op = _.ops.pop();
31944
+ _.trys.pop();
31945
+ continue;
31946
+ default:
31947
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
31948
+ _ = 0;
31949
+ continue;
31950
+ }
31951
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
31952
+ _.label = op[1];
31953
+ break;
31954
+ }
31955
+ if (op[0] === 6 && _.label < t[1]) {
31956
+ _.label = t[1];
31957
+ t = op;
31958
+ break;
31959
+ }
31960
+ if (t && _.label < t[2]) {
31961
+ _.label = t[2];
31962
+ _.ops.push(op);
31963
+ break;
31964
+ }
31965
+ if (t[2]) _.ops.pop();
31966
+ _.trys.pop();
31967
+ continue;
31968
+ }
31969
+ op = body.call(thisArg, _);
31970
+ } catch (e) {
31971
+ op = [6, e];
31972
+ y = 0;
31973
+ } finally {
31974
+ f = t = 0;
31975
+ }
31976
+ if (op[0] & 5) throw op[1];
31977
+ return {
31978
+ value: op[0] ? op[1] : void 0,
31979
+ done: true
31980
+ };
31981
+ }
31982
+ };
31773
31983
  var __rest = this && this.__rest || function (s, e) {
31774
31984
  var t = {};
31775
31985
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -31778,30 +31988,127 @@ var __rest = this && this.__rest || function (s, e) {
31778
31988
  }
31779
31989
  return t;
31780
31990
  };
31991
+ var __read = this && this.__read || function (o, n) {
31992
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
31993
+ if (!m) return o;
31994
+ var i = m.call(o),
31995
+ r,
31996
+ ar = [],
31997
+ e;
31998
+ try {
31999
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
32000
+ } catch (error) {
32001
+ e = {
32002
+ error: error
32003
+ };
32004
+ } finally {
32005
+ try {
32006
+ if (r && !r.done && (m = i["return"])) m.call(i);
32007
+ } finally {
32008
+ if (e) throw e.error;
32009
+ }
32010
+ }
32011
+ return ar;
32012
+ };
32013
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
32014
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
32015
+ if (ar || !(i in from)) {
32016
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
32017
+ ar[i] = from[i];
32018
+ }
32019
+ }
32020
+ return to.concat(ar || Array.prototype.slice.call(from));
32021
+ };
31781
32022
  exports.__esModule = true;
31782
- exports.makeGitlabJob = void 0;
32023
+ exports.createGitlabJobs = exports.makeGitlabJob = void 0;
31783
32024
  var lodash_1 = __nccwpck_require__(3255);
31784
32025
  var defaults_1 = __nccwpck_require__(7328);
32026
+ var getFullJobName = function (name, componentName, env) {
32027
+ if (env) {
32028
+ return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
32029
+ }
32030
+ return "".concat(componentName, " ").concat(name);
32031
+ };
32032
+ var getFullReferencedJobName = function (referencedJobName, componentName, env, allJobs) {
32033
+ var _a, _b;
32034
+ var referencedJob = (_b = (_a = allJobs[componentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.find(function (j) {
32035
+ return j.name === referencedJobName;
32036
+ });
32037
+ if (!referencedJob) {
32038
+ throw new Error("unknown job referenced: '".concat(referencedJobName, "' from '").concat(env, ":").concat(componentName, "'"));
32039
+ }
32040
+ var envToSet = referencedJob.envMode !== "none" ? env : null;
32041
+ return getFullJobName(referencedJobName, componentName, envToSet);
32042
+ };
31785
32043
  var getJobName = function (need) {
31786
32044
  return (0, lodash_1.isObject)(need) ? need.job : need;
31787
32045
  };
31788
- var makeGitlabJob = function (_a) {
32046
+ var makeGitlabJob = function (componentName, env, _a, allJobs) {
32047
+ var _b;
31789
32048
  var envMode = _a.envMode,
31790
32049
  needsStages = _a.needsStages,
31791
32050
  needsOtherComponent = _a.needsOtherComponent,
31792
32051
  name = _a.name,
31793
32052
  needs = _a.needs,
31794
- rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
31795
- return __assign(__assign({}, rest), {
32053
+ job = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
32054
+ var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
32055
+ var cleanedNeeds = __spreadArray(__spreadArray([], __read(needs !== null && needs !== void 0 ? needs : []), false), __read(needsOtherComponent !== null && needsOtherComponent !== void 0 ? needsOtherComponent : []), false);
32056
+ var gitlabNeedsFromNeeds = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
32057
+ var _a;
32058
+ return (0, lodash_1.isObject)(n) ? {
32059
+ job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allJobs),
32060
+ artifacts: n.artifacts
32061
+ } : getFullReferencedJobName(n, componentName, env, allJobs);
32062
+ });
32063
+ var gitlabNeedsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
32064
+ var _a, _b;
32065
+ return (_b = (_a = allJobs[componentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.filter(function (j) {
32066
+ return j.stage === n.stage;
32067
+ }).map(function (j) {
32068
+ var _a;
32069
+ return {
32070
+ job: getFullReferencedJobName(j.name, componentName, env, allJobs),
32071
+ artifacts: (_a = n.artifacts) !== null && _a !== void 0 ? _a : false
32072
+ };
32073
+ });
32074
+ });
32075
+ var gitlabNeeds = __spreadArray(__spreadArray([], __read(gitlabNeedsFromNeeds), false), __read(gitlabNeedsFromStages !== null && gitlabNeedsFromStages !== void 0 ? gitlabNeedsFromStages : []), false).sort(function (a, b) {
32076
+ return getJobName(a).localeCompare(getJobName(b));
32077
+ });
32078
+ var fullJobName = getFullJobName(name, componentName, envMode !== "none" ? env : undefined);
32079
+ var gitlabJob = __assign(__assign({}, job), {
32080
+ stage: stage,
32081
+ environment: ((_b = job.environment) === null || _b === void 0 ? void 0 : _b.on_stop) ? __assign(__assign({}, job.environment), {
32082
+ on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allJobs)
32083
+ }) : job.environment,
31796
32084
  // sort in a predictable manner for snapshot tests
31797
- needs: needs === null || needs === void 0 ? void 0 : needs.sort(function (a, b) {
31798
- return getJobName(a).localeCompare(getJobName(b));
31799
- }),
32085
+ needs: gitlabNeeds,
31800
32086
  retry: defaults_1.BASE_RETRY,
31801
32087
  interruptible: true
31802
32088
  });
32089
+ return [fullJobName, gitlabJob];
31803
32090
  };
31804
32091
  exports.makeGitlabJob = makeGitlabJob;
32092
+ var createGitlabJobs = function (allJobs) {
32093
+ return __awaiter(void 0, void 0, void 0, function () {
32094
+ return __generator(this, function (_a) {
32095
+ return [2 /*return*/, Object.keys(allJobs).reduce(function (accForComponents, componentName) {
32096
+ var componentJobs = allJobs[componentName];
32097
+ return __assign(__assign({}, accForComponents), Object.keys(componentJobs).reduce(function (accForEnvs, env) {
32098
+ var jobs = componentJobs[env];
32099
+ return __assign(__assign({}, accForEnvs), jobs.reduce(function (accForJobs, job) {
32100
+ var _a;
32101
+ var _b = __read((0, exports.makeGitlabJob)(componentName, env, job, allJobs), 2),
32102
+ fullJobName = _b[0],
32103
+ gitlabJob = _b[1];
32104
+ return __assign(__assign({}, accForJobs), (_a = {}, _a[fullJobName] = gitlabJob, _a));
32105
+ }, {}));
32106
+ }, {}));
32107
+ }, {})];
32108
+ });
32109
+ });
32110
+ };
32111
+ exports.createGitlabJobs = createGitlabJobs;
31805
32112
 
31806
32113
  /***/ }),
31807
32114
 
@@ -31828,7 +32135,7 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
31828
32135
  };
31829
32136
  exports.__esModule = true;
31830
32137
  __exportStar(__nccwpck_require__(4244), exports);
31831
- __exportStar(__nccwpck_require__(1820), exports);
32138
+ __exportStar(__nccwpck_require__(5327), exports);
31832
32139
 
31833
32140
  /***/ }),
31834
32141