@backstage/plugin-scaffolder-backend 1.3.0-next.2 → 1.4.0-next.1

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,79 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.4.0-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 801d606909: Improve error messaging when passing in malformed auth
8
+ - Updated dependencies
9
+ - @backstage/catalog-model@1.1.0-next.1
10
+ - @backstage/backend-common@0.14.1-next.1
11
+ - @backstage/errors@1.1.0-next.0
12
+ - @backstage/plugin-catalog-backend@1.2.1-next.1
13
+ - @backstage/catalog-client@1.0.4-next.1
14
+ - @backstage/integration@1.2.2-next.1
15
+
16
+ ## 1.4.0-next.0
17
+
18
+ ### Minor Changes
19
+
20
+ - 3500c13a33: Added a new `/v2/dry-run` endpoint that allows for a synchronous dry run of a provided template. A `supportsDryRun` option has been added to `createTemplateAction`, which signals whether the action should be executed during dry runs. When enabled, the action context will have the new `isDryRun` property set to signal if the action is being executed during a dry run.
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+ - @backstage/backend-common@0.14.1-next.0
26
+ - @backstage/catalog-model@1.1.0-next.0
27
+ - @backstage/integration@1.2.2-next.0
28
+ - @backstage/plugin-catalog-backend@1.2.1-next.0
29
+ - @backstage/catalog-client@1.0.4-next.0
30
+ - @backstage/plugin-scaffolder-common@1.1.2-next.0
31
+
32
+ ## 1.3.0
33
+
34
+ ### Minor Changes
35
+
36
+ - 35a26131b3: **DEPRECATION**: The `projectid` input parameters to the `publish:gitlab:merge-request`, it's no longer required as it can be decoded from the `repoUrl` input parameter.
37
+ **DEPRECATION**: The `projectid` output of the action in favour of `projectPath`
38
+ - 72dfcbc8bf: A new scaffolder action has been added: `gerrit:publish`
39
+ - ce0d8d7eb1: Fixed a bug in `publish:github` action that didn't permit to add users as collaborators.
40
+ This fix required changing the way parameters are passed to the action.
41
+ In order to add a team as collaborator, now you must use the `team` field instead of `username`.
42
+ In order to add a user as collaborator, you must use the `user` field.
43
+
44
+ It's still possible to use the field `username` but is deprecated in favor of `team`.
45
+
46
+ ```yaml
47
+ - id: publish
48
+ name: Publish
49
+ action: publish:github
50
+ input:
51
+ repoUrl: ...
52
+ collaborators:
53
+ - access: ...
54
+ team: my_team
55
+ - access: ...
56
+ user: my_username
57
+ ```
58
+
59
+ - 582003a059: - Added an optional `list` method on the `TaskBroker` and `TaskStore` interface to list tasks by an optional `userEntityRef`
60
+ - Implemented a `list` method on the `DatabaseTaskStore` class to list tasks by an optional `userEntityRef`
61
+ - Added a route under `/v2/tasks` to list tasks by a `userEntityRef` using the `createdBy` query parameter
62
+ - c042c5eaff: Add an option to not protect the default branch.
63
+ - f93af969cd: Added the ability to support running of templates that are not in the `default` namespace
64
+
65
+ ### Patch Changes
66
+
67
+ - 8f7b1835df: Updated dependency `msw` to `^0.41.0`.
68
+ - 6901f6be4a: Adds more of an explanation when the `publish:github` scaffolder action fails to create a repository.
69
+ - Updated dependencies
70
+ - @backstage/plugin-catalog-backend@1.2.0
71
+ - @backstage/backend-common@0.14.0
72
+ - @backstage/integration@1.2.1
73
+ - @backstage/catalog-client@1.0.3
74
+ - @backstage/catalog-model@1.0.3
75
+ - @backstage/plugin-scaffolder-common@1.1.1
76
+
3
77
  ## 1.3.0-next.2
4
78
 
5
79
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -2416,7 +2416,7 @@ const createPublishGitlabMergeRequestAction = (options) => {
2416
2416
  id: "publish:gitlab:merge-request",
2417
2417
  schema: {
2418
2418
  input: {
2419
- required: ["projectid", "repoUrl", "targetPath", "branchName"],
2419
+ required: ["repoUrl", "targetPath", "branchName"],
2420
2420
  type: "object",
2421
2421
  properties: {
2422
2422
  repoUrl: {
@@ -2463,6 +2463,10 @@ const createPublishGitlabMergeRequestAction = (options) => {
2463
2463
  title: "Gitlab Project id/Name(slug)",
2464
2464
  type: "string"
2465
2465
  },
2466
+ projectPath: {
2467
+ title: "Gitlab Project path",
2468
+ type: "string"
2469
+ },
2466
2470
  mergeRequestURL: {
2467
2471
  title: "MergeRequest(MR) URL",
2468
2472
  type: "string",
@@ -2474,7 +2478,13 @@ const createPublishGitlabMergeRequestAction = (options) => {
2474
2478
  async handler(ctx) {
2475
2479
  var _a;
2476
2480
  const repoUrl = ctx.input.repoUrl;
2477
- const { host } = parseRepoUrl(repoUrl, integrations);
2481
+ const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);
2482
+ const projectPath = `${owner}/${repo}`;
2483
+ if (ctx.input.projectid) {
2484
+ const deprecationWarning = `Property "projectid" is deprecated and no longer to needed to create a MR`;
2485
+ ctx.logger.warn(deprecationWarning);
2486
+ console.warn(deprecationWarning);
2487
+ }
2478
2488
  const integrationConfig = integrations.gitlab.byHost(host);
2479
2489
  const destinationBranch = ctx.input.branchName;
2480
2490
  if (!integrationConfig) {
@@ -2500,23 +2510,24 @@ const createPublishGitlabMergeRequestAction = (options) => {
2500
2510
  content: file.content.toString("base64"),
2501
2511
  execute_filemode: file.executable
2502
2512
  }));
2503
- const projects = await api.Projects.show(ctx.input.projectid);
2513
+ const projects = await api.Projects.show(projectPath);
2504
2514
  const { default_branch: defaultBranch } = projects;
2505
2515
  try {
2506
- await api.Branches.create(ctx.input.projectid, destinationBranch, String(defaultBranch));
2516
+ await api.Branches.create(projectPath, destinationBranch, String(defaultBranch));
2507
2517
  } catch (e) {
2508
2518
  throw new errors.InputError(`The branch creation failed ${e}`);
2509
2519
  }
2510
2520
  try {
2511
- await api.Commits.create(ctx.input.projectid, destinationBranch, ctx.input.title, actions);
2521
+ await api.Commits.create(projectPath, destinationBranch, ctx.input.title, actions);
2512
2522
  } catch (e) {
2513
2523
  throw new errors.InputError(`Committing the changes to ${destinationBranch} failed ${e}`);
2514
2524
  }
2515
2525
  try {
2516
- const mergeRequestUrl = await api.MergeRequests.create(ctx.input.projectid, destinationBranch, String(defaultBranch), ctx.input.title, { description: ctx.input.description }).then((mergeRequest) => {
2526
+ const mergeRequestUrl = await api.MergeRequests.create(projectPath, destinationBranch, String(defaultBranch), ctx.input.title, { description: ctx.input.description }).then((mergeRequest) => {
2517
2527
  return mergeRequest.web_url;
2518
2528
  });
2519
- ctx.output("projectid", ctx.input.projectid);
2529
+ ctx.output("projectid", projectPath);
2530
+ ctx.output("projectPath", projectPath);
2520
2531
  ctx.output("mergeRequestUrl", mergeRequestUrl);
2521
2532
  } catch (e) {
2522
2533
  throw new errors.InputError(`Merge request creation failed${e}`);
@@ -3590,9 +3601,6 @@ function getEntityBaseUrl(entity) {
3590
3601
  }
3591
3602
  async function findTemplate(options) {
3592
3603
  const { entityRef, token, catalogApi } = options;
3593
- if (entityRef.namespace.toLocaleLowerCase("en-US") !== catalogModel.DEFAULT_NAMESPACE) {
3594
- throw new errors.InputError(`Invalid namespace, only '${catalogModel.DEFAULT_NAMESPACE}' namespace is supported`);
3595
- }
3596
3604
  if (entityRef.kind.toLocaleLowerCase("en-US") !== "template") {
3597
3605
  throw new errors.InputError(`Invalid kind, only 'Template' kind is supported`);
3598
3606
  }
@@ -3890,15 +3898,27 @@ data: ${JSON.stringify(event)}
3890
3898
  }
3891
3899
  function parseBearerToken(header) {
3892
3900
  var _a;
3893
- const token = (_a = header == null ? void 0 : header.match(/Bearer\s+(\S+)/i)) == null ? void 0 : _a[1];
3894
- if (!token)
3901
+ if (!header) {
3895
3902
  return {};
3896
- const [_header, rawPayload, _signature] = token.split(".");
3897
- const payload = JSON.parse(Buffer.from(rawPayload, "base64").toString());
3898
- return {
3899
- entityRef: payload.sub,
3900
- token
3901
- };
3903
+ }
3904
+ try {
3905
+ const token = (_a = header.match(/^Bearer\s(\S+\.\S+\.\S+)$/i)) == null ? void 0 : _a[1];
3906
+ if (!token) {
3907
+ throw new TypeError("Expected Bearer with JWT");
3908
+ }
3909
+ const [_header, rawPayload, _signature] = token.split(".");
3910
+ const payload = JSON.parse(Buffer.from(rawPayload, "base64").toString());
3911
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
3912
+ throw new TypeError("Malformed JWT payload");
3913
+ }
3914
+ const sub = payload.sub;
3915
+ if (typeof sub !== "string") {
3916
+ throw new TypeError("Expected string sub claim");
3917
+ }
3918
+ return { entityRef: sub, token };
3919
+ } catch (e) {
3920
+ throw new errors.InputError(`Invalid authorization header: ${errors.stringifyError(e)}`);
3921
+ }
3902
3922
  }
3903
3923
 
3904
3924
  class ScaffolderEntitiesProcessor {