@catladder/cli 0.0.0-next-f0ea63b5 → 0.0.0-next-52feb889

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 (69) hide show
  1. package/dist/bundles/catenv/index.js +42 -8
  2. package/dist/bundles/cli/index.js +122 -10
  3. package/dist/cli/src/apps/cli/commands/project/setup/ensureGcloudProjectNumbers.d.ts +12 -0
  4. package/dist/cli/src/apps/cli/commands/project/setup/ensureGcloudProjectNumbers.js +64 -0
  5. package/dist/cli/src/apps/cli/commands/project/setup/ensureGcloudProjectNumbers.js.map +1 -0
  6. package/dist/cli/src/apps/cli/commands/project/setup/index.js +3 -0
  7. package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
  8. package/dist/cli/src/config/getProjectConfig.d.ts +6 -0
  9. package/dist/cli/src/config/getProjectConfig.js +10 -1
  10. package/dist/cli/src/config/getProjectConfig.js.map +1 -1
  11. package/dist/cli/src/gcloud/cloudSql/copyDb.js +6 -2
  12. package/dist/cli/src/gcloud/cloudSql/copyDb.js.map +1 -1
  13. package/dist/pipeline/src/constants.js +1 -1
  14. package/dist/pipeline/src/context/index.d.ts +1 -0
  15. package/dist/pipeline/src/context/index.js +1 -0
  16. package/dist/pipeline/src/context/index.js.map +1 -1
  17. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js +18 -3
  18. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js.map +1 -1
  19. package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +5 -1
  20. package/dist/pipeline/src/store/index.d.ts +4 -0
  21. package/dist/pipeline/src/store/index.js +12 -3
  22. package/dist/pipeline/src/store/index.js.map +1 -1
  23. package/dist/runner-images/agent-claude/Dockerfile +5 -0
  24. package/dist/runner-images/docker-build/Dockerfile +26 -0
  25. package/dist/runner-images/docker-build/scripts/ensureMeteorDockerfile +55 -0
  26. package/dist/runner-images/docker-build/scripts/ensureNginxDockerfile +85 -0
  27. package/dist/runner-images/docker-build/scripts/ensureNodeDockerfile +50 -0
  28. package/dist/runner-images/gcloud/Dockerfile +3 -0
  29. package/dist/runner-images/jobs-default/Dockerfile +22 -0
  30. package/dist/runner-images/jobs-meteor/Dockerfile +7 -0
  31. package/dist/runner-images/jobs-testing-chrome/Dockerfile +15 -0
  32. package/dist/runner-images/kubernetes/Dockerfile +26 -0
  33. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/Chart.lock +9 -0
  34. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/Chart.yaml +14 -0
  35. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/README.md +24 -0
  36. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/charts/mailhog-5.0.1.tgz +0 -0
  37. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/charts/mongodb-12.1.27.tgz +0 -0
  38. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/myvalues.yaml +15 -0
  39. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/_helpers.tpl +202 -0
  40. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.cloudsql-proxy-credentials.yml +10 -0
  41. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.cronjobs.yml +69 -0
  42. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.deployment.autoscaler.yml +19 -0
  43. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.deployment.yml +103 -0
  44. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.env.configmap.yml +27 -0
  45. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.env.secrets.yml +10 -0
  46. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.ingress.redirects.yaml +91 -0
  47. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.ingress.yaml +48 -0
  48. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.jobs.yml +70 -0
  49. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.service.yaml +31 -0
  50. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.volumes.yml +20 -0
  51. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.worker.deployment.yml +104 -0
  52. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.worker.service.yaml +34 -0
  53. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/mailhog.ingress.yaml +35 -0
  54. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/maintenance.deployment.yml +45 -0
  55. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/maintenance.service.yml +24 -0
  56. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/mongodb.backup.cronjob.yml +120 -0
  57. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/values.yaml +154 -0
  58. package/dist/runner-images/kubernetes/scripts/kubernetesCreateSecret +11 -0
  59. package/dist/runner-images/kubernetes/scripts/kubernetesDelete +5 -0
  60. package/dist/runner-images/kubernetes/scripts/kubernetesDeploy +57 -0
  61. package/dist/runner-images/kubernetes/scripts/kubernetesRollback +5 -0
  62. package/dist/runner-images/semantic-release/Dockerfile +24 -0
  63. package/dist/runner-images/semantic-release/scripts/semanticRelease +67 -0
  64. package/dist/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +2 -2
  66. package/src/apps/cli/commands/project/setup/ensureGcloudProjectNumbers.ts +61 -0
  67. package/src/apps/cli/commands/project/setup/index.ts +3 -0
  68. package/src/config/getProjectConfig.ts +9 -0
  69. package/src/gcloud/cloudSql/copyDb.ts +7 -2
@@ -397,7 +397,7 @@ program.parse();
397
397
  Object.defineProperty(exports, "__esModule", ({
398
398
  value: true
399
399
  }));
400
- exports.getJobOnlyEnvVarsResolved = exports.getEnvVarsResolved = exports.getGitlabVar = exports.getEnvironment = exports.getAllPipelineContexts = exports.getAllComponentsWithAllEnvsHierarchical = exports.getAllComponentsWithAllEnvsFlat = exports.getPipelineContextByChoice = exports.getProjectComponents = exports.getProjectConfig = exports.parseChoice = void 0;
400
+ exports.getJobOnlyEnvVarsResolved = exports.getEnvVarsResolved = exports.getGitlabVar = exports.getEnvironment = exports.getAllPipelineContexts = exports.getAllComponentsWithAllEnvsHierarchical = exports.getAllComponentsWithAllEnvsFlat = exports.getPipelineContextByChoice = exports.getProjectComponents = exports.invalidateProjectConfig = exports.getProjectConfig = exports.parseChoice = void 0;
401
401
  const pipeline_1 = __nccwpck_require__(60241);
402
402
  const gitlab_1 = __nccwpck_require__(4508);
403
403
  const projects_1 = __nccwpck_require__(57414);
@@ -427,6 +427,15 @@ const getProjectConfig = async () => {
427
427
  return currentConfig;
428
428
  };
429
429
  exports.getProjectConfig = getProjectConfig;
430
+ /**
431
+ * drops the cached config so the next access re-reads it from disk —
432
+ * needed after writing the catladder store, which is attached to the
433
+ * config (`config.store`) at read time
434
+ */
435
+ const invalidateProjectConfig = () => {
436
+ currentConfig = null;
437
+ };
438
+ exports.invalidateProjectConfig = invalidateProjectConfig;
430
439
  const getProjectComponents = async () => {
431
440
  const config = await (0, exports.getProjectConfig)();
432
441
  if (!config) return [];
@@ -5136,7 +5145,7 @@ Object.defineProperty(exports, "__esModule", ({
5136
5145
  value: true
5137
5146
  }));
5138
5147
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
5139
- exports.PIPELINE_IMAGE_TAG = "next-f0ea63b5" || 0;
5148
+ exports.PIPELINE_IMAGE_TAG = "next-52feb889" || 0;
5140
5149
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
5141
5150
 
5142
5151
  /***/ }),
@@ -5747,6 +5756,7 @@ Object.defineProperty(exports, "__esModule", ({
5747
5756
  value: true
5748
5757
  }));
5749
5758
  __exportStar(__nccwpck_require__(14847), exports);
5759
+ __exportStar(__nccwpck_require__(57044), exports);
5750
5760
  __exportStar(__nccwpck_require__(14956), exports);
5751
5761
  __exportStar(__nccwpck_require__(85855), exports);
5752
5762
 
@@ -7034,8 +7044,11 @@ const getCreateScheduleScript = context => {
7034
7044
  config
7035
7045
  }, jobIndex) => {
7036
7046
  var _a;
7047
+ // `headers` is pulled out of the shared args because the flag name differs
7048
+ // between create (`--headers`) and update (`--update-headers`).
7037
7049
  const {
7038
7050
  uri,
7051
+ headers,
7039
7052
  ...args
7040
7053
  } = getSchedulerArgs(config, context);
7041
7054
  const argsString = (0, createArgsString_1.createArgsString)({
@@ -7046,12 +7059,15 @@ const getCreateScheduleScript = context => {
7046
7059
  schedule: `"${config.schedule}"`,
7047
7060
  "max-retry-attempts": (_a = config.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0
7048
7061
  });
7049
- return [jobIndex === 0 ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"` : null, `current_job_uri="${uri}"`, `current_scheduler_name="${fullName}"`, `if echo "$exist_scheduler_names" | grep -Fx "$current_scheduler_name" >/dev/null; then`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`, `else`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`, `fi`].filter(utils_1.notNil).join("\n");
7062
+ const headersValue = headers ? `"${(0, bash_1.bashEscape)(headers)}"` : undefined;
7063
+ const createHeadersArg = headersValue ? ` --headers=${headersValue}` : "";
7064
+ const updateHeadersArg = headersValue ? ` --update-headers=${headersValue}` : "";
7065
+ return [jobIndex === 0 ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"` : null, `current_job_uri="${uri}"`, `current_scheduler_name="${fullName}"`, `if echo "$exist_scheduler_names" | grep -Fx "$current_scheduler_name" >/dev/null; then`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}${updateHeadersArg}`, `else`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}${createHeadersArg}`, `fi`].filter(utils_1.notNil).join("\n");
7050
7066
  });
7051
7067
  };
7052
7068
  exports.getCreateScheduleScript = getCreateScheduleScript;
7053
7069
  const getSchedulerArgs = (scheduler, context) => {
7054
- var _a;
7070
+ var _a, _b;
7055
7071
  if (scheduler.type === "job") {
7056
7072
  const {
7057
7073
  projectId,
@@ -7079,10 +7095,19 @@ const getSchedulerArgs = (scheduler, context) => {
7079
7095
  };
7080
7096
  }
7081
7097
  if (scheduler.type === "http") {
7098
+ // default the Content-Type to application/json when a body is sent and the
7099
+ // user didn't set one explicitly. Otherwise Cloud Scheduler falls back to
7100
+ // application/octet-stream, which is rarely what's intended.
7101
+ const hasContentType = Object.keys((_b = scheduler.headers) !== null && _b !== void 0 ? _b : {}).some(k => k.toLowerCase() === "content-type");
7102
+ const headers = scheduler.body && !hasContentType ? {
7103
+ "Content-Type": "application/json",
7104
+ ...scheduler.headers
7105
+ } : scheduler.headers;
7082
7106
  return {
7083
7107
  uri: scheduler.url,
7084
- "message-body": scheduler.body,
7108
+ "message-body": scheduler.body ? '"' + (0, bash_1.bashEscape)(scheduler.body) + '"' : undefined,
7085
7109
  "http-method": scheduler.method,
7110
+ headers: headers ? Object.entries(headers).map(([k, v]) => `${k}=${v}`).join(",") : undefined,
7086
7111
  "oidc-service-account-email": `"${(0, common_1.getComputeServiceAccountEmail)(context)}"`
7087
7112
  };
7088
7113
  }
@@ -9699,6 +9724,10 @@ exports.getCatladderStorePath = getCatladderStorePath;
9699
9724
  /**
9700
9725
  * reads and validates the catladder store. Returns an empty store when the
9701
9726
  * file does not exist (project setup has not run yet).
9727
+ *
9728
+ * An unreadable or invalid store is treated the same as a missing one
9729
+ * (with a warning): the store only holds machine-fetched values, so the
9730
+ * remedy is always rerunning project setup — not hand-editing the file.
9702
9731
  */
9703
9732
  const readCatladderStore = (directory = process.cwd()) => {
9704
9733
  var _a;
@@ -9706,9 +9735,14 @@ const readCatladderStore = (directory = process.cwd()) => {
9706
9735
  if (!(0, fs_1.existsSync)(path)) {
9707
9736
  return {};
9708
9737
  }
9709
- return exports.catladderStoreSchema.parse((_a = (0, yaml_1.parse)((0, fs_1.readFileSync)(path, {
9710
- encoding: "utf-8"
9711
- }))) !== null && _a !== void 0 ? _a : {});
9738
+ try {
9739
+ return exports.catladderStoreSchema.parse((_a = (0, yaml_1.parse)((0, fs_1.readFileSync)(path, {
9740
+ encoding: "utf-8"
9741
+ }))) !== null && _a !== void 0 ? _a : {});
9742
+ } catch (error) {
9743
+ console.warn(`⚠️ ignoring invalid ${exports.CATLADDER_STORE_FILE} (rerun "catladder project setup" to regenerate it): ${error instanceof Error ? error.message : error}`);
9744
+ return {};
9745
+ }
9712
9746
  };
9713
9747
  exports.readCatladderStore = readCatladderStore;
9714
9748
  /**
@@ -587,6 +587,77 @@ exports.projectConfigSecrets = projectConfigSecrets;
587
587
 
588
588
  /***/ }),
589
589
 
590
+ /***/ 22661:
591
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
592
+
593
+ "use strict";
594
+
595
+
596
+ Object.defineProperty(exports, "__esModule", ({
597
+ value: true
598
+ }));
599
+ exports.ensureGcloudProjectNumbers = void 0;
600
+ const pipeline_1 = __nccwpck_require__(60241);
601
+ const getProjectConfig_1 = __nccwpck_require__(50001);
602
+ const getProjectNumber_1 = __nccwpck_require__(68666);
603
+ const updateCatladderStore_1 = __nccwpck_require__(66487);
604
+ const projects_1 = __nccwpck_require__(57414);
605
+ /**
606
+ * fetches the gcloud project numbers of all cloud run deploys into the
607
+ * catladder store.
608
+ *
609
+ * This must run BEFORE any pipeline context is created: context creation
610
+ * computes the deterministic cloud run urls, which read the project
611
+ * number from the store and throw when it is missing — on a fresh
612
+ * project that would make `project setup` fail with the very error it is
613
+ * supposed to fix (chicken-and-egg).
614
+ */
615
+ const ensureGcloudProjectNumbers = async instance => {
616
+ var _a;
617
+ const config = await (0, getProjectConfig_1.getProjectConfig)();
618
+ if (!config) return;
619
+ const projectIds = new Set();
620
+ for (const {
621
+ componentName,
622
+ env
623
+ } of await (0, getProjectConfig_1.getAllComponentsWithAllEnvsFlat)()) {
624
+ const {
625
+ deploy
626
+ } = (0, pipeline_1.getEnvConfig)(config, componentName, env);
627
+ if (deploy && deploy.type === "google-cloudrun") {
628
+ projectIds.add(deploy.projectId);
629
+ }
630
+ }
631
+ const root = (_a = await (0, projects_1.getGitRoot)()) !== null && _a !== void 0 ? _a : process.cwd();
632
+ const store = (0, pipeline_1.readCatladderStore)(root);
633
+ const missing = [...projectIds].filter(projectId => {
634
+ var _a, _b;
635
+ return !((_b = (_a = store.gcloudProjects) === null || _a === void 0 ? void 0 : _a[projectId]) === null || _b === void 0 ? void 0 : _b.projectNumber);
636
+ });
637
+ for (const projectId of missing) {
638
+ instance.log(`fetch gcloud project number for ${projectId}...`);
639
+ const projectNumber = await (0, getProjectNumber_1.fetchGcloudProjectNumber)(projectId);
640
+ instance.log(`project number: ${projectNumber}`);
641
+ await (0, updateCatladderStore_1.updateCatladderStore)(current => ({
642
+ ...current,
643
+ gcloudProjects: {
644
+ ...current.gcloudProjects,
645
+ [projectId]: {
646
+ projectNumber
647
+ }
648
+ }
649
+ }));
650
+ }
651
+ if (missing.length > 0) {
652
+ // the store is attached to the config at read time; drop the cached
653
+ // config so contexts created after this pre-pass see the new values
654
+ (0, getProjectConfig_1.invalidateProjectConfig)();
655
+ }
656
+ };
657
+ exports.ensureGcloudProjectNumbers = ensureGcloudProjectNumbers;
658
+
659
+ /***/ }),
660
+
590
661
  /***/ 80426:
591
662
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
592
663
 
@@ -603,7 +674,10 @@ const setupContext_1 = __nccwpck_require__(63516);
603
674
  const setupTopic_1 = __nccwpck_require__(66992);
604
675
  const setupAgents_1 = __nccwpck_require__(73861);
605
676
  const logSection_1 = __nccwpck_require__(87105);
677
+ const ensureGcloudProjectNumbers_1 = __nccwpck_require__(22661);
606
678
  const setupProject = async (instance, onlyComponents) => {
679
+ // must come first: creating contexts already requires the store
680
+ await (0, ensureGcloudProjectNumbers_1.ensureGcloudProjectNumbers)(instance);
607
681
  const allContext = await (0, getProjectConfig_1.getAllPipelineContexts)(onlyComponents);
608
682
  instance.log("will setup those contexts:");
609
683
  allContext.forEach(context => {
@@ -4373,7 +4447,7 @@ exports.uninstallCompletions = uninstallCompletions;
4373
4447
  Object.defineProperty(exports, "__esModule", ({
4374
4448
  value: true
4375
4449
  }));
4376
- exports.getJobOnlyEnvVarsResolved = exports.getEnvVarsResolved = exports.getGitlabVar = exports.getEnvironment = exports.getAllPipelineContexts = exports.getAllComponentsWithAllEnvsHierarchical = exports.getAllComponentsWithAllEnvsFlat = exports.getPipelineContextByChoice = exports.getProjectComponents = exports.getProjectConfig = exports.parseChoice = void 0;
4450
+ exports.getJobOnlyEnvVarsResolved = exports.getEnvVarsResolved = exports.getGitlabVar = exports.getEnvironment = exports.getAllPipelineContexts = exports.getAllComponentsWithAllEnvsHierarchical = exports.getAllComponentsWithAllEnvsFlat = exports.getPipelineContextByChoice = exports.getProjectComponents = exports.invalidateProjectConfig = exports.getProjectConfig = exports.parseChoice = void 0;
4377
4451
  const pipeline_1 = __nccwpck_require__(60241);
4378
4452
  const gitlab_1 = __nccwpck_require__(4508);
4379
4453
  const projects_1 = __nccwpck_require__(57414);
@@ -4403,6 +4477,15 @@ const getProjectConfig = async () => {
4403
4477
  return currentConfig;
4404
4478
  };
4405
4479
  exports.getProjectConfig = getProjectConfig;
4480
+ /**
4481
+ * drops the cached config so the next access re-reads it from disk —
4482
+ * needed after writing the catladder store, which is attached to the
4483
+ * config (`config.store`) at read time
4484
+ */
4485
+ const invalidateProjectConfig = () => {
4486
+ currentConfig = null;
4487
+ };
4488
+ exports.invalidateProjectConfig = invalidateProjectConfig;
4406
4489
  const getProjectComponents = async () => {
4407
4490
  const config = await (0, exports.getProjectConfig)();
4408
4491
  if (!config) return [];
@@ -4661,8 +4744,12 @@ const createCopyDbScript = ({
4661
4744
  const copyDBScript = `
4662
4745
  set -e
4663
4746
 
4664
- ${targetPSQL(`-c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`)}
4665
- ${targetPSQL(`-c 'create database "${targetDbName}"' 1> /dev/null`)}
4747
+ ${targetPSQL(
4748
+ // connect to the always-existing "postgres" maintenance database:
4749
+ // without an explicit dbname, psql falls back to the username and
4750
+ // fails with e.g. 'FATAL: database "user" does not exist'
4751
+ `--dbname=postgres -c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`)}
4752
+ ${targetPSQL(`--dbname=postgres -c 'create database "${targetDbName}"' 1> /dev/null`)}
4666
4753
  echo "Estimating database size..."
4667
4754
  DB_SIZE=$(PGPASSWORD=${encodedSourcePassword} psql --dbname=postgres://${encodedSourceUsername}:${encodedSourcePassword}@localhost:${sourcePort}/${sourceDbName} -t -A -c "SELECT pg_database_size('${sourceDbName}')")
4668
4755
  # pg_database_size includes indexes, TOAST, and free space — pg_dump output is roughly 40% of that
@@ -10309,7 +10396,7 @@ Object.defineProperty(exports, "__esModule", ({
10309
10396
  value: true
10310
10397
  }));
10311
10398
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
10312
- exports.PIPELINE_IMAGE_TAG = "next-f0ea63b5" || 0;
10399
+ exports.PIPELINE_IMAGE_TAG = "next-52feb889" || 0;
10313
10400
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
10314
10401
 
10315
10402
  /***/ }),
@@ -10920,6 +11007,7 @@ Object.defineProperty(exports, "__esModule", ({
10920
11007
  value: true
10921
11008
  }));
10922
11009
  __exportStar(__nccwpck_require__(14847), exports);
11010
+ __exportStar(__nccwpck_require__(57044), exports);
10923
11011
  __exportStar(__nccwpck_require__(14956), exports);
10924
11012
  __exportStar(__nccwpck_require__(85855), exports);
10925
11013
 
@@ -12207,8 +12295,11 @@ const getCreateScheduleScript = context => {
12207
12295
  config
12208
12296
  }, jobIndex) => {
12209
12297
  var _a;
12298
+ // `headers` is pulled out of the shared args because the flag name differs
12299
+ // between create (`--headers`) and update (`--update-headers`).
12210
12300
  const {
12211
12301
  uri,
12302
+ headers,
12212
12303
  ...args
12213
12304
  } = getSchedulerArgs(config, context);
12214
12305
  const argsString = (0, createArgsString_1.createArgsString)({
@@ -12219,12 +12310,15 @@ const getCreateScheduleScript = context => {
12219
12310
  schedule: `"${config.schedule}"`,
12220
12311
  "max-retry-attempts": (_a = config.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0
12221
12312
  });
12222
- return [jobIndex === 0 ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"` : null, `current_job_uri="${uri}"`, `current_scheduler_name="${fullName}"`, `if echo "$exist_scheduler_names" | grep -Fx "$current_scheduler_name" >/dev/null; then`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`, `else`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`, `fi`].filter(utils_1.notNil).join("\n");
12313
+ const headersValue = headers ? `"${(0, bash_1.bashEscape)(headers)}"` : undefined;
12314
+ const createHeadersArg = headersValue ? ` --headers=${headersValue}` : "";
12315
+ const updateHeadersArg = headersValue ? ` --update-headers=${headersValue}` : "";
12316
+ return [jobIndex === 0 ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"` : null, `current_job_uri="${uri}"`, `current_scheduler_name="${fullName}"`, `if echo "$exist_scheduler_names" | grep -Fx "$current_scheduler_name" >/dev/null; then`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}${updateHeadersArg}`, `else`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}${createHeadersArg}`, `fi`].filter(utils_1.notNil).join("\n");
12223
12317
  });
12224
12318
  };
12225
12319
  exports.getCreateScheduleScript = getCreateScheduleScript;
12226
12320
  const getSchedulerArgs = (scheduler, context) => {
12227
- var _a;
12321
+ var _a, _b;
12228
12322
  if (scheduler.type === "job") {
12229
12323
  const {
12230
12324
  projectId,
@@ -12252,10 +12346,19 @@ const getSchedulerArgs = (scheduler, context) => {
12252
12346
  };
12253
12347
  }
12254
12348
  if (scheduler.type === "http") {
12349
+ // default the Content-Type to application/json when a body is sent and the
12350
+ // user didn't set one explicitly. Otherwise Cloud Scheduler falls back to
12351
+ // application/octet-stream, which is rarely what's intended.
12352
+ const hasContentType = Object.keys((_b = scheduler.headers) !== null && _b !== void 0 ? _b : {}).some(k => k.toLowerCase() === "content-type");
12353
+ const headers = scheduler.body && !hasContentType ? {
12354
+ "Content-Type": "application/json",
12355
+ ...scheduler.headers
12356
+ } : scheduler.headers;
12255
12357
  return {
12256
12358
  uri: scheduler.url,
12257
- "message-body": scheduler.body,
12359
+ "message-body": scheduler.body ? '"' + (0, bash_1.bashEscape)(scheduler.body) + '"' : undefined,
12258
12360
  "http-method": scheduler.method,
12361
+ headers: headers ? Object.entries(headers).map(([k, v]) => `${k}=${v}`).join(",") : undefined,
12259
12362
  "oidc-service-account-email": `"${(0, common_1.getComputeServiceAccountEmail)(context)}"`
12260
12363
  };
12261
12364
  }
@@ -14872,6 +14975,10 @@ exports.getCatladderStorePath = getCatladderStorePath;
14872
14975
  /**
14873
14976
  * reads and validates the catladder store. Returns an empty store when the
14874
14977
  * file does not exist (project setup has not run yet).
14978
+ *
14979
+ * An unreadable or invalid store is treated the same as a missing one
14980
+ * (with a warning): the store only holds machine-fetched values, so the
14981
+ * remedy is always rerunning project setup — not hand-editing the file.
14875
14982
  */
14876
14983
  const readCatladderStore = (directory = process.cwd()) => {
14877
14984
  var _a;
@@ -14879,9 +14986,14 @@ const readCatladderStore = (directory = process.cwd()) => {
14879
14986
  if (!(0, fs_1.existsSync)(path)) {
14880
14987
  return {};
14881
14988
  }
14882
- return exports.catladderStoreSchema.parse((_a = (0, yaml_1.parse)((0, fs_1.readFileSync)(path, {
14883
- encoding: "utf-8"
14884
- }))) !== null && _a !== void 0 ? _a : {});
14989
+ try {
14990
+ return exports.catladderStoreSchema.parse((_a = (0, yaml_1.parse)((0, fs_1.readFileSync)(path, {
14991
+ encoding: "utf-8"
14992
+ }))) !== null && _a !== void 0 ? _a : {});
14993
+ } catch (error) {
14994
+ console.warn(`⚠️ ignoring invalid ${exports.CATLADDER_STORE_FILE} (rerun "catladder project setup" to regenerate it): ${error instanceof Error ? error.message : error}`);
14995
+ return {};
14996
+ }
14885
14997
  };
14886
14998
  exports.readCatladderStore = readCatladderStore;
14887
14999
  /**
@@ -0,0 +1,12 @@
1
+ import type { IO } from "../../../../../core/types";
2
+ /**
3
+ * fetches the gcloud project numbers of all cloud run deploys into the
4
+ * catladder store.
5
+ *
6
+ * This must run BEFORE any pipeline context is created: context creation
7
+ * computes the deterministic cloud run urls, which read the project
8
+ * number from the store and throw when it is missing — on a fresh
9
+ * project that would make `project setup` fail with the very error it is
10
+ * supposed to fix (chicken-and-egg).
11
+ */
12
+ export declare const ensureGcloudProjectNumbers: (instance: IO) => Promise<void>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ensureGcloudProjectNumbers = void 0;
7
+ const pipeline_1 = require("../../../../../../../pipeline/src/index.js");
8
+ const getProjectConfig_1 = require("../../../../../config/getProjectConfig");
9
+ const getProjectNumber_1 = require("../../../../../gcloud/getProjectNumber");
10
+ const updateCatladderStore_1 = require("../../../../../store/updateCatladderStore");
11
+ const projects_1 = require("../../../../../utils/projects");
12
+ /**
13
+ * fetches the gcloud project numbers of all cloud run deploys into the
14
+ * catladder store.
15
+ *
16
+ * This must run BEFORE any pipeline context is created: context creation
17
+ * computes the deterministic cloud run urls, which read the project
18
+ * number from the store and throw when it is missing — on a fresh
19
+ * project that would make `project setup` fail with the very error it is
20
+ * supposed to fix (chicken-and-egg).
21
+ */
22
+ const ensureGcloudProjectNumbers = async instance => {
23
+ var _a;
24
+ const config = await (0, getProjectConfig_1.getProjectConfig)();
25
+ if (!config) return;
26
+ const projectIds = new Set();
27
+ for (const {
28
+ componentName,
29
+ env
30
+ } of await (0, getProjectConfig_1.getAllComponentsWithAllEnvsFlat)()) {
31
+ const {
32
+ deploy
33
+ } = (0, pipeline_1.getEnvConfig)(config, componentName, env);
34
+ if (deploy && deploy.type === "google-cloudrun") {
35
+ projectIds.add(deploy.projectId);
36
+ }
37
+ }
38
+ const root = (_a = await (0, projects_1.getGitRoot)()) !== null && _a !== void 0 ? _a : process.cwd();
39
+ const store = (0, pipeline_1.readCatladderStore)(root);
40
+ const missing = [...projectIds].filter(projectId => {
41
+ var _a, _b;
42
+ return !((_b = (_a = store.gcloudProjects) === null || _a === void 0 ? void 0 : _a[projectId]) === null || _b === void 0 ? void 0 : _b.projectNumber);
43
+ });
44
+ for (const projectId of missing) {
45
+ instance.log(`fetch gcloud project number for ${projectId}...`);
46
+ const projectNumber = await (0, getProjectNumber_1.fetchGcloudProjectNumber)(projectId);
47
+ instance.log(`project number: ${projectNumber}`);
48
+ await (0, updateCatladderStore_1.updateCatladderStore)(current => ({
49
+ ...current,
50
+ gcloudProjects: {
51
+ ...current.gcloudProjects,
52
+ [projectId]: {
53
+ projectNumber
54
+ }
55
+ }
56
+ }));
57
+ }
58
+ if (missing.length > 0) {
59
+ // the store is attached to the config at read time; drop the cached
60
+ // config so contexts created after this pre-pass see the new values
61
+ (0, getProjectConfig_1.invalidateProjectConfig)();
62
+ }
63
+ };
64
+ exports.ensureGcloudProjectNumbers = ensureGcloudProjectNumbers;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureGcloudProjectNumbers.js","sourceRoot":"","sources":["../../../../../../../../src/apps/cli/commands/project/setup/ensureGcloudProjectNumbers.ts"],"names":[],"mappings":";;;AAAA,kDAAuE;AACvE,6EAIgD;AAEhD,6EAAkF;AAClF,oFAAiF;AACjF,4DAA2D;AAE3D;;;;;;;;;GASG;AACI,MAAM,0BAA0B,GAAG,KAAK,EAAE,QAAY,EAAE,EAAE;;IAC/D,MAAM,MAAM,GAAG,MAAM,IAAA,mCAAgB,GAAE,CAAC;IACxC,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,KAAK,MAAM,EACT,aAAa,EACb,GAAG,GACJ,IAAI,MAAM,IAAA,kDAA+B,GAAE,EAAE,CAAC;QAC7C,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,uBAAY,EAAC,MAAM,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;QAC5D,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAChD,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,MAAA,CAAC,MAAM,IAAA,qBAAU,GAAE,CAAC,mCAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,IAAA,6BAAkB,EAAC,IAAI,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,CACpC,CAAC,SAAS,EAAE,EAAE,eAAC,OAAA,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,cAAc,0CAAG,SAAS,CAAC,0CAAE,aAAa,CAAA,CAAA,EAAA,CACjE,CAAC;IAEF,KAAK,MAAM,SAAS,IAAI,OAAO,EAAE,CAAC;QAChC,QAAQ,CAAC,GAAG,CAAC,mCAAmC,SAAS,KAAK,CAAC,CAAC;QAChE,MAAM,aAAa,GAAG,MAAM,IAAA,2CAAwB,EAAC,SAAS,CAAC,CAAC;QAChE,QAAQ,CAAC,GAAG,CAAC,mBAAmB,aAAa,EAAE,CAAC,CAAC;QACjD,MAAM,IAAA,2CAAoB,EAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACvC,GAAG,OAAO;YACV,cAAc,EAAE;gBACd,GAAG,OAAO,CAAC,cAAc;gBACzB,CAAC,SAAS,CAAC,EAAE,EAAE,aAAa,EAAE;aAC/B;SACF,CAAC,CAAC,CAAC;IACN,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,oEAAoE;QACpE,oEAAoE;QACpE,IAAA,0CAAuB,GAAE,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAvCW,QAAA,0BAA0B,8BAuCrC"}
@@ -10,7 +10,10 @@ const setupContext_1 = require("./setupContext");
10
10
  const setupTopic_1 = require("./setupTopic");
11
11
  const setupAgents_1 = require("./setupAgents");
12
12
  const logSection_1 = require("./logSection");
13
+ const ensureGcloudProjectNumbers_1 = require("./ensureGcloudProjectNumbers");
13
14
  const setupProject = async (instance, onlyComponents) => {
15
+ // must come first: creating contexts already requires the store
16
+ await (0, ensureGcloudProjectNumbers_1.ensureGcloudProjectNumbers)(instance);
14
17
  const allContext = await (0, getProjectConfig_1.getAllPipelineContexts)(onlyComponents);
15
18
  instance.log("will setup those contexts:");
16
19
  allContext.forEach(context => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../src/apps/cli/commands/project/setup/index.ts"],"names":[],"mappings":";;;AACA,6EAAgF;AAChF,2DAAwD;AACxD,iDAA8C;AAC9C,6CAA0C;AAC1C,+CAA4C;AAC5C,6CAA0C;AAEnC,MAAM,YAAY,GAAG,KAAK,EAC/B,QAAY,EACZ,cAAkC,EAClC,EAAE;IACF,MAAM,UAAU,GAAG,MAAM,IAA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ChB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;IAC9C,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC,CAAC;AAlCW,QAAA,YAAY,gBAkCvB"}
@@ -2,6 +2,12 @@ import type { Config } from "../../../pipeline/src/index.js";
2
2
  import type { IO } from "../core/types";
3
3
  export { parseChoice } from "./parseChoice";
4
4
  export declare const getProjectConfig: () => Promise<Config>;
5
+ /**
6
+ * drops the cached config so the next access re-reads it from disk —
7
+ * needed after writing the catladder store, which is attached to the
8
+ * config (`config.store`) at read time
9
+ */
10
+ export declare const invalidateProjectConfig: () => void;
5
11
  export declare const getProjectComponents: () => Promise<string[]>;
6
12
  export declare const getPipelineContextByChoice: (env: string, componentName: string) => Promise<import("../../../pipeline/src/index.js").ComponentContext>;
7
13
  export declare const getAllComponentsWithAllEnvsFlat: () => Promise<Array<{
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getJobOnlyEnvVarsResolved = exports.getEnvVarsResolved = exports.getGitlabVar = exports.getEnvironment = exports.getAllPipelineContexts = exports.getAllComponentsWithAllEnvsHierarchical = exports.getAllComponentsWithAllEnvsFlat = exports.getPipelineContextByChoice = exports.getProjectComponents = exports.getProjectConfig = exports.parseChoice = void 0;
6
+ exports.getJobOnlyEnvVarsResolved = exports.getEnvVarsResolved = exports.getGitlabVar = exports.getEnvironment = exports.getAllPipelineContexts = exports.getAllComponentsWithAllEnvsHierarchical = exports.getAllComponentsWithAllEnvsFlat = exports.getPipelineContextByChoice = exports.getProjectComponents = exports.invalidateProjectConfig = exports.getProjectConfig = exports.parseChoice = void 0;
7
7
  const pipeline_1 = require("../../../pipeline/src/index.js");
8
8
  const gitlab_1 = require("../utils/gitlab");
9
9
  const projects_1 = require("../utils/projects");
@@ -33,6 +33,15 @@ const getProjectConfig = async () => {
33
33
  return currentConfig;
34
34
  };
35
35
  exports.getProjectConfig = getProjectConfig;
36
+ /**
37
+ * drops the cached config so the next access re-reads it from disk —
38
+ * needed after writing the catladder store, which is attached to the
39
+ * config (`config.store`) at read time
40
+ */
41
+ const invalidateProjectConfig = () => {
42
+ currentConfig = null;
43
+ };
44
+ exports.invalidateProjectConfig = invalidateProjectConfig;
36
45
  const getProjectComponents = async () => {
37
46
  const config = await (0, exports.getProjectConfig)();
38
47
  if (!config) return [];
@@ -1 +1 @@
1
- {"version":3,"file":"getProjectConfig.js","sourceRoot":"","sources":["../../../../src/config/getProjectConfig.ts"],"names":[],"mappings":";;;AAKA,kDAM6B;AAG7B,4CAA4D;AAE5D,gDAA+C;AAE/C,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AAEpB,IAAI,aAAa,GAAkB,IAAI,CAAC;AAExC,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;IAC5B,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAU,GAAE,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAU,EAAC,OAAO,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;IACT,CAAC;IACD,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;AAChC,CAAC,CAAC;AAEK,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;IACzC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,UAAU,EAAE,CAAC;IACrB,CAAC;IACD,OAAO,aAAuB,CAAC;AACjC,CAAC,CAAC;AALW,QAAA,gBAAgB,oBAK3B;AAEK,MAAM,oBAAoB,GAAG,KAAK,IAAI,EAAE;IAC7C,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAgB,GAAE,CAAC;IACxC,I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'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`)}
34
- ${targetPSQL(`-c 'create database "${targetDbName}"' 1> /dev/null`)}
33
+ ${targetPSQL(
34
+ // connect to the always-existing "postgres" maintenance database:
35
+ // without an explicit dbname, psql falls back to the username and
36
+ // fails with e.g. 'FATAL: database "user" does not exist'
37
+ `--dbname=postgres -c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`)}
38
+ ${targetPSQL(`--dbname=postgres -c 'create database "${targetDbName}"' 1> /dev/null`)}
35
39
  echo "Estimating database size..."
36
40
  DB_SIZE=$(PGPASSWORD=${encodedSourcePassword} psql --dbname=postgres://${encodedSourceUsername}:${encodedSourcePassword}@localhost:${sourcePort}/${sourceDbName} -t -A -c "SELECT pg_database_size('${sourceDbName}')")
37
41
  # pg_database_size includes indexes, TOAST, and free space — pg_dump output is roughly 40% of that
@@ -1 +1 @@
1
- {"version":3,"file":"copyDb.js","sourceRoot":"","sources":["../../../../../src/gcloud/cloudSql/copyDb.ts"],"names":[],"mappings":";;;AAAA,iEAA8C;AAWvC,MAAM,WAAW,GAAG,KAAK,EAAE,IAAU,EAAE,EAAE;IAC9C,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAExC,OAAO,MAAM,IAAA,6BAAK,EAAC,MAAM,EAAE,EAAE,EAAE;QAC7B,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;AACL,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB;AACF,MAAM,kBAAkB,GAAG,CAAC,EAC1B,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,GACP,EAAE,EAAE;IACT,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,EAAE,CACrC,cAAc,cAAc,YAAY,UAAU,4BAA4B,cAAc,OAAO,OAAO,EAAE,CAAC;IAE/G,yEAAyE;IACzE,MAAM,qBAAqB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AAC,cAAc,CAAC,CAAC;IAEjE,MAAM,YAAY,GAAG;;;QAGf,UAAU;IACV,kEAAkE;IAClE,kEAAkE;IAClE,0DAA0D;IAC1D,wCAAwC,YAAY,sCAAsC,CAC3F;QACC,UAAU,CACV,0CAA0C,YAAY,iBAAiB,CACxE;;6BAEsB,qBAAqB,6BAA6B,qBAAqB,IAAI,qBAAqB,cAAc,UAAU,IAAI,YAAY,uCAAuC,YAAY;;;;;;;;;;;;;0CAa9K,qBAAqB,IAAI,qBAAqB,cAAc,UAAU,IAAI,YAAY,2CAA2C,UAAU,CAAC,IAAI,YAAY,gBAAgB,CAAC;;;OAGhN,CAAC;IACN,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC"}
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
7
- exports.PIPELINE_IMAGE_TAG = "next-f0ea63b5" || "latest";
7
+ exports.PIPELINE_IMAGE_TAG = "next-52feb889" || "latest";
8
8
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
@@ -1,3 +1,4 @@
1
1
  export * from "./createComponentContext";
2
+ export * from "./getEnvConfig";
2
3
  export * from "./getEnvironment";
3
4
  export * from "./getEnvironmentVariables";
@@ -23,5 +23,6 @@ Object.defineProperty(exports, "__esModule", {
23
23
  value: true
24
24
  });
25
25
  __exportStar(require("./createComponentContext"), exports);
26
+ __exportStar(require("./getEnvConfig"), exports);
26
27
  __exportStar(require("./getEnvironment"), exports);
27
28
  __exportStar(require("./getEnvironmentVariables"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../pipeline/src/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,mDAAiC;AACjC,4DAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../pipeline/src/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,iDAA+B;AAC/B,mDAAiC;AACjC,4DAA0C"}
@@ -36,8 +36,11 @@ const getCreateScheduleScript = context => {
36
36
  config
37
37
  }, jobIndex) => {
38
38
  var _a;
39
+ // `headers` is pulled out of the shared args because the flag name differs
40
+ // between create (`--headers`) and update (`--update-headers`).
39
41
  const {
40
42
  uri,
43
+ headers,
41
44
  ...args
42
45
  } = getSchedulerArgs(config, context);
43
46
  const argsString = (0, createArgsString_1.createArgsString)({
@@ -48,12 +51,15 @@ const getCreateScheduleScript = context => {
48
51
  schedule: `"${config.schedule}"`,
49
52
  "max-retry-attempts": (_a = config.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0
50
53
  });
51
- return [jobIndex === 0 ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"` : null, `current_job_uri="${uri}"`, `current_scheduler_name="${fullName}"`, `if echo "$exist_scheduler_names" | grep -Fx "$current_scheduler_name" >/dev/null; then`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`, `else`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`, `fi`].filter(utils_1.notNil).join("\n");
54
+ const headersValue = headers ? `"${(0, bash_1.bashEscape)(headers)}"` : undefined;
55
+ const createHeadersArg = headersValue ? ` --headers=${headersValue}` : "";
56
+ const updateHeadersArg = headersValue ? ` --update-headers=${headersValue}` : "";
57
+ return [jobIndex === 0 ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"` : null, `current_job_uri="${uri}"`, `current_scheduler_name="${fullName}"`, `if echo "$exist_scheduler_names" | grep -Fx "$current_scheduler_name" >/dev/null; then`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}${updateHeadersArg}`, `else`, ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}${createHeadersArg}`, `fi`].filter(utils_1.notNil).join("\n");
52
58
  });
53
59
  };
54
60
  exports.getCreateScheduleScript = getCreateScheduleScript;
55
61
  const getSchedulerArgs = (scheduler, context) => {
56
- var _a;
62
+ var _a, _b;
57
63
  if (scheduler.type === "job") {
58
64
  const {
59
65
  projectId,
@@ -81,10 +87,19 @@ const getSchedulerArgs = (scheduler, context) => {
81
87
  };
82
88
  }
83
89
  if (scheduler.type === "http") {
90
+ // default the Content-Type to application/json when a body is sent and the
91
+ // user didn't set one explicitly. Otherwise Cloud Scheduler falls back to
92
+ // application/octet-stream, which is rarely what's intended.
93
+ const hasContentType = Object.keys((_b = scheduler.headers) !== null && _b !== void 0 ? _b : {}).some(k => k.toLowerCase() === "content-type");
94
+ const headers = scheduler.body && !hasContentType ? {
95
+ "Content-Type": "application/json",
96
+ ...scheduler.headers
97
+ } : scheduler.headers;
84
98
  return {
85
99
  uri: scheduler.url,
86
- "message-body": scheduler.body,
100
+ "message-body": scheduler.body ? '"' + (0, bash_1.bashEscape)(scheduler.body) + '"' : undefined,
87
101
  "http-method": scheduler.method,
102
+ headers: headers ? Object.entries(headers).map(([k, v]) => `${k}=${v}`).join(",") : undefined,
88
103
  "oidc-service-account-email": `"${(0, common_1.getComputeServiceAccountEmail)(context)}"`
89
104
  };
90
105
  }