From 7d7d94735237cd931093ad6dc26c43743b1967bd Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 25 Aug 2022 11:41:35 +0200 Subject: [PATCH 01/15] catalog-node: Export experimental catalogServiceRef Signed-off-by: Johan Haals --- .changeset/chatty-cars-kick.md | 5 ++ plugins/catalog-node/api-report.md | 5 ++ plugins/catalog-node/package.json | 6 +- .../catalog-node/src/catalogService.test.ts | 59 +++++++++++++++++++ plugins/catalog-node/src/catalogService.ts | 44 ++++++++++++++ plugins/catalog-node/src/index.ts | 1 + 6 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 .changeset/chatty-cars-kick.md create mode 100644 plugins/catalog-node/src/catalogService.test.ts create mode 100644 plugins/catalog-node/src/catalogService.ts diff --git a/.changeset/chatty-cars-kick.md b/.changeset/chatty-cars-kick.md new file mode 100644 index 0000000000..e6f0bbe965 --- /dev/null +++ b/.changeset/chatty-cars-kick.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-node': patch +--- + +Adds experimental catalogServiceRef for optaining a `catalogClient` in the new backend system diff --git a/plugins/catalog-node/api-report.md b/plugins/catalog-node/api-report.md index 26617910b9..7d12c2e065 100644 --- a/plugins/catalog-node/api-report.md +++ b/plugins/catalog-node/api-report.md @@ -5,10 +5,12 @@ ```ts /// +import { CatalogApi } from '@backstage/catalog-client'; import { CompoundEntityRef } from '@backstage/catalog-model'; import { Entity } from '@backstage/catalog-model'; import { ExtensionPoint } from '@backstage/backend-plugin-api'; import { JsonValue } from '@backstage/types'; +import { ServiceRef } from '@backstage/backend-plugin-api'; // @alpha (undocumented) export interface CatalogProcessingExtensionPoint { @@ -106,6 +108,9 @@ export type CatalogProcessorResult = | CatalogProcessorErrorResult | CatalogProcessorRefreshKeysResult; +// @alpha +export const catalogServiceRef: ServiceRef; + // @public export type DeferredEntity = { entity: Entity; diff --git a/plugins/catalog-node/package.json b/plugins/catalog-node/package.json index 10d1d9d2dd..0024899628 100644 --- a/plugins/catalog-node/package.json +++ b/plugins/catalog-node/package.json @@ -26,16 +26,18 @@ }, "dependencies": { "@backstage/backend-plugin-api": "^0.1.2-next.0", + "@backstage/catalog-client": "^1.0.5-next.0", "@backstage/catalog-model": "^1.1.0", "@backstage/errors": "1.1.0", "@backstage/types": "^1.0.0" }, "devDependencies": { "@backstage/backend-common": "^0.15.1-next.1", - "@backstage/cli": "^0.19.0-next.1" + "@backstage/cli": "^0.19.0-next.1", + "@backstage/backend-test-utils": "^0.1.28-next.1" }, "files": [ "dist", "alpha" ] -} +} \ No newline at end of file diff --git a/plugins/catalog-node/src/catalogService.test.ts b/plugins/catalog-node/src/catalogService.test.ts new file mode 100644 index 0000000000..3f11e8a9f0 --- /dev/null +++ b/plugins/catalog-node/src/catalogService.test.ts @@ -0,0 +1,59 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { PluginEndpointDiscovery } from '@backstage/backend-common'; +import { + createBackendModule, + createServiceFactory, + createServiceRef, +} from '@backstage/backend-plugin-api'; +import { startTestBackend } from '@backstage/backend-test-utils'; +import { CatalogClient } from '@backstage/catalog-client'; +import { catalogServiceRef } from './catalogService'; + +describe('catalogServiceRef', () => { + it('should return a catalogClient', async () => { + const mockDiscoveryFactory = createServiceFactory({ + service: createServiceRef({ + id: 'core.discovery', + }), + deps: {}, + factory: async ({}) => { + return async () => jest.fn() as unknown as PluginEndpointDiscovery; + }, + }); + + const testModule = createBackendModule({ + moduleId: 'test.module', + pluginId: 'test', + register(env) { + env.registerInit({ + deps: { + catalog: catalogServiceRef, + }, + async init({ catalog }) { + expect(catalog).toBeInstanceOf(CatalogClient); + }, + }); + }, + }); + + await startTestBackend({ + services: [mockDiscoveryFactory], + features: [testModule({})], + }); + }); +}); diff --git a/plugins/catalog-node/src/catalogService.ts b/plugins/catalog-node/src/catalogService.ts new file mode 100644 index 0000000000..ddfff75462 --- /dev/null +++ b/plugins/catalog-node/src/catalogService.ts @@ -0,0 +1,44 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + createServiceFactory, + createServiceRef, + discoveryServiceRef, +} from '@backstage/backend-plugin-api'; +import { CatalogApi, CatalogClient } from '@backstage/catalog-client'; + +/** + * The catalogService provides the catalog API. + * @alpha + */ +export const catalogServiceRef = createServiceRef({ + id: 'catalog-client', + defaultFactory: async service => + createServiceFactory({ + service, + deps: { + discoveryFactory: discoveryServiceRef, + }, + factory: async ({ discoveryFactory }) => { + const discoveryApi = await discoveryFactory('root'); + const catalogClient = new CatalogClient({ discoveryApi }); + return async _pluginId => { + return catalogClient; + }; + }, + }), +}); diff --git a/plugins/catalog-node/src/index.ts b/plugins/catalog-node/src/index.ts index 02ae325a9a..6393c55f31 100644 --- a/plugins/catalog-node/src/index.ts +++ b/plugins/catalog-node/src/index.ts @@ -22,5 +22,6 @@ export type { CatalogProcessingExtensionPoint } from './extensions'; export { catalogProcessingExtensionPoint } from './extensions'; +export { catalogServiceRef } from './catalogService'; export * from './api'; export * from './processing'; From cad2b01423183a5c108432b8658fa224e1e2ea72 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 25 Aug 2022 13:43:04 +0200 Subject: [PATCH 02/15] fix typo Signed-off-by: Johan Haals --- .changeset/chatty-cars-kick.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/chatty-cars-kick.md b/.changeset/chatty-cars-kick.md index e6f0bbe965..fa8553cf1a 100644 --- a/.changeset/chatty-cars-kick.md +++ b/.changeset/chatty-cars-kick.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog-node': patch --- -Adds experimental catalogServiceRef for optaining a `catalogClient` in the new backend system +Adds experimental catalogServiceRef for obtaining a `catalogClient` in the new backend system From 79373358f2e0a5580bb2d9fdb3737f8c93e17bfb Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 25 Aug 2022 13:51:21 +0200 Subject: [PATCH 03/15] reuse discoveryServiceRef Signed-off-by: Johan Haals --- plugins/catalog-node/src/catalogService.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/catalog-node/src/catalogService.test.ts b/plugins/catalog-node/src/catalogService.test.ts index 3f11e8a9f0..050f134a71 100644 --- a/plugins/catalog-node/src/catalogService.test.ts +++ b/plugins/catalog-node/src/catalogService.test.ts @@ -18,7 +18,7 @@ import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { createBackendModule, createServiceFactory, - createServiceRef, + discoveryServiceRef, } from '@backstage/backend-plugin-api'; import { startTestBackend } from '@backstage/backend-test-utils'; import { CatalogClient } from '@backstage/catalog-client'; @@ -27,9 +27,7 @@ import { catalogServiceRef } from './catalogService'; describe('catalogServiceRef', () => { it('should return a catalogClient', async () => { const mockDiscoveryFactory = createServiceFactory({ - service: createServiceRef({ - id: 'core.discovery', - }), + service: discoveryServiceRef, deps: {}, factory: async ({}) => { return async () => jest.fn() as unknown as PluginEndpointDiscovery; From 9c5cab8036a3e4ea0b124f9b7bdf520460613325 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Tue, 30 Aug 2022 14:31:20 +0200 Subject: [PATCH 04/15] chore: expect assertions Co-authored-by: blam Signed-off-by: Johan Haals --- plugins/catalog-node/src/catalogService.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/catalog-node/src/catalogService.test.ts b/plugins/catalog-node/src/catalogService.test.ts index 050f134a71..6e9426d48b 100644 --- a/plugins/catalog-node/src/catalogService.test.ts +++ b/plugins/catalog-node/src/catalogService.test.ts @@ -26,6 +26,8 @@ import { catalogServiceRef } from './catalogService'; describe('catalogServiceRef', () => { it('should return a catalogClient', async () => { + expect.assertions(1); + const mockDiscoveryFactory = createServiceFactory({ service: discoveryServiceRef, deps: {}, From ef875b07c330ba0163945bd0c8315e58b203e92e Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Tue, 30 Aug 2022 15:15:33 +0200 Subject: [PATCH 05/15] Add experimental ScaffolderPlugin Signed-off-by: Johan Haals --- .../src/ScaffolderPlugin.ts | 138 ++++++++++++++++++ plugins/scaffolder-backend/src/index.ts | 1 + 2 files changed, 139 insertions(+) create mode 100644 plugins/scaffolder-backend/src/ScaffolderPlugin.ts diff --git a/plugins/scaffolder-backend/src/ScaffolderPlugin.ts b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts new file mode 100644 index 0000000000..5f69484179 --- /dev/null +++ b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts @@ -0,0 +1,138 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + configServiceRef, + createBackendPlugin, + databaseServiceRef, + loggerServiceRef, + loggerToWinstonLogger, + permissionsServiceRef, + urlReaderServiceRef, + httpRouterServiceRef, + createExtensionPoint, +} from '@backstage/backend-plugin-api'; +import { ScmIntegrations } from '@backstage/integration'; +import { catalogServiceRef } from '@backstage/plugin-catalog-node'; +import { TemplateFilter } from './lib'; +import { createBuiltinActions, TaskBroker, TemplateAction } from './scaffolder'; +import { createRouter } from './service/router'; + +/** + * Catalog plugin options + * @alpha + */ +export type ScaffolderPluginOptions = { + actions?: TemplateAction[]; + taskWorkers?: number; + taskBroker?: TaskBroker; + additionalTemplateFilters?: Record; +}; + +/** + * @alpha + * TODO: MOVE to catalog-node before merge. + */ +interface ScaffolderActionsExtensionPoint { + addActions(...actions: TemplateAction[]): void; +} + +class ScaffolderActionsExtensionPointImpl + implements ScaffolderActionsExtensionPoint +{ + #actions = new Array>(); + addActions(...actions: TemplateAction[]): void { + this.#actions.push(...actions); + } + get actions() { + return this.#actions; + } +} + +/** + * @alpha + * TODO: MOVE to catalog-node before merge. + */ +export const scaffolderActionsExtensionPoint = + createExtensionPoint({ + id: 'scaffolder.actions', + }); + +/** + * Catalog plugin + * @alpha + */ +export const scaffolderPlugin = createBackendPlugin({ + id: 'scaffolder', + register(env, options: ScaffolderPluginOptions) { + const actionsExtensions = new ScaffolderActionsExtensionPointImpl(); + env.registerExtensionPoint( + scaffolderActionsExtensionPoint, + actionsExtensions, + ); + + env.registerInit({ + deps: { + logger: loggerServiceRef, + config: configServiceRef, + reader: urlReaderServiceRef, + permissions: permissionsServiceRef, + database: databaseServiceRef, + httpRouter: httpRouterServiceRef, + catalogClient: catalogServiceRef, + }, + async init({ + logger, + config, + reader, + database, + httpRouter, + catalogClient, + }) { + const { additionalTemplateFilters, taskBroker, taskWorkers } = options; + const log = loggerToWinstonLogger(logger); + + const actions = options.actions || [ + ...actionsExtensions.actions, + ...createBuiltinActions({ + integrations: ScmIntegrations.fromConfig(config), + catalogClient, + reader, + config, + additionalTemplateFilters, + }), + ]; + + const actionIds = actions.map(action => action.id).join(', '); + log.info( + `Starting scaffolder with the following actions enabled ${actionIds}`, + ); + + const router = await createRouter({ + logger: log, + config, + database, + catalogClient, + reader, + actions, + taskBroker, + taskWorkers, + additionalTemplateFilters, + }); + httpRouter.use(router); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend/src/index.ts b/plugins/scaffolder-backend/src/index.ts index a1032449d5..a511aa8776 100644 --- a/plugins/scaffolder-backend/src/index.ts +++ b/plugins/scaffolder-backend/src/index.ts @@ -25,3 +25,4 @@ export * from './service/router'; export * from './lib'; export * from './processor'; export * from './extension'; +export { scaffolderPlugin } from './ScaffolderPlugin'; From 405d485788664afb4892e3b5c89d97d71b9b8e7f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 30 Aug 2022 15:39:27 +0200 Subject: [PATCH 06/15] backend-app-api: fix ServiceRegistry instantiation race MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Co-authored-by: blam Co-authored-by: Johan Haals Signed-off-by: Patrik Oldsberg Signed-off-by: Johan Haals --- .../src/wiring/ServiceRegistry.test.ts | 27 +++++++++++ .../src/wiring/ServiceRegistry.ts | 48 +++++++++++-------- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/packages/backend-app-api/src/wiring/ServiceRegistry.test.ts b/packages/backend-app-api/src/wiring/ServiceRegistry.test.ts index acdd2a4c41..f66e430c40 100644 --- a/packages/backend-app-api/src/wiring/ServiceRegistry.test.ts +++ b/packages/backend-app-api/src/wiring/ServiceRegistry.test.ts @@ -170,4 +170,31 @@ describe('ServiceRegistry', () => { expect(await factoryB('catalog')).toBe(await factoryB('catalog')); expect(await factoryA('catalog')).not.toBe(await factoryB('catalog')); }); + + it('should not call factory functions more than once', async () => { + const innerFactory = jest.fn(async (pluginId: string) => { + return { x: 1, pluginId }; + }); + const factory = jest.fn(async () => innerFactory); + const myFactory = createServiceFactory({ + service: ref1, + deps: {}, + factory, + }); + + const registry = new ServiceRegistry([myFactory]); + + await Promise.all([ + registry.get(ref1)!('catalog')!, + registry.get(ref1)!('catalog')!, + registry.get(ref1)!('catalog')!, + registry.get(ref1)!('scaffolder')!, + registry.get(ref1)!('scaffolder')!, + ]); + + expect(factory).toHaveBeenCalledTimes(1); + expect(innerFactory).toHaveBeenCalledTimes(2); + expect(innerFactory).toHaveBeenCalledWith('catalog'); + expect(innerFactory).toHaveBeenCalledWith('scaffolder'); + }); }); diff --git a/packages/backend-app-api/src/wiring/ServiceRegistry.ts b/packages/backend-app-api/src/wiring/ServiceRegistry.ts index b471cd67ca..c99e92d761 100644 --- a/packages/backend-app-api/src/wiring/ServiceRegistry.ts +++ b/packages/backend-app-api/src/wiring/ServiceRegistry.ts @@ -22,7 +22,13 @@ import { export class ServiceRegistry { readonly #providedFactories: Map; readonly #loadedDefaultFactories: Map; - readonly #implementations: Map>; + readonly #implementations: Map< + ServiceFactory, + { + factoryFunc: Promise>; + byPlugin: Map>; + } + >; constructor(factories: ServiceFactory[]) { this.#providedFactories = new Map(factories.map(f => [f.service.id, f])); @@ -47,29 +53,31 @@ export class ServiceRegistry { factory = loadedFactory; } - let implementations = this.#implementations.get(factory); - if (implementations) { - if (implementations.has(pluginId)) { - return implementations.get(pluginId) as T; - } - } else { - implementations = new Map(); - this.#implementations.set(factory, implementations); + let implementation = this.#implementations.get(factory); + if (!implementation) { + const factoryDeps = Object.fromEntries( + Object.entries(factory.deps).map(([name, serviceRef]) => [ + name, + this.get(serviceRef)!, // TODO: throw + ]), + ); + + implementation = { + factoryFunc: factory.factory(factoryDeps), + byPlugin: new Map(), + }; + + this.#implementations.set(factory, implementation); } - const factoryDeps = Object.fromEntries( - Object.entries(factory.deps).map(([name, serviceRef]) => [ - name, - this.get(serviceRef)!, // TODO: throw - ]), - ); + let result = implementation.byPlugin.get(pluginId) as Promise; + if (!result) { + result = implementation.factoryFunc.then(func => func(pluginId)); - const factoryFunc = await factory.factory(factoryDeps); - const implementation = await factoryFunc(pluginId); + implementation.byPlugin.set(pluginId, result); + } - implementations.set(pluginId, implementation); - - return implementation as T; + return result; }; } } From 1338cca2f0f5906ced8c1554198f02a2ef8edaa1 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 30 Aug 2022 15:56:41 +0200 Subject: [PATCH 07/15] backend-app-api: fix ServiceRegistry default factory loader race MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Co-authored-by: blam Co-authored-by: Johan Haals Signed-off-by: Patrik Oldsberg Signed-off-by: Johan Haals --- .../src/wiring/ServiceRegistry.test.ts | 23 +++++++++++++++++++ .../src/wiring/ServiceRegistry.ts | 7 +++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/backend-app-api/src/wiring/ServiceRegistry.test.ts b/packages/backend-app-api/src/wiring/ServiceRegistry.test.ts index f66e430c40..d5b688c0de 100644 --- a/packages/backend-app-api/src/wiring/ServiceRegistry.test.ts +++ b/packages/backend-app-api/src/wiring/ServiceRegistry.test.ts @@ -17,6 +17,7 @@ import { createServiceRef, createServiceFactory, + ServiceRef, } from '@backstage/backend-plugin-api'; import { ServiceRegistry } from './ServiceRegistry'; @@ -171,6 +172,28 @@ describe('ServiceRegistry', () => { expect(await factoryA('catalog')).not.toBe(await factoryB('catalog')); }); + it('should only call each default factory loader once', async () => { + const factoryLoader = jest.fn(async (service: ServiceRef) => + createServiceFactory({ + service, + deps: {}, + factory: async () => async () => {}, + }), + ); + const ref = createServiceRef({ + id: '1', + defaultFactory: factoryLoader, + }); + + const registry = new ServiceRegistry([]); + const factory = registry.get(ref)!; + await Promise.all([ + expect(factory('catalog')).resolves.toBeUndefined(), + expect(factory('catalog')).resolves.toBeUndefined(), + ]); + expect(factoryLoader).toHaveBeenCalledTimes(1); + }); + it('should not call factory functions more than once', async () => { const innerFactory = jest.fn(async (pluginId: string) => { return { x: 1, pluginId }; diff --git a/packages/backend-app-api/src/wiring/ServiceRegistry.ts b/packages/backend-app-api/src/wiring/ServiceRegistry.ts index c99e92d761..9df092db42 100644 --- a/packages/backend-app-api/src/wiring/ServiceRegistry.ts +++ b/packages/backend-app-api/src/wiring/ServiceRegistry.ts @@ -21,7 +21,7 @@ import { export class ServiceRegistry { readonly #providedFactories: Map; - readonly #loadedDefaultFactories: Map; + readonly #loadedDefaultFactories: Map>; readonly #implementations: Map< ServiceFactory, { @@ -47,10 +47,11 @@ export class ServiceRegistry { if (!factory) { let loadedFactory = this.#loadedDefaultFactories.get(defaultFactory!); if (!loadedFactory) { - loadedFactory = (await defaultFactory!(ref)) as ServiceFactory; + loadedFactory = defaultFactory!(ref) as Promise; this.#loadedDefaultFactories.set(defaultFactory!, loadedFactory); } - factory = loadedFactory; + // NOTE: This await is safe as long as #providedFactories is not mutated. + factory = await loadedFactory; } let implementation = this.#implementations.get(factory); From 935fea481690b1db1f79f7e03481c3e14eb713c2 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 31 Aug 2022 13:30:48 +0200 Subject: [PATCH 08/15] chore: format Signed-off-by: Johan Haals --- plugins/catalog-node/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog-node/package.json b/plugins/catalog-node/package.json index 0024899628..1e4095b7d4 100644 --- a/plugins/catalog-node/package.json +++ b/plugins/catalog-node/package.json @@ -40,4 +40,4 @@ "dist", "alpha" ] -} \ No newline at end of file +} From 4d3778c4400ead602889abd83135a0881c7a2103 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 31 Aug 2022 13:35:48 +0200 Subject: [PATCH 09/15] scaffolder: export alpha ScaffolderPluginOptions Signed-off-by: Johan Haals --- plugins/scaffolder-backend/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/scaffolder-backend/src/index.ts b/plugins/scaffolder-backend/src/index.ts index a511aa8776..985ada405e 100644 --- a/plugins/scaffolder-backend/src/index.ts +++ b/plugins/scaffolder-backend/src/index.ts @@ -26,3 +26,4 @@ export * from './lib'; export * from './processor'; export * from './extension'; export { scaffolderPlugin } from './ScaffolderPlugin'; +export type { ScaffolderPluginOptions } from './ScaffolderPlugin'; From 2b54f5aea8111be02b2938ada64032587902324e Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 31 Aug 2022 13:36:08 +0200 Subject: [PATCH 10/15] update api report Signed-off-by: Johan Haals --- plugins/scaffolder-backend/api-report.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index da8782667e..75f7dc8ff5 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -419,7 +419,7 @@ export const createPublishGitlabMergeRequestAction: (options: { branchName: string; targetPath: string; token?: string | undefined; - commitAction?: 'update' | 'create' | 'delete' | undefined; + commitAction?: 'update' | 'delete' | 'create' | undefined; projectid?: string | undefined; removeSourceBranch?: boolean | undefined; assignee?: string | undefined; @@ -569,6 +569,19 @@ export class ScaffolderEntitiesProcessor implements CatalogProcessor { validateEntityKind(entity: Entity): Promise; } +// @alpha +export const scaffolderPlugin: ( + options: ScaffolderPluginOptions, +) => BackendFeature; + +// @alpha +export type ScaffolderPluginOptions = { + actions?: TemplateAction[]; + taskWorkers?: number; + taskBroker?: TaskBroker; + additionalTemplateFilters?: Record; +}; + // @public export type SerializedTask = { id: string; From 6b9f6c0a4d68d1f4e239b681d6e6394c0c49fea5 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 31 Aug 2022 13:36:58 +0200 Subject: [PATCH 11/15] Add scaffolder changeset Signed-off-by: Johan Haals --- .changeset/stupid-pigs-appear.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/stupid-pigs-appear.md diff --git a/.changeset/stupid-pigs-appear.md b/.changeset/stupid-pigs-appear.md new file mode 100644 index 0000000000..bd34f984d1 --- /dev/null +++ b/.changeset/stupid-pigs-appear.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Added alpha `scaffolderPlugin` to be used with experimental backend system. From af6bb42c6817b4ed1d648c3496a28090799a9809 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 31 Aug 2022 13:47:34 +0200 Subject: [PATCH 12/15] Add changeset Signed-off-by: Johan Haals --- .changeset/purple-jeans-bathe.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/purple-jeans-bathe.md diff --git a/.changeset/purple-jeans-bathe.md b/.changeset/purple-jeans-bathe.md new file mode 100644 index 0000000000..39706db2c4 --- /dev/null +++ b/.changeset/purple-jeans-bathe.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-app-api': patch +--- + +Updated `ServiceRegistry` to not initialize factories more than once. From f7c0ae7a36baf49eaa465b9d24b25a273ff4a277 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 31 Aug 2022 13:51:06 +0200 Subject: [PATCH 13/15] chore: Update API report Signed-off-by: Johan Haals --- plugins/scaffolder-backend/api-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 75f7dc8ff5..066b201918 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -419,7 +419,7 @@ export const createPublishGitlabMergeRequestAction: (options: { branchName: string; targetPath: string; token?: string | undefined; - commitAction?: 'update' | 'delete' | 'create' | undefined; + commitAction?: 'update' | 'create' | 'delete' | undefined; projectid?: string | undefined; removeSourceBranch?: boolean | undefined; assignee?: string | undefined; From 0883167bebf9c7b18c81565ce75ec7b54f3f80fe Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 31 Aug 2022 15:15:28 +0200 Subject: [PATCH 14/15] Update .changeset/chatty-cars-kick.md Co-authored-by: Patrik Oldsberg Signed-off-by: Johan Haals Signed-off-by: Johan Haals --- .changeset/chatty-cars-kick.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/chatty-cars-kick.md b/.changeset/chatty-cars-kick.md index fa8553cf1a..fcda65d0f7 100644 --- a/.changeset/chatty-cars-kick.md +++ b/.changeset/chatty-cars-kick.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog-node': patch --- -Adds experimental catalogServiceRef for obtaining a `catalogClient` in the new backend system +Adds experimental `catalogServiceRef` for obtaining a `CatalogClient` in the new backend system. From 903b473962fa25565ff1b2824ce2f18d4bda7e8f Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 31 Aug 2022 15:15:35 +0200 Subject: [PATCH 15/15] Update plugins/scaffolder-backend/src/ScaffolderPlugin.ts Co-authored-by: Patrik Oldsberg Signed-off-by: Johan Haals Signed-off-by: Johan Haals --- plugins/scaffolder-backend/src/ScaffolderPlugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/scaffolder-backend/src/ScaffolderPlugin.ts b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts index 5f69484179..b884802a1f 100644 --- a/plugins/scaffolder-backend/src/ScaffolderPlugin.ts +++ b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts @@ -43,7 +43,7 @@ export type ScaffolderPluginOptions = { /** * @alpha - * TODO: MOVE to catalog-node before merge. + * TODO: MOVE to scaffolder-node. */ interface ScaffolderActionsExtensionPoint { addActions(...actions: TemplateAction[]): void; @@ -63,7 +63,7 @@ class ScaffolderActionsExtensionPointImpl /** * @alpha - * TODO: MOVE to catalog-node before merge. + * TODO: MOVE to scaffolder-node. */ export const scaffolderActionsExtensionPoint = createExtensionPoint({