@backstage/plugin-scaffolder-backend 0.15.21-next.0 → 0.15.21

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 0.15.21
4
+
5
+ ### Patch Changes
6
+
7
+ - b05d303226: Added the ability to support supplying secrets when creating tasks in the `scaffolder-backend`.
8
+
9
+ **deprecation**: Deprecated `ctx.token` from actions in the `scaffolder-backend`. Please move to using `ctx.secrets.backstageToken` instead.
10
+
11
+ **deprecation**: Deprecated `task.token` in `TaskSpec` in the `scaffolder-backend`. Please move to using `task.secrets.backstageToken` instead.
12
+
13
+ - Updated dependencies
14
+ - @backstage/plugin-catalog-backend@0.21.0
15
+ - @backstage/integration@0.7.2
16
+ - @backstage/backend-common@0.10.4
17
+ - @backstage/config@0.1.13
18
+ - @backstage/catalog-model@0.9.10
19
+ - @backstage/catalog-client@0.5.5
20
+ - @backstage/plugin-scaffolder-backend-module-cookiecutter@0.1.9
21
+ - @backstage/plugin-scaffolder-common@0.1.3
22
+
3
23
  ## 0.15.21-next.0
4
24
 
5
25
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -119,6 +119,7 @@ function createCatalogRegisterAction(options) {
119
119
  }
120
120
  },
121
121
  async handler(ctx) {
122
+ var _a, _b;
122
123
  const { input } = ctx;
123
124
  let catalogInfoUrl;
124
125
  if ("catalogInfoUrl" in input) {
@@ -138,13 +139,13 @@ function createCatalogRegisterAction(options) {
138
139
  await catalogClient.addLocation({
139
140
  type: "url",
140
141
  target: catalogInfoUrl
141
- }, ctx.token ? { token: ctx.token } : {});
142
+ }, ((_a = ctx.secrets) == null ? void 0 : _a.backstageToken) ? { token: ctx.secrets.backstageToken } : {});
142
143
  try {
143
144
  const result = await catalogClient.addLocation({
144
145
  dryRun: true,
145
146
  type: "url",
146
147
  target: catalogInfoUrl
147
- }, ctx.token ? { token: ctx.token } : {});
148
+ }, ((_b = ctx.secrets) == null ? void 0 : _b.backstageToken) ? { token: ctx.secrets.backstageToken } : {});
148
149
  if (result.entities.length > 0) {
149
150
  const { entities } = result;
150
151
  let entity;
@@ -2023,7 +2024,8 @@ class DatabaseTaskStore {
2023
2024
  }
2024
2025
  const updateCount = await tx("tasks").where({ id: task.id, status: "open" }).update({
2025
2026
  status: "processing",
2026
- last_heartbeat_at: this.db.fn.now()
2027
+ last_heartbeat_at: this.db.fn.now(),
2028
+ secrets: null
2027
2029
  });
2028
2030
  if (updateCount < 1) {
2029
2031
  return void 0;
@@ -2087,8 +2089,7 @@ class DatabaseTaskStore {
2087
2089
  id: taskId,
2088
2090
  status: oldStatus
2089
2091
  }).update({
2090
- status,
2091
- secrets: null
2092
+ status
2092
2093
  });
2093
2094
  if (updateCount !== 1) {
2094
2095
  throw new errors.ConflictError(`Failed to update status to '${status}' for taskId ${taskId}`);
@@ -2301,7 +2302,7 @@ class HandlebarsWorkflowRunner {
2301
2302
  this.handlebars.registerHelper("eq", (a, b) => a === b);
2302
2303
  }
2303
2304
  async execute(task) {
2304
- var _a, _b;
2305
+ var _a, _b, _c;
2305
2306
  if (!isValidTaskSpec$1(task.spec)) {
2306
2307
  throw new errors.InputError(`Task spec is not a valid v1beta2 task spec`);
2307
2308
  }
@@ -2405,6 +2406,7 @@ class HandlebarsWorkflowRunner {
2405
2406
  logStream: stream$1,
2406
2407
  input,
2407
2408
  token: (_b = task.secrets) == null ? void 0 : _b.token,
2409
+ secrets: (_c = task.secrets) != null ? _c : {},
2408
2410
  workspacePath,
2409
2411
  async createTemporaryDirectory() {
2410
2412
  const tmpDir = await fs__default["default"].mkdtemp(`${workspacePath}_step-${step.id}-`);
@@ -2530,7 +2532,7 @@ class NunjucksWorkflowRunner {
2530
2532
  });
2531
2533
  }
2532
2534
  async execute(task) {
2533
- var _a, _b, _c;
2535
+ var _a, _b, _c, _d;
2534
2536
  if (!isValidTaskSpec(task.spec)) {
2535
2537
  throw new errors.InputError("Wrong template version executed with the workflow engine");
2536
2538
  }
@@ -2580,6 +2582,7 @@ class NunjucksWorkflowRunner {
2580
2582
  baseUrl: task.spec.baseUrl,
2581
2583
  input,
2582
2584
  token: (_c = task.secrets) == null ? void 0 : _c.token,
2585
+ secrets: (_d = task.secrets) != null ? _d : {},
2583
2586
  logger: taskLogger,
2584
2587
  logStream: streamLogger,
2585
2588
  workspacePath,
@@ -2861,6 +2864,8 @@ async function createRouter(options) {
2861
2864
  throw new errors.InputError(`Unsupported apiVersion field in schema entity, ${template.apiVersion}`);
2862
2865
  }
2863
2866
  const result = await taskBroker.dispatch(taskSpec, {
2867
+ ...req.body.secrets,
2868
+ backstageToken: token,
2864
2869
  token
2865
2870
  });
2866
2871
  res.status(201).json({ id: result.taskId });