From f509643e62e8beecacbd5b1e995ce327dd806ba7 Mon Sep 17 00:00:00 2001 From: ivangonzalezacuna Date: Mon, 9 Sep 2024 09:12:11 +0200 Subject: [PATCH] Fix some deprecations and deprecate old backend system As described here: https://github.com/backstage/community-plugins/issues/1176 --- .changeset/cool-rockets-confess.md | 10 ++++++++++ plugins/s3-viewer-backend/config.d.ts | 6 ++++-- plugins/s3-viewer-backend/src/run.ts | 4 ++-- plugins/s3-viewer-backend/src/service/router.ts | 4 ++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 .changeset/cool-rockets-confess.md diff --git a/.changeset/cool-rockets-confess.md b/.changeset/cool-rockets-confess.md new file mode 100644 index 0000000..e23f08c --- /dev/null +++ b/.changeset/cool-rockets-confess.md @@ -0,0 +1,10 @@ +--- +'@spreadshirt/backstage-plugin-s3-viewer-backend': patch +--- + +Replace some deprecations caused by the removal of the backend-tasks plugin and deprecate old backend system. + +The old backend system calls will be completely removed in the next release, so +none of the deprecations caused by these functions are going to be addressed. + +More info about this process [in this issue](https://github.com/backstage/community-plugins/issues/1176). diff --git a/plugins/s3-viewer-backend/config.d.ts b/plugins/s3-viewer-backend/config.d.ts index d441e96..eb00764 100644 --- a/plugins/s3-viewer-backend/config.d.ts +++ b/plugins/s3-viewer-backend/config.d.ts @@ -1,4 +1,4 @@ -import { TaskScheduleDefinitionConfig } from '@backstage/backend-tasks'; +import { SchedulerServiceTaskScheduleDefinitionConfig } from '@backstage/backend-plugin-api'; /** Configuration for the S3 Viewer plugin */ export interface Config { @@ -7,7 +7,9 @@ export interface Config { * If defined, it sets the schedule used to refresh the list of buckets * @visibility backend * */ - bucketRefreshSchedule: TaskScheduleDefinitionConfig | undefined; + bucketRefreshSchedule: + | SchedulerServiceTaskScheduleDefinitionConfig + | undefined; /** @visibility backend */ bucketLocatorMethods: Array< diff --git a/plugins/s3-viewer-backend/src/run.ts b/plugins/s3-viewer-backend/src/run.ts index 0a3ed2b..79ba0fc 100644 --- a/plugins/s3-viewer-backend/src/run.ts +++ b/plugins/s3-viewer-backend/src/run.ts @@ -14,13 +14,13 @@ * limitations under the License. */ -import { getRootLogger } from '@backstage/backend-common'; +import { mockServices } from '@backstage/backend-test-utils'; import yn from 'yn'; import { startStandaloneServer } from './service/standaloneServer'; const port = process.env.PLUGIN_PORT ? Number(process.env.PLUGIN_PORT) : 7007; const enableCors = yn(process.env.PLUGIN_CORS, { default: false }); -const logger = getRootLogger(); +const logger = mockServices.logger.mock(); startStandaloneServer({ port, enableCors, logger }).catch(err => { logger.error(err); diff --git a/plugins/s3-viewer-backend/src/service/router.ts b/plugins/s3-viewer-backend/src/service/router.ts index 8bd1844..3bd81e3 100644 --- a/plugins/s3-viewer-backend/src/service/router.ts +++ b/plugins/s3-viewer-backend/src/service/router.ts @@ -45,6 +45,10 @@ export interface RouterOptions { httpAuth?: HttpAuthService; } +/** + * @deprecated Use the new backend system instead + * @public + */ export async function createRouter( options: RouterOptions, ): Promise {