@backstage/plugin-scaffolder-backend 1.12.0-next.1 → 1.12.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 +49 -0
- package/README.md +1 -1
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +71 -26
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/index.cjs.js +71 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
+
## 1.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7d724d8ef56: Added the ability to be able to define an actions `input` and `output` schema using `zod` instead of hand writing types and `jsonschema`
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 860de10fa67: Make identity valid if subject of token is a backstage server-2-server auth token
|
|
12
|
+
- 65454876fb2: Minor API report tweaks
|
|
13
|
+
- c6c78b4acbe: throw error from catalog:fetch scaffolder action when entity is null and optional is false
|
|
14
|
+
- 9968f455921: catalog write action should allow any shape of object
|
|
15
|
+
- 928a12a9b3e: Internal refactor of `/alpha` exports.
|
|
16
|
+
- 52b0022dab7: Updated dependency `msw` to `^1.0.0`.
|
|
17
|
+
- 7af12854970: Extended scaffolder action `catalog:fetch` to fetch multiple catalog entities by entity references.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/plugin-catalog-backend@1.8.0
|
|
20
|
+
- @backstage/catalog-client@1.4.0
|
|
21
|
+
- @backstage/plugin-auth-node@0.2.12
|
|
22
|
+
- @backstage/backend-tasks@0.5.0
|
|
23
|
+
- @backstage/backend-common@0.18.3
|
|
24
|
+
- @backstage/errors@1.1.5
|
|
25
|
+
- @backstage/plugin-catalog-node@1.3.4
|
|
26
|
+
- @backstage/backend-plugin-api@0.5.0
|
|
27
|
+
- @backstage/catalog-model@1.2.1
|
|
28
|
+
- @backstage/integration@1.4.3
|
|
29
|
+
- @backstage/config@1.0.7
|
|
30
|
+
- @backstage/types@1.0.2
|
|
31
|
+
- @backstage/plugin-scaffolder-common@1.2.6
|
|
32
|
+
- @backstage/plugin-scaffolder-node@0.1.1
|
|
33
|
+
|
|
34
|
+
## 1.12.0-next.2
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- 860de10fa67: Make identity valid if subject of token is a backstage server-2-server auth token
|
|
39
|
+
- 65454876fb2: Minor API report tweaks
|
|
40
|
+
- 9968f455921: catalog write action should allow any shape of object
|
|
41
|
+
- Updated dependencies
|
|
42
|
+
- @backstage/plugin-auth-node@0.2.12-next.2
|
|
43
|
+
- @backstage/backend-tasks@0.5.0-next.2
|
|
44
|
+
- @backstage/backend-common@0.18.3-next.2
|
|
45
|
+
- @backstage/backend-plugin-api@0.4.1-next.2
|
|
46
|
+
- @backstage/plugin-catalog-backend@1.8.0-next.2
|
|
47
|
+
- @backstage/plugin-catalog-node@1.3.4-next.2
|
|
48
|
+
- @backstage/plugin-scaffolder-node@0.1.1-next.2
|
|
49
|
+
- @backstage/config@1.0.7-next.0
|
|
50
|
+
- @backstage/integration@1.4.3-next.0
|
|
51
|
+
|
|
3
52
|
## 1.12.0-next.1
|
|
4
53
|
|
|
5
54
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Scaffolder Backend
|
|
2
2
|
|
|
3
3
|
This is the backend for the default Backstage [software
|
|
4
|
-
templates](https://backstage.io/docs/features/software-templates/
|
|
4
|
+
templates](https://backstage.io/docs/features/software-templates/).
|
|
5
5
|
This provides the API for the frontend [scaffolder
|
|
6
6
|
plugin](https://github.com/backstage/backstage/tree/master/plugins/scaffolder),
|
|
7
7
|
as well as the built-in template actions, tasks and stages.
|
package/alpha/package.json
CHANGED
package/dist/alpha.cjs.js
CHANGED
|
@@ -326,7 +326,7 @@ function createCatalogWriteAction() {
|
|
|
326
326
|
input: zod.z.object({
|
|
327
327
|
filePath: zod.z.string().optional().describe("Defaults to catalog-info.yaml"),
|
|
328
328
|
// TODO: this should reference an zod entity validator if it existed.
|
|
329
|
-
entity: zod.z.object({}).describe(
|
|
329
|
+
entity: zod.z.object({}).passthrough().describe(
|
|
330
330
|
"You can provide the same values used in the Entity schema."
|
|
331
331
|
)
|
|
332
332
|
})
|
|
@@ -361,17 +361,31 @@ const examples$1 = [
|
|
|
361
361
|
}
|
|
362
362
|
]
|
|
363
363
|
})
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
description: "Fetch multiple entities by referencse",
|
|
367
|
+
example: yaml__default["default"].stringify({
|
|
368
|
+
steps: [
|
|
369
|
+
{
|
|
370
|
+
action: id$1,
|
|
371
|
+
id: "fetchMultiple",
|
|
372
|
+
name: "Fetch catalog entities",
|
|
373
|
+
input: {
|
|
374
|
+
entityRefs: ["component:default/name"]
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
})
|
|
364
379
|
}
|
|
365
380
|
];
|
|
366
381
|
function createFetchCatalogEntityAction(options) {
|
|
367
382
|
const { catalogClient } = options;
|
|
368
383
|
return pluginScaffolderNode.createTemplateAction({
|
|
369
384
|
id: id$1,
|
|
370
|
-
description: "Returns entity from the catalog by entity reference",
|
|
385
|
+
description: "Returns entity or entities from the catalog by entity reference(s)",
|
|
371
386
|
examples: examples$1,
|
|
372
387
|
schema: {
|
|
373
388
|
input: {
|
|
374
|
-
required: ["entityRef"],
|
|
375
389
|
type: "object",
|
|
376
390
|
properties: {
|
|
377
391
|
entityRef: {
|
|
@@ -379,9 +393,14 @@ function createFetchCatalogEntityAction(options) {
|
|
|
379
393
|
title: "Entity reference",
|
|
380
394
|
description: "Entity reference of the entity to get"
|
|
381
395
|
},
|
|
396
|
+
entityRefs: {
|
|
397
|
+
type: "array",
|
|
398
|
+
title: "Entity references",
|
|
399
|
+
description: "Entity references of the entities to get"
|
|
400
|
+
},
|
|
382
401
|
optional: {
|
|
383
402
|
title: "Optional",
|
|
384
|
-
description: "
|
|
403
|
+
description: "Allow the entity or entities to optionally exist. Default: false",
|
|
385
404
|
type: "boolean"
|
|
386
405
|
}
|
|
387
406
|
}
|
|
@@ -392,28 +411,50 @@ function createFetchCatalogEntityAction(options) {
|
|
|
392
411
|
entity: {
|
|
393
412
|
title: "Entity found by the entity reference",
|
|
394
413
|
type: "object",
|
|
395
|
-
description: "Object containing same values used in the Entity schema."
|
|
414
|
+
description: "Object containing same values used in the Entity schema. Only when used with `entityRef` parameter."
|
|
415
|
+
},
|
|
416
|
+
entities: {
|
|
417
|
+
title: "Entities found by the entity references",
|
|
418
|
+
type: "array",
|
|
419
|
+
items: { type: "object" },
|
|
420
|
+
description: "Array containing objects with same values used in the Entity schema. Only when used with `entityRefs` parameter."
|
|
396
421
|
}
|
|
397
422
|
}
|
|
398
423
|
}
|
|
399
424
|
},
|
|
400
425
|
async handler(ctx) {
|
|
401
|
-
var _a;
|
|
402
|
-
const { entityRef, optional } = ctx.input;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
426
|
+
var _a, _b;
|
|
427
|
+
const { entityRef, entityRefs, optional } = ctx.input;
|
|
428
|
+
if (!entityRef && !entityRefs) {
|
|
429
|
+
if (optional) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
throw new Error("Missing entity reference or references");
|
|
433
|
+
}
|
|
434
|
+
if (entityRef) {
|
|
435
|
+
const entity = await catalogClient.getEntityByRef(entityRef, {
|
|
406
436
|
token: (_a = ctx.secrets) == null ? void 0 : _a.backstageToken
|
|
407
437
|
});
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
throw e;
|
|
438
|
+
if (!entity && !optional) {
|
|
439
|
+
throw new Error(`Entity ${entityRef} not found`);
|
|
411
440
|
}
|
|
441
|
+
ctx.output("entity", entity != null ? entity : null);
|
|
412
442
|
}
|
|
413
|
-
if (
|
|
414
|
-
|
|
443
|
+
if (entityRefs) {
|
|
444
|
+
const entities = await catalogClient.getEntitiesByRefs(
|
|
445
|
+
{ entityRefs },
|
|
446
|
+
{
|
|
447
|
+
token: (_b = ctx.secrets) == null ? void 0 : _b.backstageToken
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
const finalEntities = entities.items.map((e, i) => {
|
|
451
|
+
if (!e && !optional) {
|
|
452
|
+
throw new Error(`Entity ${entityRefs[i]} not found`);
|
|
453
|
+
}
|
|
454
|
+
return e != null ? e : null;
|
|
455
|
+
});
|
|
456
|
+
ctx.output("entities", finalEntities);
|
|
415
457
|
}
|
|
416
|
-
ctx.output("entity", entity != null ? entity : null);
|
|
417
458
|
}
|
|
418
459
|
});
|
|
419
460
|
}
|
|
@@ -3528,11 +3569,12 @@ const defaultClientFactory = async ({
|
|
|
3528
3569
|
...{ throttle: { enabled: false } }
|
|
3529
3570
|
});
|
|
3530
3571
|
};
|
|
3531
|
-
const createPublishGithubPullRequestAction = ({
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3572
|
+
const createPublishGithubPullRequestAction = (options) => {
|
|
3573
|
+
const {
|
|
3574
|
+
integrations,
|
|
3575
|
+
githubCredentialsProvider,
|
|
3576
|
+
clientFactory = defaultClientFactory
|
|
3577
|
+
} = options;
|
|
3536
3578
|
return pluginScaffolderNode.createTemplateAction({
|
|
3537
3579
|
id: "publish:github:pull-request",
|
|
3538
3580
|
schema: {
|
|
@@ -4428,7 +4470,8 @@ class DatabaseTaskStore {
|
|
|
4428
4470
|
});
|
|
4429
4471
|
return { events };
|
|
4430
4472
|
}
|
|
4431
|
-
async shutdownTask(
|
|
4473
|
+
async shutdownTask(options) {
|
|
4474
|
+
const { taskId } = options;
|
|
4432
4475
|
const message = `This task was marked as stale as it exceeded its timeout`;
|
|
4433
4476
|
const statusStepEvents = (await this.listEvents({ taskId })).events.filter(
|
|
4434
4477
|
({ body }) => body == null ? void 0 : body.stepId
|
|
@@ -5233,13 +5276,12 @@ async function findTemplate(options) {
|
|
|
5233
5276
|
function isSupportedTemplate(entity) {
|
|
5234
5277
|
return entity.apiVersion === "scaffolder.backstage.io/v1beta3";
|
|
5235
5278
|
}
|
|
5236
|
-
function buildDefaultIdentityClient({
|
|
5237
|
-
logger
|
|
5238
|
-
}) {
|
|
5279
|
+
function buildDefaultIdentityClient(options) {
|
|
5239
5280
|
return {
|
|
5240
5281
|
getIdentity: async ({ request }) => {
|
|
5241
5282
|
var _a;
|
|
5242
5283
|
const header = request.headers.authorization;
|
|
5284
|
+
const { logger } = options;
|
|
5243
5285
|
if (!header) {
|
|
5244
5286
|
return void 0;
|
|
5245
5287
|
}
|
|
@@ -5259,6 +5301,9 @@ function buildDefaultIdentityClient({
|
|
|
5259
5301
|
if (typeof sub !== "string") {
|
|
5260
5302
|
throw new TypeError("Expected string sub claim");
|
|
5261
5303
|
}
|
|
5304
|
+
if (sub === "backstage-server") {
|
|
5305
|
+
return void 0;
|
|
5306
|
+
}
|
|
5262
5307
|
catalogModel.parseEntityRef(sub);
|
|
5263
5308
|
return {
|
|
5264
5309
|
identity: {
|
|
@@ -5292,7 +5337,7 @@ async function createRouter(options) {
|
|
|
5292
5337
|
additionalTemplateGlobals
|
|
5293
5338
|
} = options;
|
|
5294
5339
|
const logger = parentLogger.child({ plugin: "scaffolder" });
|
|
5295
|
-
const identity = options.identity || buildDefaultIdentityClient(
|
|
5340
|
+
const identity = options.identity || buildDefaultIdentityClient(options);
|
|
5296
5341
|
const workingDirectory = await getWorkingDirectory(config, logger);
|
|
5297
5342
|
const integrations = integration.ScmIntegrations.fromConfig(config);
|
|
5298
5343
|
let taskBroker;
|