@backstage/plugin-scaffolder-backend 1.13.2-next.2 → 1.14.1-next.0

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,64 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.14.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - cc936b529676: Fix handling of `optional` property in `catalog:register` scaffolder action
8
+ - b269da39ac2d: Clearer error messages for action `publish:gitlab:merge-request`
9
+ - Updated dependencies
10
+ - @backstage/catalog-client@1.4.2-next.0
11
+ - @backstage/plugin-catalog-backend@1.9.2-next.0
12
+ - @backstage/plugin-catalog-node@1.3.7-next.0
13
+ - @backstage/backend-common@0.18.6-next.0
14
+ - @backstage/integration@1.4.5
15
+ - @backstage/config@1.0.7
16
+ - @backstage/backend-plugin-api@0.5.3-next.0
17
+ - @backstage/backend-tasks@0.5.3-next.0
18
+ - @backstage/catalog-model@1.3.0
19
+ - @backstage/errors@1.1.5
20
+ - @backstage/types@1.0.2
21
+ - @backstage/plugin-auth-node@0.2.15-next.0
22
+ - @backstage/plugin-catalog-common@1.0.13
23
+ - @backstage/plugin-permission-common@0.7.5
24
+ - @backstage/plugin-permission-node@0.7.9-next.0
25
+ - @backstage/plugin-scaffolder-common@1.3.0
26
+ - @backstage/plugin-scaffolder-node@0.1.4-next.0
27
+
28
+ ## 1.14.0
29
+
30
+ ### Minor Changes
31
+
32
+ - 67115f532b8: Expose both types of scaffolder permissions and rules through the metadata endpoint.
33
+
34
+ The metadata endpoint now correctly exposes both types of scaffolder permissions and rules (for both the template and action resource types) through the metadata endpoint.
35
+
36
+ - a73b3c0b097: Add ability to use `defaultNamespace` and `defaultKind` for scaffolder action `catalog:fetch`
37
+
38
+ ### Patch Changes
39
+
40
+ - 1a48b84901c: Bump minimum required version of `vm2` to be 3.9.18
41
+ - d20c87966a4: Bump minimum required version of `vm2` to be 3.9.17
42
+ - 6d954de4b06: Update typing for `RouterOptions::actions` and `ScaffolderActionsExtensionPoint::addActions` to allow any kind of action being assigned to it.
43
+ - Updated dependencies
44
+ - @backstage/plugin-catalog-backend@1.9.1
45
+ - @backstage/backend-common@0.18.5
46
+ - @backstage/integration@1.4.5
47
+ - @backstage/plugin-scaffolder-common@1.3.0
48
+ - @backstage/plugin-permission-node@0.7.8
49
+ - @backstage/plugin-scaffolder-node@0.1.3
50
+ - @backstage/backend-tasks@0.5.2
51
+ - @backstage/plugin-auth-node@0.2.14
52
+ - @backstage/plugin-catalog-node@1.3.6
53
+ - @backstage/backend-plugin-api@0.5.2
54
+ - @backstage/catalog-client@1.4.1
55
+ - @backstage/catalog-model@1.3.0
56
+ - @backstage/config@1.0.7
57
+ - @backstage/errors@1.1.5
58
+ - @backstage/types@1.0.2
59
+ - @backstage/plugin-catalog-common@1.0.13
60
+ - @backstage/plugin-permission-common@0.7.5
61
+
3
62
  ## 1.13.2-next.2
4
63
 
5
64
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.13.2-next.2",
3
+ "version": "1.14.1-next.0",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.cjs.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
6
  var alpha = require('@backstage/plugin-catalog-node/alpha');
7
- var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-2f24bb9e.cjs.js');
7
+ var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-c40021d1.cjs.js');
8
8
  var alpha$1 = require('@backstage/plugin-scaffolder-common/alpha');
9
9
  var pluginPermissionNode = require('@backstage/plugin-permission-node');
10
10
  var backendCommon = require('@backstage/backend-common');
@@ -179,13 +179,19 @@ function createCatalogRegisterAction(options) {
179
179
  });
180
180
  }
181
181
  ctx.logger.info(`Registering ${catalogInfoUrl} in the catalog`);
182
- await catalogClient.addLocation(
183
- {
184
- type: "url",
185
- target: catalogInfoUrl
186
- },
187
- ((_a = ctx.secrets) == null ? void 0 : _a.backstageToken) ? { token: ctx.secrets.backstageToken } : {}
188
- );
182
+ try {
183
+ await catalogClient.addLocation(
184
+ {
185
+ type: "url",
186
+ target: catalogInfoUrl
187
+ },
188
+ ((_a = ctx.secrets) == null ? void 0 : _a.backstageToken) ? { token: ctx.secrets.backstageToken } : {}
189
+ );
190
+ } catch (e) {
191
+ if (!input.optional) {
192
+ throw e;
193
+ }
194
+ }
189
195
  try {
190
196
  const result = await catalogClient.addLocation(
191
197
  {
@@ -195,7 +201,7 @@ function createCatalogRegisterAction(options) {
195
201
  },
196
202
  ((_b = ctx.secrets) == null ? void 0 : _b.backstageToken) ? { token: ctx.secrets.backstageToken } : {}
197
203
  );
198
- if (result.entities.length > 0) {
204
+ if (result.entities.length) {
199
205
  const { entities } = result;
200
206
  let entity;
201
207
  entity = entities.find(
@@ -317,6 +323,7 @@ function createFetchCatalogEntityAction(options) {
317
323
  id: id$2,
318
324
  description: "Returns entity or entities from the catalog by entity reference(s)",
319
325
  examples: examples$2,
326
+ supportsDryRun: true,
320
327
  schema: {
321
328
  input: zod.z.object({
322
329
  entityRef: zod.z.string({
@@ -327,7 +334,9 @@ function createFetchCatalogEntityAction(options) {
327
334
  }).optional(),
328
335
  optional: zod.z.boolean({
329
336
  description: "Allow the entity or entities to optionally exist. Default: false"
330
- }).optional()
337
+ }).optional(),
338
+ defaultKind: zod.z.string({ description: "The default kind" }).optional(),
339
+ defaultNamespace: zod.z.string({ description: "The default namespace" }).optional()
331
340
  }),
332
341
  output: zod.z.object({
333
342
  entity: zod.z.any({
@@ -342,7 +351,7 @@ function createFetchCatalogEntityAction(options) {
342
351
  },
343
352
  async handler(ctx) {
344
353
  var _a, _b;
345
- const { entityRef, entityRefs, optional } = ctx.input;
354
+ const { entityRef, entityRefs, optional, defaultKind, defaultNamespace } = ctx.input;
346
355
  if (!entityRef && !entityRefs) {
347
356
  if (optional) {
348
357
  return;
@@ -350,9 +359,14 @@ function createFetchCatalogEntityAction(options) {
350
359
  throw new Error("Missing entity reference or references");
351
360
  }
352
361
  if (entityRef) {
353
- const entity = await catalogClient.getEntityByRef(entityRef, {
354
- token: (_a = ctx.secrets) == null ? void 0 : _a.backstageToken
355
- });
362
+ const entity = await catalogClient.getEntityByRef(
363
+ catalogModel.stringifyEntityRef(
364
+ catalogModel.parseEntityRef(entityRef, { defaultKind, defaultNamespace })
365
+ ),
366
+ {
367
+ token: (_a = ctx.secrets) == null ? void 0 : _a.backstageToken
368
+ }
369
+ );
356
370
  if (!entity && !optional) {
357
371
  throw new Error(`Entity ${entityRef} not found`);
358
372
  }
@@ -360,7 +374,13 @@ function createFetchCatalogEntityAction(options) {
360
374
  }
361
375
  if (entityRefs) {
362
376
  const entities = await catalogClient.getEntitiesByRefs(
363
- { entityRefs },
377
+ {
378
+ entityRefs: entityRefs.map(
379
+ (ref) => catalogModel.stringifyEntityRef(
380
+ catalogModel.parseEntityRef(ref, { defaultKind, defaultNamespace })
381
+ )
382
+ )
383
+ },
364
384
  {
365
385
  token: (_b = ctx.secrets) == null ? void 0 : _b.backstageToken
366
386
  }
@@ -4236,13 +4256,15 @@ const createPublishGitlabMergeRequestAction = (options) => {
4236
4256
  try {
4237
4257
  await api.Branches.create(repoID, branchName, String(defaultBranch));
4238
4258
  } catch (e) {
4239
- throw new errors.InputError(`The branch creation failed ${e}`);
4259
+ throw new errors.InputError(
4260
+ `The branch creation failed. Please check that your repo does not already contain a branch named '${branchName}'. ${e}`
4261
+ );
4240
4262
  }
4241
4263
  try {
4242
4264
  await api.Commits.create(repoID, branchName, ctx.input.title, actions);
4243
4265
  } catch (e) {
4244
4266
  throw new errors.InputError(
4245
- `Committing the changes to ${branchName} failed ${e}`
4267
+ `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${e}`
4246
4268
  );
4247
4269
  }
4248
4270
  try {
@@ -5622,6 +5644,12 @@ async function findTemplate(options) {
5622
5644
  return template;
5623
5645
  }
5624
5646
 
5647
+ function isTemplatePermissionRuleInput(permissionRule) {
5648
+ return permissionRule.resourceType === alpha.RESOURCE_TYPE_SCAFFOLDER_TEMPLATE;
5649
+ }
5650
+ function isActionPermissionRuleInput(permissionRule) {
5651
+ return permissionRule.resourceType === alpha.RESOURCE_TYPE_SCAFFOLDER_ACTION;
5652
+ }
5625
5653
  function isSupportedTemplate(entity) {
5626
5654
  return entity.apiVersion === "scaffolder.backstage.io/v1beta3";
5627
5655
  }
@@ -5753,14 +5781,29 @@ async function createRouter(options) {
5753
5781
  const templateRules = Object.values(
5754
5782
  scaffolderTemplateRules
5755
5783
  );
5784
+ const actionRules = Object.values(
5785
+ scaffolderActionRules
5786
+ );
5756
5787
  if (permissionRules) {
5757
- templateRules.push(...permissionRules);
5788
+ templateRules.push(
5789
+ ...permissionRules.filter(isTemplatePermissionRuleInput)
5790
+ );
5791
+ actionRules.push(...permissionRules.filter(isActionPermissionRuleInput));
5758
5792
  }
5759
5793
  const isAuthorized = pluginPermissionNode.createConditionAuthorizer(Object.values(templateRules));
5760
5794
  const permissionIntegrationRouter = pluginPermissionNode.createPermissionIntegrationRouter({
5761
- resourceType: alpha.RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
5762
- permissions: alpha.scaffolderPermissions,
5763
- rules: templateRules
5795
+ resources: [
5796
+ {
5797
+ resourceType: alpha.RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
5798
+ permissions: alpha.scaffolderTemplatePermissions,
5799
+ rules: templateRules
5800
+ },
5801
+ {
5802
+ resourceType: alpha.RESOURCE_TYPE_SCAFFOLDER_ACTION,
5803
+ permissions: alpha.scaffolderActionPermissions,
5804
+ rules: actionRules
5805
+ }
5806
+ ]
5764
5807
  });
5765
5808
  router.use(permissionIntegrationRouter);
5766
5809
  router.get(
@@ -6139,4 +6182,4 @@ exports.executeShellCommand = executeShellCommand;
6139
6182
  exports.fetchContents = fetchContents;
6140
6183
  exports.scaffolderActionRules = scaffolderActionRules;
6141
6184
  exports.scaffolderTemplateRules = scaffolderTemplateRules;
6142
- //# sourceMappingURL=ScaffolderEntitiesProcessor-2f24bb9e.cjs.js.map
6185
+ //# sourceMappingURL=ScaffolderEntitiesProcessor-c40021d1.cjs.js.map