From a4bac3c25b354f8b0dda2065756c1e51827ba96c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 3 Sep 2024 13:14:00 +0200 Subject: [PATCH] removed the basePath of discovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/angry-hotels-warn.md | 6 ++++++ packages/backend-common/api-report.md | 7 +------ .../backend-common/src/deprecated/index.ts | 6 +++--- .../backend-defaults/api-report-discovery.md | 7 +------ .../discovery/HostDiscovery.test.ts | 19 ------------------- .../entrypoints/discovery/HostDiscovery.ts | 10 ++++------ 6 files changed, 15 insertions(+), 40 deletions(-) create mode 100644 .changeset/angry-hotels-warn.md diff --git a/.changeset/angry-hotels-warn.md b/.changeset/angry-hotels-warn.md new file mode 100644 index 0000000000..07caaba574 --- /dev/null +++ b/.changeset/angry-hotels-warn.md @@ -0,0 +1,6 @@ +--- +'@backstage/backend-defaults': minor +'@backstage/backend-common': minor +--- + +**BREAKING**: You can no longer supply a `basePath` option to the host discovery implementation. In the new backend system, the ability to choose this path has been removed anyway at the plugin router level. diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index 4a59277e37..1a67d4877f 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -277,12 +277,7 @@ export class Git { // @public @deprecated class HostDiscovery implements DiscoveryService { - static fromConfig( - config: Config, - options?: { - basePath?: string; - }, - ): HostDiscovery; + static fromConfig(config: Config): HostDiscovery; // (undocumented) getBaseUrl(pluginId: string): Promise; // (undocumented) diff --git a/packages/backend-common/src/deprecated/index.ts b/packages/backend-common/src/deprecated/index.ts index c7ba186df4..f769d4db09 100644 --- a/packages/backend-common/src/deprecated/index.ts +++ b/packages/backend-common/src/deprecated/index.ts @@ -96,11 +96,11 @@ export class HostDiscovery implements DiscoveryService { * plugins: [search] * ``` * - * The basePath defaults to `/api`, meaning the default full internal + * The fixed base path is `/api`, meaning the default full internal * path for the `catalog` plugin will be `http://localhost:7007/api/catalog`. */ - static fromConfig(config: Config, options?: { basePath?: string }) { - return new HostDiscovery(_HostDiscovery.fromConfig(config, options)); + static fromConfig(config: Config) { + return new HostDiscovery(_HostDiscovery.fromConfig(config)); } private constructor(private readonly impl: _HostDiscovery) {} diff --git a/packages/backend-defaults/api-report-discovery.md b/packages/backend-defaults/api-report-discovery.md index f12daf49c1..d168d33a71 100644 --- a/packages/backend-defaults/api-report-discovery.md +++ b/packages/backend-defaults/api-report-discovery.md @@ -16,12 +16,7 @@ export const discoveryServiceFactory: ServiceFactory< // @public export class HostDiscovery implements DiscoveryService { - static fromConfig( - config: RootConfigService, - options?: { - basePath?: string; - }, - ): HostDiscovery; + static fromConfig(config: RootConfigService): HostDiscovery; // (undocumented) getBaseUrl(pluginId: string): Promise; // (undocumented) diff --git a/packages/backend-defaults/src/entrypoints/discovery/HostDiscovery.test.ts b/packages/backend-defaults/src/entrypoints/discovery/HostDiscovery.test.ts index 4e6aff5853..e4e30044dd 100644 --- a/packages/backend-defaults/src/entrypoints/discovery/HostDiscovery.test.ts +++ b/packages/backend-defaults/src/entrypoints/discovery/HostDiscovery.test.ts @@ -54,25 +54,6 @@ describe('HostDiscovery', () => { ); }); - it('can configure the base path', async () => { - const discovery = HostDiscovery.fromConfig( - new ConfigReader({ - backend: { - baseUrl: 'http://localhost:40', - listen: { port: 80, host: 'localhost' }, - }, - }), - { basePath: '/service' }, - ); - - await expect(discovery.getBaseUrl('catalog')).resolves.toBe( - 'http://localhost:80/service/catalog', - ); - await expect(discovery.getExternalBaseUrl('catalog')).resolves.toBe( - 'http://localhost:40/service/catalog', - ); - }); - it.each([ [{ listen: ':80' }, 'http://localhost:80'], [{ listen: ':40', https: true }, 'https://localhost:40'], diff --git a/packages/backend-defaults/src/entrypoints/discovery/HostDiscovery.ts b/packages/backend-defaults/src/entrypoints/discovery/HostDiscovery.ts index 26e2a01a23..47793c82f7 100644 --- a/packages/backend-defaults/src/entrypoints/discovery/HostDiscovery.ts +++ b/packages/backend-defaults/src/entrypoints/discovery/HostDiscovery.ts @@ -42,6 +42,7 @@ export class HostDiscovery implements DiscoveryService { * * Can be overridden in config by providing a target and corresponding plugins in `discovery.endpoints`. * eg. + * * ```yaml * discovery: * endpoints: @@ -55,14 +56,11 @@ export class HostDiscovery implements DiscoveryService { * plugins: [search] * ``` * - * The basePath defaults to `/api`, meaning the default full internal + * The fixed base path is `/api`, meaning the default full internal * path for the `catalog` plugin will be `http://localhost:7007/api/catalog`. */ - static fromConfig( - config: RootConfigService, - options?: { basePath?: string }, - ) { - const basePath = options?.basePath ?? '/api'; + static fromConfig(config: RootConfigService) { + const basePath = '/api'; const externalBaseUrl = config .getString('backend.baseUrl') .replace(/\/+$/, '');