@catladder/pipeline 0.0.0-refactor-needs-c896b98e → 0.0.0-refactor-args-30342529

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 (33) hide show
  1. package/dist/build/node/cache.js +10 -2
  2. package/dist/build/rails/test.js +2 -1
  3. package/dist/bundles/catladder-gitlab/index.js +76 -48
  4. package/dist/constants.js +1 -1
  5. package/dist/deploy/base.js +1 -1
  6. package/dist/deploy/cloudRun/deployJob.js +2 -2
  7. package/dist/deploy/cloudRun/index.js +2 -2
  8. package/dist/deploy/kubernetes/kubeValues.d.ts +13 -10
  9. package/dist/deploy/kubernetes/kubeValues.js +47 -2
  10. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +2 -2
  11. package/dist/deploy/types/googleCloudRun.d.ts +4 -0
  12. package/dist/deploy/types/kubernetes.d.ts +3 -2
  13. package/dist/pipeline/createJobs.js +9 -4
  14. package/dist/pipeline/gitlab/makeGitlabJob.js +2 -33
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/dist/types/jobs.d.ts +6 -7
  17. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +48 -48
  18. package/examples/__snapshots__/custom-build-job.ts.snap +8 -8
  19. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +4077 -0
  20. package/examples/cloud-run-with-sql.ts +7 -0
  21. package/examples/kubernetes-with-jobs.ts +68 -0
  22. package/package.json +1 -1
  23. package/src/build/node/cache.ts +5 -2
  24. package/src/build/rails/test.ts +1 -1
  25. package/src/deploy/base.ts +1 -1
  26. package/src/deploy/cloudRun/deployJob.ts +2 -2
  27. package/src/deploy/cloudRun/index.ts +2 -1
  28. package/src/deploy/kubernetes/kubeValues.ts +14 -2
  29. package/src/deploy/types/googleCloudRun.ts +5 -0
  30. package/src/deploy/types/kubernetes.ts +20 -17
  31. package/src/pipeline/createJobs.ts +17 -14
  32. package/src/pipeline/gitlab/makeGitlabJob.ts +1 -3
  33. package/src/types/jobs.ts +8 -9
@@ -31,9 +31,15 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
31
31
  }
32
32
  return to.concat(ar || Array.prototype.slice.call(from));
33
33
  };
34
+ var __importDefault = this && this.__importDefault || function (mod) {
35
+ return mod && mod.__esModule ? mod : {
36
+ "default": mod
37
+ };
38
+ };
34
39
  exports.__esModule = true;
35
40
  exports.getNextCache = exports.getNodeCache = exports.getNodeModulesCache = exports.getYarnCache = void 0;
36
41
  var path_1 = require("path");
42
+ var slugify_1 = __importDefault(require("slugify"));
37
43
  var getYarnCache = function (context, policy) {
38
44
  var _a;
39
45
  if (policy === void 0) {
@@ -45,7 +51,7 @@ var getYarnCache = function (context, policy) {
45
51
  policy: policy,
46
52
  paths: [".yarn"]
47
53
  } : {
48
- key: context.componentConfig.dir + "-yarn",
54
+ key: (0, slugify_1["default"])(context.componentConfig.dir) + "-yarn",
49
55
  policy: policy,
50
56
  paths: [(0, path_1.join)(context.componentConfig.dir, ".yarn")]
51
57
  }];
@@ -57,9 +63,11 @@ var getNodeModulesCache = function (context, policy) {
57
63
  policy = "pull-push";
58
64
  }
59
65
  var componentIsInWorkspace = (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace;
66
+ // We intentionally do not use the contents of yarn.lock as a cache key, as yarn install should always guarantee that the files are updated, but it can still use part of the cache if not all packages are up-to-date.
67
+ // It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
60
68
  return [{
61
69
  // if component is in a shared workspace, use workspace cache. use individual cache else
62
- key: componentIsInWorkspace ? "node-modules-workspace" : context.componentConfig.dir + "-node-modules",
70
+ key: componentIsInWorkspace ? "node-modules-workspace" : (0, slugify_1["default"])(context.componentConfig.dir) + "-node-modules",
63
71
  policy: policy,
64
72
  paths: __spreadArray([], __read(componentIsInWorkspace ? __spreadArray(["node_modules"], __read((_c = (_b = context.packageManagerInfo) === null || _b === void 0 ? void 0 : _b.workspaces.map(function (w) {
65
73
  return (0, path_1.join)(w.location, "node_modules");
@@ -63,8 +63,9 @@ var createRailsTestJobs = function (context) {
63
63
  var bundlerCache = {
64
64
  key: {
65
65
  files: ["Gemfile.lock"],
66
- prefix: "$CI_JOB_IMAGE"
66
+ prefix: "$CI_JOB_IMAGE" // a changed image might have different OS libraries which no longer work with the cached gems
67
67
  },
68
+
68
69
  paths: [bundlerCacheDir]
69
70
  };
70
71
  var auditJob = buildConfig.audit !== false ? __assign(__assign({
@@ -27494,9 +27494,15 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
27494
27494
  }
27495
27495
  return to.concat(ar || Array.prototype.slice.call(from));
27496
27496
  };
27497
+ var __importDefault = this && this.__importDefault || function (mod) {
27498
+ return mod && mod.__esModule ? mod : {
27499
+ "default": mod
27500
+ };
27501
+ };
27497
27502
  exports.__esModule = true;
27498
27503
  exports.getNextCache = exports.getNodeCache = exports.getNodeModulesCache = exports.getYarnCache = void 0;
27499
27504
  var path_1 = __nccwpck_require__(1017);
27505
+ var slugify_1 = __importDefault(__nccwpck_require__(4035));
27500
27506
  var getYarnCache = function (context, policy) {
27501
27507
  var _a;
27502
27508
  if (policy === void 0) {
@@ -27508,7 +27514,7 @@ var getYarnCache = function (context, policy) {
27508
27514
  policy: policy,
27509
27515
  paths: [".yarn"]
27510
27516
  } : {
27511
- key: context.componentConfig.dir + "-yarn",
27517
+ key: (0, slugify_1["default"])(context.componentConfig.dir) + "-yarn",
27512
27518
  policy: policy,
27513
27519
  paths: [(0, path_1.join)(context.componentConfig.dir, ".yarn")]
27514
27520
  }];
@@ -27520,9 +27526,11 @@ var getNodeModulesCache = function (context, policy) {
27520
27526
  policy = "pull-push";
27521
27527
  }
27522
27528
  var componentIsInWorkspace = (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace;
27529
+ // We intentionally do not use the contents of yarn.lock as a cache key, as yarn install should always guarantee that the files are updated, but it can still use part of the cache if not all packages are up-to-date.
27530
+ // It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
27523
27531
  return [{
27524
27532
  // if component is in a shared workspace, use workspace cache. use individual cache else
27525
- key: componentIsInWorkspace ? "node-modules-workspace" : context.componentConfig.dir + "-node-modules",
27533
+ key: componentIsInWorkspace ? "node-modules-workspace" : (0, slugify_1["default"])(context.componentConfig.dir) + "-node-modules",
27526
27534
  policy: policy,
27527
27535
  paths: __spreadArray([], __read(componentIsInWorkspace ? __spreadArray(["node_modules"], __read((_c = (_b = context.packageManagerInfo) === null || _b === void 0 ? void 0 : _b.workspaces.map(function (w) {
27528
27536
  return (0, path_1.join)(w.location, "node_modules");
@@ -28022,8 +28030,9 @@ var createRailsTestJobs = function (context) {
28022
28030
  var bundlerCache = {
28023
28031
  key: {
28024
28032
  files: ["Gemfile.lock"],
28025
- prefix: "$CI_JOB_IMAGE"
28033
+ prefix: "$CI_JOB_IMAGE" // a changed image might have different OS libraries which no longer work with the cached gems
28026
28034
  },
28035
+
28027
28036
  paths: [bundlerCacheDir]
28028
28037
  };
28029
28038
  var auditJob = buildConfig.audit !== false ? __assign(__assign({
@@ -28309,7 +28318,7 @@ exports.readConfigSync = readConfigSync;
28309
28318
 
28310
28319
  exports.__esModule = true;
28311
28320
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
28312
- exports.PIPELINE_IMAGE_TAG = "refactor-needs-c896b98e" || 0;
28321
+ exports.PIPELINE_IMAGE_TAG = "refactor-args-30342529" || 0;
28313
28322
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
28314
28323
 
28315
28324
  /***/ }),
@@ -29366,7 +29375,7 @@ var getBaseDeploymentJob = function (context) {
29366
29375
  return {
29367
29376
  name: exports.DEPLOY_JOB_NAME,
29368
29377
  envMode: "stagePerEnv",
29369
- needs: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
29378
+ needsOtherComponent: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
29370
29379
  return {
29371
29380
  componentName: c,
29372
29381
  job: exports.DEPLOY_JOB_NAME,
@@ -29517,9 +29526,9 @@ var createGoogleCloudRunDeployJobs = function (context) {
29517
29526
  value = _b[1];
29518
29527
  return "".concat(key, "=").concat(value);
29519
29528
  }).join(",");
29520
- var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
29529
+ var commonArgs = "--project=".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
29521
29530
  var cloudRunArgs = deployConfig.cloudSql ? "--set-cloudsql-instances=".concat(deployConfig.cloudSql.instanceConnectionName) : "";
29522
- var commonDeployArgs = "--image ".concat(gcloudImageName, " ").concat(commonArgs, " ").concat(cloudRunArgs, " --labels ").concat(labelsString);
29531
+ var commonDeployArgs = "--image=".concat(gcloudImageName, " ").concat(commonArgs, " ").concat(cloudRunArgs, " --labels=").concat(labelsString);
29523
29532
  var serviceName = context.environment.fullName.toLowerCase();
29524
29533
  var getFullJobName = function (name) {
29525
29534
  return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
@@ -29712,7 +29721,7 @@ var jobName_1 = __nccwpck_require__(9357);
29712
29721
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
29713
29722
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
29714
29723
  var getCloudSqlVariables = function (_a) {
29715
- var _b, _c;
29724
+ var _b, _c, _d;
29716
29725
  var deployConfigRaw = _a.deployConfigRaw,
29717
29726
  environmentSlug = _a.environmentSlug,
29718
29727
  env = _a.env,
@@ -29729,7 +29738,7 @@ var getCloudSqlVariables = function (_a) {
29729
29738
  return {
29730
29739
  CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
29731
29740
  DB_NAME: DB_NAME,
29732
- DB_USER: "postgres",
29741
+ DB_USER: (_d = deployConfigRaw.cloudSql.dbUser) !== null && _d !== void 0 ? _d : "postgres",
29733
29742
  DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
29734
29743
  DATABASE_URL: "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME".concat(additionalQueryParamsString),
29735
29744
  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)
@@ -30395,6 +30404,16 @@ exports.createKubeEnv = createKubeEnv;
30395
30404
  "use strict";
30396
30405
 
30397
30406
 
30407
+ var __assign = this && this.__assign || function () {
30408
+ __assign = Object.assign || function (t) {
30409
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
30410
+ s = arguments[i];
30411
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
30412
+ }
30413
+ return t;
30414
+ };
30415
+ return __assign.apply(this, arguments);
30416
+ };
30398
30417
  var __rest = this && this.__rest || function (s, e) {
30399
30418
  var t = {};
30400
30419
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -30403,6 +30422,28 @@ var __rest = this && this.__rest || function (s, e) {
30403
30422
  }
30404
30423
  return t;
30405
30424
  };
30425
+ var __read = this && this.__read || function (o, n) {
30426
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
30427
+ if (!m) return o;
30428
+ var i = m.call(o),
30429
+ r,
30430
+ ar = [],
30431
+ e;
30432
+ try {
30433
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30434
+ } catch (error) {
30435
+ e = {
30436
+ error: error
30437
+ };
30438
+ } finally {
30439
+ try {
30440
+ if (r && !r.done && (m = i["return"])) m.call(i);
30441
+ } finally {
30442
+ if (e) throw e.error;
30443
+ }
30444
+ }
30445
+ return ar;
30446
+ };
30406
30447
  exports.__esModule = true;
30407
30448
  exports.createKubeValues = void 0;
30408
30449
  var lodash_1 = __nccwpck_require__(3255);
@@ -30443,6 +30484,14 @@ var createAppConfig = function (context, application) {
30443
30484
  );
30444
30485
  };
30445
30486
 
30487
+ var removeFalsy = function (record) {
30488
+ if (!record) return undefined;
30489
+ return Object.fromEntries(Object.entries(record).filter(function (_a) {
30490
+ var _b = __read(_a, 2),
30491
+ value = _b[1];
30492
+ return value !== false;
30493
+ }));
30494
+ };
30446
30495
  var createKubeValues = function (context) {
30447
30496
  var _a, _b;
30448
30497
  var deployConfig = context.componentConfig.deploy;
@@ -30459,13 +30508,18 @@ var createKubeValues = function (context) {
30459
30508
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
30460
30509
  var _c = values !== null && values !== void 0 ? values : {},
30461
30510
  application = _c.application,
30462
- rest = __rest(_c, ["application"]);
30511
+ jobs = _c.jobs,
30512
+ cronjobs = _c.cronjobs,
30513
+ rest = __rest(_c, ["application", "jobs", "cronjobs"]);
30463
30514
  var env = (0, kubeEnv_1.createKubeEnv)(context);
30464
30515
  var defaultKubeValues = (0, lodash_1.merge)({
30465
30516
  env: env,
30466
30517
  application: createAppConfig(context, application)
30467
30518
  }, (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) : {});
30468
- var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, rest));
30519
+ var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
30520
+ jobs: removeFalsy(jobs),
30521
+ cronjobs: removeFalsy(cronjobs)
30522
+ }, rest)));
30469
30523
  return kubeValues;
30470
30524
  };
30471
30525
  exports.createKubeValues = createKubeValues;
@@ -31514,14 +31568,19 @@ var getFullReferencedJobName = function (referencedJobName, componentName, env,
31514
31568
  var replaceReferences = function (job, componentName, env, allRawJobs) {
31515
31569
  var _a, _b, _c;
31516
31570
  var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
31517
- var cleanedNeeds = __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read((_b = job.needsOtherComponent) !== null && _b !== void 0 ? _b : []), false);
31518
- var needs = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
31519
- var _a;
31571
+ var needsFromNeeds = (_a = job.needs) === null || _a === void 0 ? void 0 : _a.map(function (n) {
31520
31572
  return (0, lodash_1.isObject)(n) ? {
31521
- job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
31573
+ job: getFullReferencedJobName(n.job, componentName, env, allRawJobs),
31522
31574
  artifacts: n.artifacts
31523
31575
  } : getFullReferencedJobName(n, componentName, env, allRawJobs);
31524
31576
  });
31577
+ var needsFromOtherComponents = (_b = job.needsOtherComponent) === null || _b === void 0 ? void 0 : _b.map(function (other) {
31578
+ return {
31579
+ artifacts: other.artifacts,
31580
+ job: getFullReferencedJobName(other.job, other.componentName, env, allRawJobs)
31581
+ };
31582
+ });
31583
+ var needs = __spreadArray(__spreadArray([], __read(needsFromNeeds !== null && needsFromNeeds !== void 0 ? needsFromNeeds : []), false), __read(needsFromOtherComponents !== null && needsFromOtherComponents !== void 0 ? needsFromOtherComponents : []), false);
31525
31584
  return __assign(__assign({}, job), {
31526
31585
  stage: stage,
31527
31586
  needs: needs,
@@ -31634,37 +31693,6 @@ var __rest = this && this.__rest || function (s, e) {
31634
31693
  }
31635
31694
  return t;
31636
31695
  };
31637
- var __read = this && this.__read || function (o, n) {
31638
- var m = typeof Symbol === "function" && o[Symbol.iterator];
31639
- if (!m) return o;
31640
- var i = m.call(o),
31641
- r,
31642
- ar = [],
31643
- e;
31644
- try {
31645
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31646
- } catch (error) {
31647
- e = {
31648
- error: error
31649
- };
31650
- } finally {
31651
- try {
31652
- if (r && !r.done && (m = i["return"])) m.call(i);
31653
- } finally {
31654
- if (e) throw e.error;
31655
- }
31656
- }
31657
- return ar;
31658
- };
31659
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
31660
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31661
- if (ar || !(i in from)) {
31662
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
31663
- ar[i] = from[i];
31664
- }
31665
- }
31666
- return to.concat(ar || Array.prototype.slice.call(from));
31667
- };
31668
31696
  exports.__esModule = true;
31669
31697
  exports.makeGitlabJob = void 0;
31670
31698
  var lodash_1 = __nccwpck_require__(3255);
@@ -31681,9 +31709,9 @@ var makeGitlabJob = function (_a) {
31681
31709
  rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
31682
31710
  return __assign(__assign({}, rest), {
31683
31711
  // sort in a predictable manner for snapshot tests
31684
- needs: needs ? __spreadArray([], __read(needs), false).sort(function (a, b) {
31712
+ needs: needs === null || needs === void 0 ? void 0 : needs.sort(function (a, b) {
31685
31713
  return getJobName(a).localeCompare(getJobName(b));
31686
- }) : undefined,
31714
+ }),
31687
31715
  retry: defaults_1.BASE_RETRY,
31688
31716
  interruptible: true
31689
31717
  });
package/dist/constants.js CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
5
- exports.PIPELINE_IMAGE_TAG = "refactor-needs-c896b98e" || "";
5
+ exports.PIPELINE_IMAGE_TAG = "refactor-args-30342529" || "";
6
6
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
@@ -38,7 +38,7 @@ var getBaseDeploymentJob = function (context) {
38
38
  return {
39
39
  name: exports.DEPLOY_JOB_NAME,
40
40
  envMode: "stagePerEnv",
41
- needs: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
41
+ needsOtherComponent: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
42
42
  return {
43
43
  componentName: c,
44
44
  job: exports.DEPLOY_JOB_NAME,
@@ -70,9 +70,9 @@ var createGoogleCloudRunDeployJobs = function (context) {
70
70
  value = _b[1];
71
71
  return "".concat(key, "=").concat(value);
72
72
  }).join(",");
73
- var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
73
+ var commonArgs = "--project=".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
74
74
  var cloudRunArgs = deployConfig.cloudSql ? "--set-cloudsql-instances=".concat(deployConfig.cloudSql.instanceConnectionName) : "";
75
- var commonDeployArgs = "--image ".concat(gcloudImageName, " ").concat(commonArgs, " ").concat(cloudRunArgs, " --labels ").concat(labelsString);
75
+ var commonDeployArgs = "--image=".concat(gcloudImageName, " ").concat(commonArgs, " ").concat(cloudRunArgs, " --labels=").concat(labelsString);
76
76
  var serviceName = context.environment.fullName.toLowerCase();
77
77
  var getFullJobName = function (name) {
78
78
  return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
@@ -50,7 +50,7 @@ var jobName_1 = require("./utils/jobName");
50
50
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
51
51
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
52
52
  var getCloudSqlVariables = function (_a) {
53
- var _b, _c;
53
+ var _b, _c, _d;
54
54
  var deployConfigRaw = _a.deployConfigRaw,
55
55
  environmentSlug = _a.environmentSlug,
56
56
  env = _a.env,
@@ -67,7 +67,7 @@ var getCloudSqlVariables = function (_a) {
67
67
  return {
68
68
  CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
69
69
  DB_NAME: DB_NAME,
70
- DB_USER: "postgres",
70
+ DB_USER: (_d = deployConfigRaw.cloudSql.dbUser) !== null && _d !== void 0 ? _d : "postgres",
71
71
  DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
72
72
  DATABASE_URL: "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME".concat(additionalQueryParamsString),
73
73
  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)
@@ -60,7 +60,6 @@ export declare const createKubeValues: (context: Context) => never[] | ({
60
60
  worker?: import("../types").KubernetesWorkerDef | undefined;
61
61
  }> | undefined;
62
62
  } & {
63
- [x: string]: unknown;
64
63
  cloudsql?: {
65
64
  enabled: boolean;
66
65
  instanceId?: string | undefined;
@@ -71,15 +70,6 @@ export declare const createKubeValues: (context: Context) => never[] | ({
71
70
  mailhog?: {
72
71
  enabled: boolean;
73
72
  } | undefined;
74
- jobs?: Record<string, import("../types/base").AllowUnknownProps<{
75
- command: string;
76
- hook?: string | undefined;
77
- }>> | undefined;
78
- cronjobs?: Record<string, import("../types/base").AllowUnknownProps<{
79
- schedule: string;
80
- command: string;
81
- concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
82
- }>> | undefined;
83
73
  secretsFromOtherComponent?: {
84
74
  [envVar: string]: string;
85
75
  } | undefined;
@@ -87,4 +77,17 @@ export declare const createKubeValues: (context: Context) => never[] | ({
87
77
  [envVar: string]: string;
88
78
  } | undefined;
89
79
  secretsAsFile?: string[] | undefined;
80
+ jobs: {
81
+ [k: string]: false | import("../types/base").AllowUnknownProps<{
82
+ command: string;
83
+ hook?: string | undefined;
84
+ }>;
85
+ } | undefined;
86
+ cronjobs: {
87
+ [k: string]: false | import("../types/base").AllowUnknownProps<{
88
+ schedule: string;
89
+ command: string;
90
+ concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
91
+ }>;
92
+ } | undefined;
90
93
  });
@@ -1,5 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
3
13
  var __rest = this && this.__rest || function (s, e) {
4
14
  var t = {};
5
15
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -8,6 +18,28 @@ var __rest = this && this.__rest || function (s, e) {
8
18
  }
9
19
  return t;
10
20
  };
21
+ var __read = this && this.__read || function (o, n) {
22
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
23
+ if (!m) return o;
24
+ var i = m.call(o),
25
+ r,
26
+ ar = [],
27
+ e;
28
+ try {
29
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
+ } catch (error) {
31
+ e = {
32
+ error: error
33
+ };
34
+ } finally {
35
+ try {
36
+ if (r && !r.done && (m = i["return"])) m.call(i);
37
+ } finally {
38
+ if (e) throw e.error;
39
+ }
40
+ }
41
+ return ar;
42
+ };
11
43
  exports.__esModule = true;
12
44
  exports.createKubeValues = void 0;
13
45
  var lodash_1 = require("lodash");
@@ -48,6 +80,14 @@ var createAppConfig = function (context, application) {
48
80
  );
49
81
  };
50
82
 
83
+ var removeFalsy = function (record) {
84
+ if (!record) return undefined;
85
+ return Object.fromEntries(Object.entries(record).filter(function (_a) {
86
+ var _b = __read(_a, 2),
87
+ value = _b[1];
88
+ return value !== false;
89
+ }));
90
+ };
51
91
  var createKubeValues = function (context) {
52
92
  var _a, _b;
53
93
  var deployConfig = context.componentConfig.deploy;
@@ -64,13 +104,18 @@ var createKubeValues = function (context) {
64
104
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
65
105
  var _c = values !== null && values !== void 0 ? values : {},
66
106
  application = _c.application,
67
- rest = __rest(_c, ["application"]);
107
+ jobs = _c.jobs,
108
+ cronjobs = _c.cronjobs,
109
+ rest = __rest(_c, ["application", "jobs", "cronjobs"]);
68
110
  var env = (0, kubeEnv_1.createKubeEnv)(context);
69
111
  var defaultKubeValues = (0, lodash_1.merge)({
70
112
  env: env,
71
113
  application: createAppConfig(context, application)
72
114
  }, (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) : {});
73
- var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, rest));
115
+ var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
116
+ jobs: removeFalsy(jobs),
117
+ cronjobs: removeFalsy(cronjobs)
118
+ }, rest)));
74
119
  return kubeValues;
75
120
  };
76
121
  exports.createKubeValues = createKubeValues;
@@ -13,11 +13,11 @@ export declare const processSecretsAsFiles: <T extends {
13
13
  mailhog?: {
14
14
  enabled: boolean;
15
15
  } | undefined;
16
- jobs?: Record<string, import("../types/base").AllowUnknownProps<{
16
+ jobs?: Record<string, false | import("../types/base").AllowUnknownProps<{
17
17
  command: string;
18
18
  hook?: string | undefined;
19
19
  }>> | undefined;
20
- cronjobs?: Record<string, import("../types/base").AllowUnknownProps<{
20
+ cronjobs?: Record<string, false | import("../types/base").AllowUnknownProps<{
21
21
  schedule: string;
22
22
  command: string;
23
23
  concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
@@ -3,6 +3,10 @@ export declare type Gcloudregion = "asia-east1" | "asia-northeast1" | "asia-nort
3
3
  export declare type DeployConfigCloudRunCloudSql = {
4
4
  type: "unmanaged";
5
5
  instanceConnectionName: string;
6
+ /**
7
+ * the database username, defaults to "postgres"
8
+ */
9
+ dbUser?: string;
6
10
  /**
7
11
  * the prefix of the database, the full db name is this plus the environment slug
8
12
  *
@@ -106,6 +106,7 @@ export declare type DeployConfigMongodbBase = {
106
106
  */
107
107
  size?: string;
108
108
  };
109
+ resources?: KubernetesResourcesDef;
109
110
  };
110
111
  export declare type DeployConfigMongodbStandalone = {
111
112
  architecture: "standalone";
@@ -148,7 +149,7 @@ export declare type DeployConfigKubernetesValues = AllowUnknownProps<{
148
149
  * post-install/upgrade jobs. These use the app image and have all env vars available.
149
150
  * Typically used for migrations and seeds
150
151
  */
151
- jobs?: Record<string, AllowUnknownProps<{
152
+ jobs?: Record<string, false | AllowUnknownProps<{
152
153
  /**
153
154
  * the command to execute
154
155
  */
@@ -163,7 +164,7 @@ export declare type DeployConfigKubernetesValues = AllowUnknownProps<{
163
164
  /**
164
165
  * cronjobs that run periodically. These use the app image have all env vars available.
165
166
  */
166
- cronjobs?: Record<string, AllowUnknownProps<{
167
+ cronjobs?: Record<string, false | AllowUnknownProps<{
167
168
  schedule: string;
168
169
  command: string;
169
170
  concurrencyPolicy?: "Forbid" | "Allow" | "Replace";
@@ -221,14 +221,19 @@ var getFullReferencedJobName = function (referencedJobName, componentName, env,
221
221
  var replaceReferences = function (job, componentName, env, allRawJobs) {
222
222
  var _a, _b, _c;
223
223
  var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
224
- var cleanedNeeds = __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read((_b = job.needsOtherComponent) !== null && _b !== void 0 ? _b : []), false);
225
- var needs = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
226
- var _a;
224
+ var needsFromNeeds = (_a = job.needs) === null || _a === void 0 ? void 0 : _a.map(function (n) {
227
225
  return (0, lodash_1.isObject)(n) ? {
228
- job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
226
+ job: getFullReferencedJobName(n.job, componentName, env, allRawJobs),
229
227
  artifacts: n.artifacts
230
228
  } : getFullReferencedJobName(n, componentName, env, allRawJobs);
231
229
  });
230
+ var needsFromOtherComponents = (_b = job.needsOtherComponent) === null || _b === void 0 ? void 0 : _b.map(function (other) {
231
+ return {
232
+ artifacts: other.artifacts,
233
+ job: getFullReferencedJobName(other.job, other.componentName, env, allRawJobs)
234
+ };
235
+ });
236
+ var needs = __spreadArray(__spreadArray([], __read(needsFromNeeds !== null && needsFromNeeds !== void 0 ? needsFromNeeds : []), false), __read(needsFromOtherComponents !== null && needsFromOtherComponents !== void 0 ? needsFromOtherComponents : []), false);
232
237
  return __assign(__assign({}, job), {
233
238
  stage: stage,
234
239
  needs: needs,
@@ -18,37 +18,6 @@ var __rest = this && this.__rest || function (s, e) {
18
18
  }
19
19
  return t;
20
20
  };
21
- var __read = this && this.__read || function (o, n) {
22
- var m = typeof Symbol === "function" && o[Symbol.iterator];
23
- if (!m) return o;
24
- var i = m.call(o),
25
- r,
26
- ar = [],
27
- e;
28
- try {
29
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
- } catch (error) {
31
- e = {
32
- error: error
33
- };
34
- } finally {
35
- try {
36
- if (r && !r.done && (m = i["return"])) m.call(i);
37
- } finally {
38
- if (e) throw e.error;
39
- }
40
- }
41
- return ar;
42
- };
43
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
44
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
45
- if (ar || !(i in from)) {
46
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
47
- ar[i] = from[i];
48
- }
49
- }
50
- return to.concat(ar || Array.prototype.slice.call(from));
51
- };
52
21
  exports.__esModule = true;
53
22
  exports.makeGitlabJob = void 0;
54
23
  var lodash_1 = require("lodash");
@@ -65,9 +34,9 @@ var makeGitlabJob = function (_a) {
65
34
  rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
66
35
  return __assign(__assign({}, rest), {
67
36
  // sort in a predictable manner for snapshot tests
68
- needs: needs ? __spreadArray([], __read(needs), false).sort(function (a, b) {
37
+ needs: needs === null || needs === void 0 ? void 0 : needs.sort(function (a, b) {
69
38
  return getJobName(a).localeCompare(getJobName(b));
70
- }) : undefined,
39
+ }),
71
40
  retry: defaults_1.BASE_RETRY,
72
41
  interruptible: true
73
42
  });