@catladder/pipeline 0.0.0-refactor-needs-c896b98e → 0.0.0-refactor-args-52277d47

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 (36) 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 +138 -58
  4. package/dist/constants.js +1 -1
  5. package/dist/deploy/base.js +1 -1
  6. package/dist/deploy/cloudRun/deployJob.js +7 -12
  7. package/dist/deploy/cloudRun/index.js +2 -2
  8. package/dist/deploy/cloudRun/utils/createArgsString.d.ts +11 -0
  9. package/dist/deploy/cloudRun/utils/createArgsString.js +50 -0
  10. package/dist/deploy/kubernetes/kubeValues.d.ts +13 -10
  11. package/dist/deploy/kubernetes/kubeValues.js +47 -2
  12. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +2 -2
  13. package/dist/deploy/types/googleCloudRun.d.ts +4 -0
  14. package/dist/deploy/types/kubernetes.d.ts +3 -2
  15. package/dist/pipeline/createJobs.js +9 -4
  16. package/dist/pipeline/gitlab/makeGitlabJob.js +2 -33
  17. package/dist/tsconfig.tsbuildinfo +1 -1
  18. package/dist/types/jobs.d.ts +6 -7
  19. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +1778 -416
  20. package/examples/__snapshots__/custom-build-job.ts.snap +8 -8
  21. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +4077 -0
  22. package/examples/cloud-run-with-sql.ts +23 -0
  23. package/examples/kubernetes-with-jobs.ts +68 -0
  24. package/package.json +1 -1
  25. package/src/build/node/cache.ts +5 -2
  26. package/src/build/rails/test.ts +1 -1
  27. package/src/deploy/base.ts +1 -1
  28. package/src/deploy/cloudRun/deployJob.ts +8 -7
  29. package/src/deploy/cloudRun/index.ts +2 -1
  30. package/src/deploy/cloudRun/utils/createArgsString.ts +19 -0
  31. package/src/deploy/kubernetes/kubeValues.ts +14 -2
  32. package/src/deploy/types/googleCloudRun.ts +5 -0
  33. package/src/deploy/types/kubernetes.ts +20 -17
  34. package/src/pipeline/createJobs.ts +17 -14
  35. package/src/pipeline/gitlab/makeGitlabJob.ts +1 -3
  36. 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-52277d47" || 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,
@@ -29492,6 +29501,7 @@ var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(818);
29492
29501
  var database_1 = __nccwpck_require__(6745);
29493
29502
  var gitlab_1 = __nccwpck_require__(9818);
29494
29503
  var jobName_1 = __nccwpck_require__(9357);
29504
+ var createArgsString_1 = __nccwpck_require__(947);
29495
29505
  var setExtraVarsScripts = function (deployConfig) {
29496
29506
  return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
29497
29507
  };
@@ -29517,9 +29527,12 @@ var createGoogleCloudRunDeployJobs = function (context) {
29517
29527
  value = _b[1];
29518
29528
  return "".concat(key, "=").concat(value);
29519
29529
  }).join(",");
29520
- var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
29530
+ var commonArgs = (0, createArgsString_1.createArgsString)({
29531
+ project: deployConfig.projectId,
29532
+ region: deployConfig.region
29533
+ });
29521
29534
  var cloudRunArgs = deployConfig.cloudSql ? "--set-cloudsql-instances=".concat(deployConfig.cloudSql.instanceConnectionName) : "";
29522
- var commonDeployArgs = "--image ".concat(gcloudImageName, " ").concat(commonArgs, " ").concat(cloudRunArgs, " --labels ").concat(labelsString);
29535
+ var commonDeployArgs = "--image=".concat(gcloudImageName, " ").concat(commonArgs, " ").concat(cloudRunArgs, " --labels=").concat(labelsString);
29523
29536
  var serviceName = context.environment.fullName.toLowerCase();
29524
29537
  var getFullJobName = function (name) {
29525
29538
  return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
@@ -29559,16 +29572,7 @@ var createGoogleCloudRunDeployJobs = function (context) {
29559
29572
  "max-instances": customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances,
29560
29573
  "no-cpu-throttling": customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling
29561
29574
  };
29562
- var argsString = Object.entries(args).filter(function (_a) {
29563
- var _b = __read(_a, 2),
29564
- value = _b[1];
29565
- return !(0, lodash_1.isNil)(value);
29566
- }).map(function (_a) {
29567
- var _b = __read(_a, 2),
29568
- key = _b[0],
29569
- value = _b[1];
29570
- return "--".concat(key).concat(value !== true ? "=".concat(value) : "");
29571
- }).join(" ");
29575
+ var argsString = (0, createArgsString_1.createArgsString)(args);
29572
29576
  return "gcloud run deploy ".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "", " ").concat(commandArg, " ").concat(commonDeployArgs, " --env-vars-file=____envvars.yaml ").concat(argsString);
29573
29577
  };
29574
29578
  var getJobCreateScriptsForJob = function (jobName, job) {
@@ -29712,7 +29716,7 @@ var jobName_1 = __nccwpck_require__(9357);
29712
29716
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
29713
29717
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
29714
29718
  var getCloudSqlVariables = function (_a) {
29715
- var _b, _c;
29719
+ var _b, _c, _d;
29716
29720
  var deployConfigRaw = _a.deployConfigRaw,
29717
29721
  environmentSlug = _a.environmentSlug,
29718
29722
  env = _a.env,
@@ -29729,7 +29733,7 @@ var getCloudSqlVariables = function (_a) {
29729
29733
  return {
29730
29734
  CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
29731
29735
  DB_NAME: DB_NAME,
29732
- DB_USER: "postgres",
29736
+ DB_USER: (_d = deployConfigRaw.cloudSql.dbUser) !== null && _d !== void 0 ? _d : "postgres",
29733
29737
  DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
29734
29738
  DATABASE_URL: "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME".concat(additionalQueryParamsString),
29735
29739
  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)
@@ -29774,6 +29778,63 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
29774
29778
 
29775
29779
  /***/ }),
29776
29780
 
29781
+ /***/ 947:
29782
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
29783
+
29784
+ "use strict";
29785
+
29786
+
29787
+ var __read = this && this.__read || function (o, n) {
29788
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
29789
+ if (!m) return o;
29790
+ var i = m.call(o),
29791
+ r,
29792
+ ar = [],
29793
+ e;
29794
+ try {
29795
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
29796
+ } catch (error) {
29797
+ e = {
29798
+ error: error
29799
+ };
29800
+ } finally {
29801
+ try {
29802
+ if (r && !r.done && (m = i["return"])) m.call(i);
29803
+ } finally {
29804
+ if (e) throw e.error;
29805
+ }
29806
+ }
29807
+ return ar;
29808
+ };
29809
+ exports.__esModule = true;
29810
+ exports.createArgsString = void 0;
29811
+ var lodash_1 = __nccwpck_require__(3255);
29812
+ /**
29813
+ * creates arguments string:
29814
+ *
29815
+ * --key=value
29816
+ *
29817
+ * - undefined or null values will get removed completly
29818
+ * - true will just be "--key"
29819
+ * @param args args record
29820
+ * @returns
29821
+ */
29822
+ var createArgsString = function (args) {
29823
+ return Object.entries(args).filter(function (_a) {
29824
+ var _b = __read(_a, 2),
29825
+ value = _b[1];
29826
+ return !(0, lodash_1.isNil)(value);
29827
+ }).map(function (_a) {
29828
+ var _b = __read(_a, 2),
29829
+ key = _b[0],
29830
+ value = _b[1];
29831
+ return "--".concat(key).concat(value !== true ? "=".concat(value) : "");
29832
+ }).join(" ");
29833
+ };
29834
+ exports.createArgsString = createArgsString;
29835
+
29836
+ /***/ }),
29837
+
29777
29838
  /***/ 6745:
29778
29839
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
29779
29840
 
@@ -30395,6 +30456,16 @@ exports.createKubeEnv = createKubeEnv;
30395
30456
  "use strict";
30396
30457
 
30397
30458
 
30459
+ var __assign = this && this.__assign || function () {
30460
+ __assign = Object.assign || function (t) {
30461
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
30462
+ s = arguments[i];
30463
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
30464
+ }
30465
+ return t;
30466
+ };
30467
+ return __assign.apply(this, arguments);
30468
+ };
30398
30469
  var __rest = this && this.__rest || function (s, e) {
30399
30470
  var t = {};
30400
30471
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -30403,6 +30474,28 @@ var __rest = this && this.__rest || function (s, e) {
30403
30474
  }
30404
30475
  return t;
30405
30476
  };
30477
+ var __read = this && this.__read || function (o, n) {
30478
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
30479
+ if (!m) return o;
30480
+ var i = m.call(o),
30481
+ r,
30482
+ ar = [],
30483
+ e;
30484
+ try {
30485
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30486
+ } catch (error) {
30487
+ e = {
30488
+ error: error
30489
+ };
30490
+ } finally {
30491
+ try {
30492
+ if (r && !r.done && (m = i["return"])) m.call(i);
30493
+ } finally {
30494
+ if (e) throw e.error;
30495
+ }
30496
+ }
30497
+ return ar;
30498
+ };
30406
30499
  exports.__esModule = true;
30407
30500
  exports.createKubeValues = void 0;
30408
30501
  var lodash_1 = __nccwpck_require__(3255);
@@ -30443,6 +30536,14 @@ var createAppConfig = function (context, application) {
30443
30536
  );
30444
30537
  };
30445
30538
 
30539
+ var removeFalsy = function (record) {
30540
+ if (!record) return undefined;
30541
+ return Object.fromEntries(Object.entries(record).filter(function (_a) {
30542
+ var _b = __read(_a, 2),
30543
+ value = _b[1];
30544
+ return value !== false;
30545
+ }));
30546
+ };
30446
30547
  var createKubeValues = function (context) {
30447
30548
  var _a, _b;
30448
30549
  var deployConfig = context.componentConfig.deploy;
@@ -30459,13 +30560,18 @@ var createKubeValues = function (context) {
30459
30560
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
30460
30561
  var _c = values !== null && values !== void 0 ? values : {},
30461
30562
  application = _c.application,
30462
- rest = __rest(_c, ["application"]);
30563
+ jobs = _c.jobs,
30564
+ cronjobs = _c.cronjobs,
30565
+ rest = __rest(_c, ["application", "jobs", "cronjobs"]);
30463
30566
  var env = (0, kubeEnv_1.createKubeEnv)(context);
30464
30567
  var defaultKubeValues = (0, lodash_1.merge)({
30465
30568
  env: env,
30466
30569
  application: createAppConfig(context, application)
30467
30570
  }, (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));
30571
+ var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
30572
+ jobs: removeFalsy(jobs),
30573
+ cronjobs: removeFalsy(cronjobs)
30574
+ }, rest)));
30469
30575
  return kubeValues;
30470
30576
  };
30471
30577
  exports.createKubeValues = createKubeValues;
@@ -31514,14 +31620,19 @@ var getFullReferencedJobName = function (referencedJobName, componentName, env,
31514
31620
  var replaceReferences = function (job, componentName, env, allRawJobs) {
31515
31621
  var _a, _b, _c;
31516
31622
  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;
31623
+ var needsFromNeeds = (_a = job.needs) === null || _a === void 0 ? void 0 : _a.map(function (n) {
31520
31624
  return (0, lodash_1.isObject)(n) ? {
31521
- job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
31625
+ job: getFullReferencedJobName(n.job, componentName, env, allRawJobs),
31522
31626
  artifacts: n.artifacts
31523
31627
  } : getFullReferencedJobName(n, componentName, env, allRawJobs);
31524
31628
  });
31629
+ var needsFromOtherComponents = (_b = job.needsOtherComponent) === null || _b === void 0 ? void 0 : _b.map(function (other) {
31630
+ return {
31631
+ artifacts: other.artifacts,
31632
+ job: getFullReferencedJobName(other.job, other.componentName, env, allRawJobs)
31633
+ };
31634
+ });
31635
+ var needs = __spreadArray(__spreadArray([], __read(needsFromNeeds !== null && needsFromNeeds !== void 0 ? needsFromNeeds : []), false), __read(needsFromOtherComponents !== null && needsFromOtherComponents !== void 0 ? needsFromOtherComponents : []), false);
31525
31636
  return __assign(__assign({}, job), {
31526
31637
  stage: stage,
31527
31638
  needs: needs,
@@ -31634,37 +31745,6 @@ var __rest = this && this.__rest || function (s, e) {
31634
31745
  }
31635
31746
  return t;
31636
31747
  };
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
31748
  exports.__esModule = true;
31669
31749
  exports.makeGitlabJob = void 0;
31670
31750
  var lodash_1 = __nccwpck_require__(3255);
@@ -31681,9 +31761,9 @@ var makeGitlabJob = function (_a) {
31681
31761
  rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
31682
31762
  return __assign(__assign({}, rest), {
31683
31763
  // sort in a predictable manner for snapshot tests
31684
- needs: needs ? __spreadArray([], __read(needs), false).sort(function (a, b) {
31764
+ needs: needs === null || needs === void 0 ? void 0 : needs.sort(function (a, b) {
31685
31765
  return getJobName(a).localeCompare(getJobName(b));
31686
- }) : undefined,
31766
+ }),
31687
31767
  retry: defaults_1.BASE_RETRY,
31688
31768
  interruptible: true
31689
31769
  });
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-52277d47" || "";
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,
@@ -45,6 +45,7 @@ var gcloudServiceAccountLoginCommands_1 = require("./utils/gcloudServiceAccountL
45
45
  var database_1 = require("./utils/database");
46
46
  var gitlab_1 = require("../../utils/gitlab");
47
47
  var jobName_1 = require("./utils/jobName");
48
+ var createArgsString_1 = require("./utils/createArgsString");
48
49
  var setExtraVarsScripts = function (deployConfig) {
49
50
  return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
50
51
  };
@@ -70,9 +71,12 @@ var createGoogleCloudRunDeployJobs = function (context) {
70
71
  value = _b[1];
71
72
  return "".concat(key, "=").concat(value);
72
73
  }).join(",");
73
- var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
74
+ var commonArgs = (0, createArgsString_1.createArgsString)({
75
+ project: deployConfig.projectId,
76
+ region: deployConfig.region
77
+ });
74
78
  var cloudRunArgs = deployConfig.cloudSql ? "--set-cloudsql-instances=".concat(deployConfig.cloudSql.instanceConnectionName) : "";
75
- var commonDeployArgs = "--image ".concat(gcloudImageName, " ").concat(commonArgs, " ").concat(cloudRunArgs, " --labels ").concat(labelsString);
79
+ var commonDeployArgs = "--image=".concat(gcloudImageName, " ").concat(commonArgs, " ").concat(cloudRunArgs, " --labels=").concat(labelsString);
76
80
  var serviceName = context.environment.fullName.toLowerCase();
77
81
  var getFullJobName = function (name) {
78
82
  return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
@@ -112,16 +116,7 @@ var createGoogleCloudRunDeployJobs = function (context) {
112
116
  "max-instances": customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances,
113
117
  "no-cpu-throttling": customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling
114
118
  };
115
- var argsString = Object.entries(args).filter(function (_a) {
116
- var _b = __read(_a, 2),
117
- value = _b[1];
118
- return !(0, lodash_1.isNil)(value);
119
- }).map(function (_a) {
120
- var _b = __read(_a, 2),
121
- key = _b[0],
122
- value = _b[1];
123
- return "--".concat(key).concat(value !== true ? "=".concat(value) : "");
124
- }).join(" ");
119
+ var argsString = (0, createArgsString_1.createArgsString)(args);
125
120
  return "gcloud run deploy ".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "", " ").concat(commandArg, " ").concat(commonDeployArgs, " --env-vars-file=____envvars.yaml ").concat(argsString);
126
121
  };
127
122
  var getJobCreateScriptsForJob = function (jobName, job) {
@@ -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)
@@ -0,0 +1,11 @@
1
+ /**
2
+ * creates arguments string:
3
+ *
4
+ * --key=value
5
+ *
6
+ * - undefined or null values will get removed completly
7
+ * - true will just be "--key"
8
+ * @param args args record
9
+ * @returns
10
+ */
11
+ export declare const createArgsString: (args: Record<string, string | number | true | undefined>) => string;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var __read = this && this.__read || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o),
7
+ r,
8
+ ar = [],
9
+ e;
10
+ try {
11
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
+ } catch (error) {
13
+ e = {
14
+ error: error
15
+ };
16
+ } finally {
17
+ try {
18
+ if (r && !r.done && (m = i["return"])) m.call(i);
19
+ } finally {
20
+ if (e) throw e.error;
21
+ }
22
+ }
23
+ return ar;
24
+ };
25
+ exports.__esModule = true;
26
+ exports.createArgsString = void 0;
27
+ var lodash_1 = require("lodash");
28
+ /**
29
+ * creates arguments string:
30
+ *
31
+ * --key=value
32
+ *
33
+ * - undefined or null values will get removed completly
34
+ * - true will just be "--key"
35
+ * @param args args record
36
+ * @returns
37
+ */
38
+ var createArgsString = function (args) {
39
+ return Object.entries(args).filter(function (_a) {
40
+ var _b = __read(_a, 2),
41
+ value = _b[1];
42
+ return !(0, lodash_1.isNil)(value);
43
+ }).map(function (_a) {
44
+ var _b = __read(_a, 2),
45
+ key = _b[0],
46
+ value = _b[1];
47
+ return "--".concat(key).concat(value !== true ? "=".concat(value) : "");
48
+ }).join(" ");
49
+ };
50
+ exports.createArgsString = createArgsString;
@@ -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;