@catladder/pipeline 0.0.0-kube-command-59ed84cc → 0.0.0-kubernetes-new-cloudsql-d0cdae5b

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 (60) hide show
  1. package/dist/build/docker.d.ts +4 -18
  2. package/dist/build/docker.js +15 -9
  3. package/dist/build/rails/build.js +4 -8
  4. package/dist/build/rails/test.js +1 -2
  5. package/dist/bundles/catladder-gitlab/index.js +476 -197
  6. package/dist/constants.js +1 -1
  7. package/dist/deploy/cloudRun/index.js +5 -4
  8. package/dist/deploy/cloudSql/utils.d.ts +3 -0
  9. package/dist/deploy/cloudSql/utils.js +9 -0
  10. package/dist/deploy/kubernetes/cloudSql/index.d.ts +10 -10
  11. package/dist/deploy/kubernetes/cloudSql/index.js +36 -15
  12. package/dist/deploy/kubernetes/kubeValues.d.ts +1 -6
  13. package/dist/deploy/kubernetes/kubeValues.js +1 -1
  14. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +1 -6
  15. package/dist/deploy/types/kubernetes.d.ts +43 -6
  16. package/dist/pipeline/createAllJobs.d.ts +8 -0
  17. package/dist/pipeline/createAllJobs.js +164 -0
  18. package/dist/pipeline/createChildPipeline.js +24 -48
  19. package/dist/pipeline/createJobsForComponent.d.ts +3 -0
  20. package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -100
  21. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
  22. package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
  23. package/dist/pipeline/index.d.ts +1 -1
  24. package/dist/pipeline/index.js +1 -1
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +8 -20
  27. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +8 -20
  28. package/examples/__snapshots__/cloud-run-non-public.ts.snap +8 -20
  29. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +16 -40
  30. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +16 -40
  31. package/examples/__snapshots__/custom-build-job.ts.snap +8 -20
  32. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +2240 -0
  33. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +2252 -0
  34. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +48 -12
  35. package/examples/kubernetes-with-cloud-sql-legacy.ts +33 -0
  36. package/examples/kubernetes-with-cloud-sql.ts +35 -0
  37. package/package.json +1 -1
  38. package/src/build/docker.ts +13 -6
  39. package/src/build/index.ts +1 -1
  40. package/src/build/node/cache.ts +2 -2
  41. package/src/build/rails/build.ts +9 -6
  42. package/src/build/rails/test.ts +43 -39
  43. package/src/config/configruedEnvs.ts +2 -8
  44. package/src/deploy/cloudRun/index.ts +7 -8
  45. package/src/deploy/cloudSql/utils.ts +23 -0
  46. package/src/deploy/kubernetes/cloudSql/index.ts +58 -14
  47. package/src/deploy/kubernetes/deployJob.ts +2 -1
  48. package/src/deploy/kubernetes/kubeValues.ts +7 -2
  49. package/src/deploy/types/kubernetes.ts +48 -6
  50. package/src/pipeline/createAllJobs.ts +38 -0
  51. package/src/pipeline/createChildPipeline.ts +6 -22
  52. package/src/pipeline/createJobsForComponent.ts +64 -0
  53. package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
  54. package/src/pipeline/index.ts +1 -1
  55. package/src/types/gitlab-types.ts +8 -6
  56. package/dist/pipeline/createJobs.d.ts +0 -3
  57. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
  58. package/dist/pipeline/gitlab/makeGitlabJob.js +0 -75
  59. package/src/pipeline/createJobs.ts +0 -196
  60. package/src/pipeline/gitlab/makeGitlabJob.ts +0 -25
@@ -27232,18 +27232,22 @@ var requiresDockerBuild = function (context) {
27232
27232
  return false;
27233
27233
  };
27234
27234
  exports.requiresDockerBuild = requiresDockerBuild;
27235
+ var getDockerBaseVariables = function () {
27236
+ return {
27237
+ DOCKER_HOST: "tcp://0.0.0.0:2375",
27238
+ DOCKER_TLS_CERTDIR: "",
27239
+ DOCKER_DRIVER: "overlay2",
27240
+ DOCKER_BUILDKIT: "1"
27241
+ };
27242
+ };
27235
27243
  var getDockerBuildVariables = function (context) {
27236
27244
  var _a, _b, _c, _d;
27237
- return __assign(__assign(__assign({}, DOCKER_RUNNER_BUILD_VARIABLES), {
27238
- DOCKER_BUILDKIT: "1",
27245
+ return __assign(__assign(__assign(__assign({}, DOCKER_RUNNER_BUILD_VARIABLES), {
27239
27246
  DOCKERFILE_ADDITIONS: (_b = (_a = context.componentConfig.build.docker) === null || _a === void 0 ? void 0 : _a.additionsBegin) === null || _b === void 0 ? void 0 : _b.join("\n"),
27240
27247
  DOCKERFILE_ADDITIONS_END: (_d = (_c = context.componentConfig.build.docker) === null || _c === void 0 ? void 0 : _c.additionsEnd) === null || _d === void 0 ? void 0 : _d.join("\n"),
27241
27248
  APP_DIR: context.componentConfig.dir,
27242
- DOCKER_HOST: "tcp://0.0.0.0:2375",
27243
- DOCKER_TLS_CERTDIR: "",
27244
- DOCKER_DIR: ".",
27245
- DOCKER_DRIVER: "overlay2"
27246
- }), (0, exports.getDockerImageVariables)(context));
27249
+ DOCKER_DIR: "."
27250
+ }), getDockerBaseVariables()), (0, exports.getDockerImageVariables)(context));
27247
27251
  };
27248
27252
  exports.getDockerBuildVariables = getDockerBuildVariables;
27249
27253
  exports.DOCKER_BUILD_JOB_NAME = "🔨 docker";
@@ -27254,7 +27258,7 @@ var getDockerJobBaseProps = function (context) {
27254
27258
  name: "docker:20-dind",
27255
27259
  command: ["--tls=false"]
27256
27260
  }],
27257
- variables: (0, exports.getDockerBuildVariables)(context)
27261
+ variables: getDockerBaseVariables()
27258
27262
  };
27259
27263
  };
27260
27264
  exports.getDockerJobBaseProps = getDockerJobBaseProps;
@@ -27267,7 +27271,9 @@ var createDockerBuildJobBase = function (context, _a) {
27267
27271
  stage: "build"
27268
27272
  }, (0, exports.getDockerJobBaseProps)(context)), {
27269
27273
  script: script || []
27270
- }), def);
27274
+ }), {
27275
+ variables: (0, exports.getDockerBuildVariables)(context)
27276
+ }, def);
27271
27277
  };
27272
27278
  exports.createDockerBuildJobBase = createDockerBuildJobBase;
27273
27279
  exports.gitlabDockerLogin = "docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY";
@@ -27916,29 +27922,25 @@ exports.createRailsBuildJobs = void 0;
27916
27922
  var types_1 = __nccwpck_require__(6575);
27917
27923
  var docker_1 = __nccwpck_require__(9953);
27918
27924
  var createRailsBuildJobs = function (context) {
27919
- var _a, _b, _c, _d, _e, _f;
27925
+ var _a, _b, _c;
27920
27926
  var buildConfig = context.componentConfig.build;
27921
27927
  if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
27922
27928
  // should not happen
27923
27929
  throw new Error("build type is not rails");
27924
27930
  }
27925
27931
  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) {
27932
+ var packEnvArgs = Object.entries((_a = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
27931
27933
  var _b = __read(_a, 2),
27932
27934
  k = _b[0],
27933
27935
  v = _b[1];
27934
27936
  return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
27935
- });
27937
+ }).join(" ");
27936
27938
  return [(0, docker_1.createDockerBuildJobBase)(context, {
27937
27939
  variables: context.componentConfig.build.extraVars,
27938
27940
  // custom script
27939
27941
  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",
27940
27942
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
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 : "")]
27943
+ "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, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")]
27942
27944
  })];
27943
27945
  };
27944
27946
  exports.createRailsBuildJobs = createRailsBuildJobs;
@@ -28062,9 +28064,8 @@ var createRailsTestJobs = function (context) {
28062
28064
  var bundlerCache = {
28063
28065
  key: {
28064
28066
  files: ["Gemfile.lock"],
28065
- prefix: "$CI_JOB_IMAGE" // a changed image might have different OS libraries which no longer work with the cached gems
28067
+ prefix: "$CI_JOB_IMAGE"
28066
28068
  },
28067
-
28068
28069
  paths: [bundlerCacheDir]
28069
28070
  };
28070
28071
  var auditJob = buildConfig.audit !== false ? __assign(__assign({
@@ -28350,7 +28351,7 @@ exports.readConfigSync = readConfigSync;
28350
28351
 
28351
28352
  exports.__esModule = true;
28352
28353
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
28353
- exports.PIPELINE_IMAGE_TAG = "kube-command-59ed84cc" || 0;
28354
+ exports.PIPELINE_IMAGE_TAG = "kubernetes-new-cloudsql-d0cdae5b" || 0;
28354
28355
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
28355
28356
 
28356
28357
  /***/ }),
@@ -29783,20 +29784,21 @@ exports.__esModule = true;
29783
29784
  exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
29784
29785
  var context_1 = __nccwpck_require__(7123);
29785
29786
  var gitlab_1 = __nccwpck_require__(9818);
29787
+ var utils_1 = __nccwpck_require__(4335);
29786
29788
  var deployJob_1 = __nccwpck_require__(5565);
29787
29789
  var jobName_1 = __nccwpck_require__(9357);
29788
29790
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
29789
29791
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
29790
29792
  var getCloudSqlVariables = function (_a) {
29791
- var _b, _c, _d, _e;
29793
+ var _b, _c;
29792
29794
  var deployConfigRaw = _a.deployConfigRaw,
29793
29795
  environmentSlugPrefix = _a.environmentSlugPrefix,
29794
29796
  env = _a.env,
29795
29797
  componentName = _a.componentName,
29796
29798
  fullConfig = _a.fullConfig;
29797
29799
  if (deployConfigRaw && deployConfigRaw.cloudSql) {
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) {
29800
+ var DB_NAME = (0, utils_1.getFullDbName)(deployConfigRaw.cloudSql, fullConfig, environmentSlugPrefix, componentName);
29801
+ var additionalQueryParamsString = Object.entries((_b = deployConfigRaw.cloudSql.dbAdditionalQueryParams) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
29800
29802
  var _b = __read(_a, 2),
29801
29803
  key = _b[0],
29802
29804
  value = _b[1];
@@ -29805,7 +29807,7 @@ var getCloudSqlVariables = function (_a) {
29805
29807
  return {
29806
29808
  CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
29807
29809
  DB_NAME: DB_NAME,
29808
- DB_USER: (_e = deployConfigRaw.cloudSql.dbUser) !== null && _e !== void 0 ? _e : "postgres",
29810
+ DB_USER: (_c = deployConfigRaw.cloudSql.dbUser) !== null && _c !== void 0 ? _c : "postgres",
29809
29811
  DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
29810
29812
  DATABASE_URL: "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME".concat(additionalQueryParamsString),
29811
29813
  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)
@@ -30016,6 +30018,22 @@ exports.getCloudRunJobName = getCloudRunJobName;
30016
30018
 
30017
30019
  /***/ }),
30018
30020
 
30021
+ /***/ 4335:
30022
+ /***/ ((__unused_webpack_module, exports) => {
30023
+
30024
+ "use strict";
30025
+
30026
+
30027
+ exports.__esModule = true;
30028
+ exports.getFullDbName = void 0;
30029
+ var getFullDbName = function (cloudSqlConfig, fullConfig, environmentSlugPrefix, componentName) {
30030
+ var _a, _b;
30031
+ return [(_a = cloudSqlConfig.dbNamePrefix) !== null && _a !== void 0 ? _a : "".concat(fullConfig.customerName, "-").concat(fullConfig.appName), environmentSlugPrefix, (_b = cloudSqlConfig.dbBaseName) !== null && _b !== void 0 ? _b : componentName].filter(Boolean).join("-");
30032
+ };
30033
+ exports.getFullDbName = getFullDbName;
30034
+
30035
+ /***/ }),
30036
+
30019
30037
  /***/ 494:
30020
30038
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
30021
30039
 
@@ -30239,8 +30257,9 @@ exports.additionalKubernetesSecretKeys = additionalKubernetesSecretKeys;
30239
30257
 
30240
30258
 
30241
30259
  exports.__esModule = true;
30242
- exports.createCloudsqlBaseConfig = exports.getKubernetesCloudSQLConfig = exports.hasKubernetesCloudSQL = void 0;
30260
+ exports.createKubernetesCloudsqlBaseValues = exports.hasKubernetesCloudSQL = void 0;
30243
30261
  var context_1 = __nccwpck_require__(7123);
30262
+ var utils_1 = __nccwpck_require__(4335);
30244
30263
  var types_1 = __nccwpck_require__(4436);
30245
30264
  var hasKubernetesCloudSQL = function (context) {
30246
30265
  var _a, _b;
@@ -30250,22 +30269,42 @@ var hasKubernetesCloudSQL = function (context) {
30250
30269
  return false;
30251
30270
  };
30252
30271
  exports.hasKubernetesCloudSQL = hasKubernetesCloudSQL;
30253
- var getKubernetesCloudSQLConfig = function (context) {
30254
- var _a;
30255
- if ((0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
30256
- return (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.cloudsql;
30272
+ var createKubernetesCloudsqlBaseValues = function (context) {
30273
+ var _a, _b, _c, _d, _e;
30274
+ if (!(0, types_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
30275
+ throw new Error("cannot get cloud sql config");
30276
+ }
30277
+ var config = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.cloudsql;
30278
+ if (!config) {
30279
+ throw new Error("cannot get cloud sql config");
30280
+ }
30281
+ var proxyCredentials = "$".concat((0, context_1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"));
30282
+ if ((config === null || config === void 0 ? void 0 : config.type) !== "unmanaged") {
30283
+ var instanceConnectionName = "".concat((_b = config.projectId) !== null && _b !== void 0 ? _b : "skynet-164509", ":").concat((_c = config.region) !== null && _c !== void 0 ? _c : "europe-west6", ":").concat((_d = config.instanceId) !== null && _d !== void 0 ? _d : context.environment.envVars.KUBE_NAMESPACE);
30284
+ return {
30285
+ cloudsql: {
30286
+ enabled: config.enabled,
30287
+ dbUser: "postgres",
30288
+ instanceConnectionName: instanceConnectionName,
30289
+ proxyCredentials: proxyCredentials,
30290
+ fullDbName: context.environment.envVars.KUBE_APP_NAME
30291
+ }
30292
+ };
30293
+ } else if (config.type === "unmanaged") {
30294
+ return {
30295
+ cloudsql: {
30296
+ enabled: config.enabled,
30297
+ dbUser: (_e = config.dbUser) !== null && _e !== void 0 ? _e : "postgres",
30298
+ instanceConnectionName: config.instanceConnectionName,
30299
+ proxyCredentials: proxyCredentials,
30300
+ fullDbName: (0, utils_1.getFullDbName)(config, context.fullConfig, context.environment.slugPrefix, context.componentName)
30301
+ }
30302
+ };
30303
+ } else {
30304
+ throw new Error("unknonw type");
30257
30305
  }
30258
- throw new Error("cannot get cloud sql config");
30259
- };
30260
- exports.getKubernetesCloudSQLConfig = getKubernetesCloudSQLConfig;
30261
- var createCloudsqlBaseConfig = function (context) {
30262
- return {
30263
- cloudsql: {
30264
- proxyCredentials: "$".concat((0, context_1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"))
30265
- }
30266
- };
30267
30306
  };
30268
- exports.createCloudsqlBaseConfig = createCloudsqlBaseConfig;
30307
+ exports.createKubernetesCloudsqlBaseValues = createKubernetesCloudsqlBaseValues;
30269
30308
 
30270
30309
  /***/ }),
30271
30310
 
@@ -30648,7 +30687,7 @@ var createKubeValues = function (context) {
30648
30687
  var defaultKubeValues = (0, lodash_1.merge)({
30649
30688
  env: env,
30650
30689
  application: createAppConfig(context, application)
30651
- }, (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) : {});
30690
+ }, (0, cloudSql_1.hasKubernetesCloudSQL)(context) ? (0, cloudSql_1.createKubernetesCloudsqlBaseValues)(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) : {});
30652
30691
  var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
30653
30692
  jobs: removeFalsy(jobs),
30654
30693
  cronjobs: removeFalsy(cronjobs)
@@ -31249,22 +31288,183 @@ exports.getBaseCommitInfo = getBaseCommitInfo;
31249
31288
 
31250
31289
  /***/ }),
31251
31290
 
31252
- /***/ 4244:
31291
+ /***/ 6579:
31253
31292
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
31254
31293
 
31255
31294
  "use strict";
31256
31295
 
31257
31296
 
31258
- var __assign = this && this.__assign || function () {
31259
- __assign = Object.assign || function (t) {
31260
- for (var s, i = 1, n = arguments.length; i < n; i++) {
31261
- s = arguments[i];
31262
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
31297
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
31298
+ function adopt(value) {
31299
+ return value instanceof P ? value : new P(function (resolve) {
31300
+ resolve(value);
31301
+ });
31302
+ }
31303
+ return new (P || (P = Promise))(function (resolve, reject) {
31304
+ function fulfilled(value) {
31305
+ try {
31306
+ step(generator.next(value));
31307
+ } catch (e) {
31308
+ reject(e);
31309
+ }
31263
31310
  }
31264
- return t;
31265
- };
31266
- return __assign.apply(this, arguments);
31311
+ function rejected(value) {
31312
+ try {
31313
+ step(generator["throw"](value));
31314
+ } catch (e) {
31315
+ reject(e);
31316
+ }
31317
+ }
31318
+ function step(result) {
31319
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
31320
+ }
31321
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31322
+ });
31323
+ };
31324
+ var __generator = this && this.__generator || function (thisArg, body) {
31325
+ var _ = {
31326
+ label: 0,
31327
+ sent: function () {
31328
+ if (t[0] & 1) throw t[1];
31329
+ return t[1];
31330
+ },
31331
+ trys: [],
31332
+ ops: []
31333
+ },
31334
+ f,
31335
+ y,
31336
+ t,
31337
+ g;
31338
+ return g = {
31339
+ next: verb(0),
31340
+ "throw": verb(1),
31341
+ "return": verb(2)
31342
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
31343
+ return this;
31344
+ }), g;
31345
+ function verb(n) {
31346
+ return function (v) {
31347
+ return step([n, v]);
31348
+ };
31349
+ }
31350
+ function step(op) {
31351
+ if (f) throw new TypeError("Generator is already executing.");
31352
+ while (_) try {
31353
+ 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;
31354
+ if (y = 0, t) op = [op[0] & 2, t.value];
31355
+ switch (op[0]) {
31356
+ case 0:
31357
+ case 1:
31358
+ t = op;
31359
+ break;
31360
+ case 4:
31361
+ _.label++;
31362
+ return {
31363
+ value: op[1],
31364
+ done: false
31365
+ };
31366
+ case 5:
31367
+ _.label++;
31368
+ y = op[1];
31369
+ op = [0];
31370
+ continue;
31371
+ case 7:
31372
+ op = _.ops.pop();
31373
+ _.trys.pop();
31374
+ continue;
31375
+ default:
31376
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
31377
+ _ = 0;
31378
+ continue;
31379
+ }
31380
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
31381
+ _.label = op[1];
31382
+ break;
31383
+ }
31384
+ if (op[0] === 6 && _.label < t[1]) {
31385
+ _.label = t[1];
31386
+ t = op;
31387
+ break;
31388
+ }
31389
+ if (t && _.label < t[2]) {
31390
+ _.label = t[2];
31391
+ _.ops.push(op);
31392
+ break;
31393
+ }
31394
+ if (t[2]) _.ops.pop();
31395
+ _.trys.pop();
31396
+ continue;
31397
+ }
31398
+ op = body.call(thisArg, _);
31399
+ } catch (e) {
31400
+ op = [6, e];
31401
+ y = 0;
31402
+ } finally {
31403
+ f = t = 0;
31404
+ }
31405
+ if (op[0] & 5) throw op[1];
31406
+ return {
31407
+ value: op[0] ? op[1] : void 0,
31408
+ done: true
31409
+ };
31410
+ }
31267
31411
  };
31412
+ exports.__esModule = true;
31413
+ exports.createAllJobs = void 0;
31414
+ var config_1 = __nccwpck_require__(8906);
31415
+ var createJobsForComponent_1 = __nccwpck_require__(5327);
31416
+ var createAllJobs = function (config, trigger) {
31417
+ return __awaiter(void 0, void 0, void 0, function () {
31418
+ var _a, _b;
31419
+ return __generator(this, function (_c) {
31420
+ switch (_c.label) {
31421
+ case 0:
31422
+ _b = (_a = Object).fromEntries;
31423
+ return [4 /*yield*/, Promise.all(Object.keys(config.components).map(function (componentName) {
31424
+ return __awaiter(void 0, void 0, void 0, function () {
31425
+ var envs, _a, _b, _c;
31426
+ return __generator(this, function (_d) {
31427
+ switch (_d.label) {
31428
+ case 0:
31429
+ envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
31430
+ _a = [componentName];
31431
+ _c = (_b = Object).fromEntries;
31432
+ return [4 /*yield*/, Promise.all(envs.map(function (env) {
31433
+ return __awaiter(void 0, void 0, void 0, function () {
31434
+ var _a;
31435
+ return __generator(this, function (_b) {
31436
+ switch (_b.label) {
31437
+ case 0:
31438
+ _a = [env];
31439
+ return [4 /*yield*/, (0, createJobsForComponent_1.createJobsForComponent)(config, componentName, env, trigger)];
31440
+ case 1:
31441
+ return [2 /*return*/, _a.concat([_b.sent()])];
31442
+ }
31443
+ });
31444
+ });
31445
+ }))];
31446
+ case 1:
31447
+ return [2 /*return*/, _a.concat([_c.apply(_b, [_d.sent()])])];
31448
+ }
31449
+ });
31450
+ });
31451
+ }))];
31452
+ case 1:
31453
+ return [2 /*return*/, _b.apply(_a, [_c.sent()])];
31454
+ }
31455
+ });
31456
+ });
31457
+ };
31458
+ exports.createAllJobs = createAllJobs;
31459
+
31460
+ /***/ }),
31461
+
31462
+ /***/ 4244:
31463
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
31464
+
31465
+ "use strict";
31466
+
31467
+
31268
31468
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
31269
31469
  function adopt(value) {
31270
31470
  return value instanceof P ? value : new P(function (resolve) {
@@ -31417,54 +31617,40 @@ var config_1 = __nccwpck_require__(8906);
31417
31617
  var rules_1 = __nccwpck_require__(1410);
31418
31618
  var runner_1 = __nccwpck_require__(7666);
31419
31619
  var jobs_1 = __nccwpck_require__(9072);
31420
- var createJobs_1 = __nccwpck_require__(1820);
31620
+ var createAllJobs_1 = __nccwpck_require__(6579);
31621
+ var createGitlabJobs_1 = __nccwpck_require__(5569);
31421
31622
  var createChildPipeline = function (type, trigger, config) {
31422
31623
  return __awaiter(void 0, void 0, void 0, function () {
31423
- var components, jobs, allEnvs, stages, pipeline;
31424
- return __generator(this, function (_a) {
31425
- switch (_a.label) {
31624
+ var jobs, allEnvs, stages, pipeline;
31625
+ var _a;
31626
+ return __generator(this, function (_b) {
31627
+ switch (_b.label) {
31426
31628
  case 0:
31427
- components = Object.keys(config.components);
31428
- return [4 /*yield*/, components.reduce(function (acc, componentName) {
31429
- return __awaiter(void 0, void 0, void 0, function () {
31430
- var envs, _a, _b;
31431
- return __generator(this, function (_c) {
31432
- switch (_c.label) {
31433
- case 0:
31434
- envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
31435
- _a = [{}];
31436
- return [4 /*yield*/, acc];
31437
- case 1:
31438
- _b = [__assign.apply(void 0, _a.concat([_c.sent()]))];
31439
- return [4 /*yield*/, (0, createJobs_1.createJobs)(type, envs, config, componentName, trigger)];
31440
- case 2:
31441
- return [2 /*return*/, __assign.apply(void 0, _b.concat([_c.sent()]))];
31442
- }
31443
- });
31444
- });
31445
- }, Promise.resolve({}))];
31629
+ return [4 /*yield*/, (0, createAllJobs_1.createAllJobs)(config, trigger)];
31446
31630
  case 1:
31447
- jobs = _a.sent();
31631
+ jobs = _b.sent();
31448
31632
  allEnvs = (0, config_1.getAllEnvsInAllComponents)(config);
31449
31633
  stages = jobs_1.BASE_STAGES.reduce(function (acc, baseStage) {
31450
31634
  return __spreadArray(__spreadArray(__spreadArray([], __read(acc), false), [baseStage], false), __read(allEnvs.map(function (e) {
31451
31635
  return "".concat(baseStage, " ").concat(e);
31452
31636
  })), false);
31453
31637
  }, []);
31454
- if (type === "gitlab") {
31455
- pipeline = {
31456
- image: (0, runner_1.getRunnerImage)("jobs-default"),
31457
- variables: {
31458
- FF_USE_FASTZIP: "true"
31459
- },
31460
- workflow: {
31461
- rules: rules_1.RULES_ALWAYS
31462
- },
31463
- stages: stages,
31464
- jobs: jobs
31465
- };
31466
- return [2 /*return*/, pipeline];
31467
- }
31638
+ if (!(type === "gitlab")) return [3 /*break*/, 3];
31639
+ _a = {
31640
+ image: (0, runner_1.getRunnerImage)("jobs-default"),
31641
+ variables: {
31642
+ FF_USE_FASTZIP: "true"
31643
+ },
31644
+ workflow: {
31645
+ rules: rules_1.RULES_ALWAYS
31646
+ },
31647
+ stages: stages
31648
+ };
31649
+ return [4 /*yield*/, (0, createGitlabJobs_1.createGitlabJobs)(jobs)];
31650
+ case 2:
31651
+ pipeline = (_a.jobs = _b.sent(), _a);
31652
+ return [2 /*return*/, pipeline];
31653
+ case 3:
31468
31654
  throw new Error("".concat(type, " is not supported"));
31469
31655
  }
31470
31656
  });
@@ -31474,7 +31660,7 @@ exports.createChildPipeline = createChildPipeline;
31474
31660
 
31475
31661
  /***/ }),
31476
31662
 
31477
- /***/ 1820:
31663
+ /***/ 5327:
31478
31664
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
31479
31665
 
31480
31666
  "use strict";
@@ -31645,14 +31831,12 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
31645
31831
  return to.concat(ar || Array.prototype.slice.call(from));
31646
31832
  };
31647
31833
  exports.__esModule = true;
31648
- exports.createJobs = void 0;
31834
+ exports.createJobsForComponent = void 0;
31649
31835
  var lodash_1 = __nccwpck_require__(3255);
31650
31836
  var build_1 = __nccwpck_require__(2004);
31651
31837
  var context_1 = __nccwpck_require__(7123);
31652
31838
  var deploy_1 = __nccwpck_require__(1264);
31653
- var utils_1 = __nccwpck_require__(1815);
31654
31839
  var getCommitInfo_1 = __nccwpck_require__(802);
31655
- var makeGitlabJob_1 = __nccwpck_require__(726);
31656
31840
  var packageManager_1 = __nccwpck_require__(3214);
31657
31841
  var injectDefaultVarsInCustomJobs = function (context, jobs) {
31658
31842
  return jobs.map(function (_a) {
@@ -31680,71 +31864,9 @@ var createRawJobs = function (context) {
31680
31864
  var customJobs = getCustomJobs(context);
31681
31865
  return __spreadArray(__spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false), __read(customJobs), false);
31682
31866
  };
31683
- var getFullJobName = function (name, componentName, env) {
31684
- if (env) {
31685
- return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
31686
- }
31687
- return "".concat(componentName, " ").concat(name);
31688
- };
31689
- var getFullReferencedJobName = function (referencedJobName, componentName, env, allRawJobs) {
31690
- var referencedJob = allRawJobs.find(function (j) {
31691
- return j.name === referencedJobName;
31692
- });
31693
- if (!referencedJob) {
31694
- throw new Error("unknown job referenced: " + referencedJobName);
31695
- }
31696
- var envToSet = referencedJob.envMode !== "none" ? env : null;
31697
- return getFullJobName(referencedJobName, componentName, envToSet);
31698
- };
31699
- // replaces references to other jobs with the full name
31700
- // the full name contains the componentname and the env name (if any)
31701
- var replaceReferences = function (job, componentName, env, allRawJobs) {
31702
- var _a, _b, _c;
31703
- var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
31704
- var cleanedNeeds = __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read((_b = job.needsOtherComponent) !== null && _b !== void 0 ? _b : []), false);
31705
- var needs = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
31706
- var _a;
31707
- return (0, lodash_1.isObject)(n) ? {
31708
- job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
31709
- artifacts: n.artifacts
31710
- } : getFullReferencedJobName(n, componentName, env, allRawJobs);
31711
- });
31712
- return __assign(__assign({}, job), {
31713
- stage: stage,
31714
- needs: needs,
31715
- environment: ((_c = job.environment) === null || _c === void 0 ? void 0 : _c.on_stop) ? __assign(__assign({}, job.environment), {
31716
- on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allRawJobs)
31717
- }) : job.environment
31718
- });
31719
- };
31720
- // this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
31721
- var addStageNeeds = function (jobs) {
31722
- // when a job defines needsStages, we add these as needs
31723
- return jobs.map(function (job) {
31724
- var _a;
31725
- if (!job.needsStages || job.needsStages.length === 0) {
31726
- return job;
31727
- }
31728
- var neededJobs = jobs.map(function (j) {
31729
- var _a, _b;
31730
- var neededStage = (_a = job.needsStages) === null || _a === void 0 ? void 0 : _a.find(function (s) {
31731
- return j.stage === s.stage;
31732
- });
31733
- if (neededStage) {
31734
- return {
31735
- job: j.name,
31736
- artifacts: (_b = neededStage.artifacts) !== null && _b !== void 0 ? _b : false
31737
- };
31738
- }
31739
- }).filter(utils_1.notNil);
31740
- return __assign(__assign({}, job), {
31741
- needs: __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
31742
- });
31743
- });
31744
- };
31745
- var createJobs = function (type, envs, config, componentName, trigger) {
31867
+ var createJobsForComponent = function (config, componentName, env, trigger) {
31746
31868
  return __awaiter(void 0, void 0, void 0, function () {
31747
- var commitInfo, _a, packageManagerInfo;
31869
+ var commitInfo, _a, packageManagerInfo, context;
31748
31870
  return __generator(this, function (_b) {
31749
31871
  switch (_b.label) {
31750
31872
  case 0:
@@ -31757,47 +31879,19 @@ var createJobs = function (type, envs, config, componentName, trigger) {
31757
31879
  return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfo)(config, componentName)];
31758
31880
  case 2:
31759
31881
  packageManagerInfo = _b.sent();
31760
- return [2 /*return*/, envs.reduce(function (acc, env) {
31761
- return __awaiter(void 0, void 0, void 0, function () {
31762
- var context, jobs, result, _a, _b, _c, _d, _e;
31763
- return __generator(this, function (_f) {
31764
- switch (_f.label) {
31765
- case 0:
31766
- return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
31767
- case 1:
31768
- context = _f.sent();
31769
- jobs = addStageNeeds(createRawJobs(context));
31770
- _a = [{}];
31771
- return [4 /*yield*/, acc];
31772
- case 2:
31773
- _b = [__assign.apply(void 0, _a.concat([_f.sent()]))];
31774
- _d = (_c = jobs).reduce;
31775
- _e = [function (acc, job) {
31776
- var _a;
31777
- var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
31778
- var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
31779
- if (type === "gitlab") {
31780
- return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
31781
- }
31782
- throw new Error("not supported");
31783
- }];
31784
- return [4 /*yield*/, Promise.resolve({})];
31785
- case 3:
31786
- result = __assign.apply(void 0, _b.concat([_d.apply(_c, _e.concat([_f.sent()]))]));
31787
- return [2 /*return*/, result];
31788
- }
31789
- });
31790
- });
31791
- }, {})];
31882
+ return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
31883
+ case 3:
31884
+ context = _b.sent();
31885
+ return [2 /*return*/, createRawJobs(context)];
31792
31886
  }
31793
31887
  });
31794
31888
  });
31795
31889
  };
31796
- exports.createJobs = createJobs;
31890
+ exports.createJobsForComponent = createJobsForComponent;
31797
31891
 
31798
31892
  /***/ }),
31799
31893
 
31800
- /***/ 726:
31894
+ /***/ 5569:
31801
31895
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
31802
31896
 
31803
31897
  "use strict";
@@ -31813,6 +31907,121 @@ var __assign = this && this.__assign || function () {
31813
31907
  };
31814
31908
  return __assign.apply(this, arguments);
31815
31909
  };
31910
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
31911
+ function adopt(value) {
31912
+ return value instanceof P ? value : new P(function (resolve) {
31913
+ resolve(value);
31914
+ });
31915
+ }
31916
+ return new (P || (P = Promise))(function (resolve, reject) {
31917
+ function fulfilled(value) {
31918
+ try {
31919
+ step(generator.next(value));
31920
+ } catch (e) {
31921
+ reject(e);
31922
+ }
31923
+ }
31924
+ function rejected(value) {
31925
+ try {
31926
+ step(generator["throw"](value));
31927
+ } catch (e) {
31928
+ reject(e);
31929
+ }
31930
+ }
31931
+ function step(result) {
31932
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
31933
+ }
31934
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31935
+ });
31936
+ };
31937
+ var __generator = this && this.__generator || function (thisArg, body) {
31938
+ var _ = {
31939
+ label: 0,
31940
+ sent: function () {
31941
+ if (t[0] & 1) throw t[1];
31942
+ return t[1];
31943
+ },
31944
+ trys: [],
31945
+ ops: []
31946
+ },
31947
+ f,
31948
+ y,
31949
+ t,
31950
+ g;
31951
+ return g = {
31952
+ next: verb(0),
31953
+ "throw": verb(1),
31954
+ "return": verb(2)
31955
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
31956
+ return this;
31957
+ }), g;
31958
+ function verb(n) {
31959
+ return function (v) {
31960
+ return step([n, v]);
31961
+ };
31962
+ }
31963
+ function step(op) {
31964
+ if (f) throw new TypeError("Generator is already executing.");
31965
+ while (_) try {
31966
+ 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;
31967
+ if (y = 0, t) op = [op[0] & 2, t.value];
31968
+ switch (op[0]) {
31969
+ case 0:
31970
+ case 1:
31971
+ t = op;
31972
+ break;
31973
+ case 4:
31974
+ _.label++;
31975
+ return {
31976
+ value: op[1],
31977
+ done: false
31978
+ };
31979
+ case 5:
31980
+ _.label++;
31981
+ y = op[1];
31982
+ op = [0];
31983
+ continue;
31984
+ case 7:
31985
+ op = _.ops.pop();
31986
+ _.trys.pop();
31987
+ continue;
31988
+ default:
31989
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
31990
+ _ = 0;
31991
+ continue;
31992
+ }
31993
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
31994
+ _.label = op[1];
31995
+ break;
31996
+ }
31997
+ if (op[0] === 6 && _.label < t[1]) {
31998
+ _.label = t[1];
31999
+ t = op;
32000
+ break;
32001
+ }
32002
+ if (t && _.label < t[2]) {
32003
+ _.label = t[2];
32004
+ _.ops.push(op);
32005
+ break;
32006
+ }
32007
+ if (t[2]) _.ops.pop();
32008
+ _.trys.pop();
32009
+ continue;
32010
+ }
32011
+ op = body.call(thisArg, _);
32012
+ } catch (e) {
32013
+ op = [6, e];
32014
+ y = 0;
32015
+ } finally {
32016
+ f = t = 0;
32017
+ }
32018
+ if (op[0] & 5) throw op[1];
32019
+ return {
32020
+ value: op[0] ? op[1] : void 0,
32021
+ done: true
32022
+ };
32023
+ }
32024
+ };
31816
32025
  var __rest = this && this.__rest || function (s, e) {
31817
32026
  var t = {};
31818
32027
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -31853,29 +32062,99 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
31853
32062
  return to.concat(ar || Array.prototype.slice.call(from));
31854
32063
  };
31855
32064
  exports.__esModule = true;
31856
- exports.makeGitlabJob = void 0;
32065
+ exports.createGitlabJobs = exports.makeGitlabJob = void 0;
31857
32066
  var lodash_1 = __nccwpck_require__(3255);
31858
32067
  var defaults_1 = __nccwpck_require__(7328);
32068
+ var getFullJobName = function (name, componentName, env) {
32069
+ if (env) {
32070
+ return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
32071
+ }
32072
+ return "".concat(componentName, " ").concat(name);
32073
+ };
32074
+ var getFullReferencedJobName = function (referencedJobName, componentName, env, allJobs) {
32075
+ var _a, _b;
32076
+ var referencedJob = (_b = (_a = allJobs[componentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.find(function (j) {
32077
+ return j.name === referencedJobName;
32078
+ });
32079
+ if (!referencedJob) {
32080
+ throw new Error("unknown job referenced: '".concat(referencedJobName, "' from '").concat(env, ":").concat(componentName, "'"));
32081
+ }
32082
+ var envToSet = referencedJob.envMode !== "none" ? env : null;
32083
+ return getFullJobName(referencedJobName, componentName, envToSet);
32084
+ };
31859
32085
  var getJobName = function (need) {
31860
32086
  return (0, lodash_1.isObject)(need) ? need.job : need;
31861
32087
  };
31862
- var makeGitlabJob = function (_a) {
32088
+ var makeGitlabJob = function (componentName, env, _a, allJobs) {
32089
+ var _b;
31863
32090
  var envMode = _a.envMode,
31864
32091
  needsStages = _a.needsStages,
31865
32092
  needsOtherComponent = _a.needsOtherComponent,
31866
32093
  name = _a.name,
31867
32094
  needs = _a.needs,
31868
- rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
31869
- return __assign(__assign({}, rest), {
32095
+ job = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
32096
+ var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
32097
+ var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
32098
+ var _a, _b, _c, _d;
32099
+ var referencedComponentName = componentName;
32100
+ var allJobNamesFromThatStage = (_d = (_c = (_b = (_a = allJobs[referencedComponentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.filter(function (j) {
32101
+ return j.stage === n.stage;
32102
+ })) === null || _c === void 0 ? void 0 : _c.map(function (j) {
32103
+ return j.name;
32104
+ })) !== null && _d !== void 0 ? _d : [];
32105
+ return allJobNamesFromThatStage.map(function (job) {
32106
+ var _a;
32107
+ return {
32108
+ job: job,
32109
+ artifacts: (_a = n.artifacts) !== null && _a !== void 0 ? _a : false,
32110
+ componentName: referencedComponentName
32111
+ };
32112
+ });
32113
+ });
32114
+ var cleanedNeeds = __spreadArray(__spreadArray(__spreadArray([], __read(needs !== null && needs !== void 0 ? needs : []), false), __read(needsOtherComponent !== null && needsOtherComponent !== void 0 ? needsOtherComponent : []), false), __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false);
32115
+ var gitlabNeeds = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
32116
+ var _a;
32117
+ return (0, lodash_1.isObject)(n) ? {
32118
+ job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allJobs),
32119
+ artifacts: n.artifacts
32120
+ } : getFullReferencedJobName(n, componentName, env, allJobs);
32121
+ }).sort(function (a, b) {
32122
+ return getJobName(a).localeCompare(getJobName(b));
32123
+ });
32124
+ var fullJobName = getFullJobName(name, componentName, envMode !== "none" ? env : undefined);
32125
+ var gitlabJob = __assign(__assign({}, job), {
32126
+ stage: stage,
32127
+ environment: ((_b = job.environment) === null || _b === void 0 ? void 0 : _b.on_stop) ? __assign(__assign({}, job.environment), {
32128
+ on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allJobs)
32129
+ }) : job.environment,
31870
32130
  // sort in a predictable manner for snapshot tests
31871
- needs: needs ? __spreadArray([], __read(needs), false).sort(function (a, b) {
31872
- return getJobName(a).localeCompare(getJobName(b));
31873
- }) : undefined,
32131
+ needs: gitlabNeeds,
31874
32132
  retry: defaults_1.BASE_RETRY,
31875
32133
  interruptible: true
31876
32134
  });
32135
+ return [fullJobName, gitlabJob];
31877
32136
  };
31878
32137
  exports.makeGitlabJob = makeGitlabJob;
32138
+ var createGitlabJobs = function (allJobs) {
32139
+ return __awaiter(void 0, void 0, void 0, function () {
32140
+ return __generator(this, function (_a) {
32141
+ return [2 /*return*/, Object.keys(allJobs).reduce(function (accForComponents, componentName) {
32142
+ var componentJobs = allJobs[componentName];
32143
+ return __assign(__assign({}, accForComponents), Object.keys(componentJobs).reduce(function (accForEnvs, env) {
32144
+ var jobs = componentJobs[env];
32145
+ return __assign(__assign({}, accForEnvs), jobs.reduce(function (accForJobs, job) {
32146
+ var _a;
32147
+ var _b = __read((0, exports.makeGitlabJob)(componentName, env, job, allJobs), 2),
32148
+ fullJobName = _b[0],
32149
+ gitlabJob = _b[1];
32150
+ return __assign(__assign({}, accForJobs), (_a = {}, _a[fullJobName] = gitlabJob, _a));
32151
+ }, {}));
32152
+ }, {}));
32153
+ }, {})];
32154
+ });
32155
+ });
32156
+ };
32157
+ exports.createGitlabJobs = createGitlabJobs;
31879
32158
 
31880
32159
  /***/ }),
31881
32160
 
@@ -31902,7 +32181,7 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
31902
32181
  };
31903
32182
  exports.__esModule = true;
31904
32183
  __exportStar(__nccwpck_require__(4244), exports);
31905
- __exportStar(__nccwpck_require__(1820), exports);
32184
+ __exportStar(__nccwpck_require__(5327), exports);
31906
32185
 
31907
32186
  /***/ }),
31908
32187