Merge pull request #27419 from awanlin/topic/devtools-remove-deprecated-code

DevTools - Removed Deprecated Code
This commit is contained in:
Andre Wanlin
2024-11-29 11:02:42 -06:00
committed by GitHub
11 changed files with 16 additions and 124 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-devtools-backend': minor
---
**BREAKING** Removed support for what is known as the legacy backend, please use the New Backend System.
-1
View File
@@ -42,7 +42,6 @@
"@backstage/plugin-catalog-backend-module-scaffolder-entity-model": "workspace:^",
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^",
"@backstage/plugin-catalog-node": "workspace:^",
"@backstage/plugin-devtools-backend": "workspace:^",
"@backstage/plugin-events-backend": "workspace:^",
"@backstage/plugin-events-node": "workspace:^",
"@backstage/plugin-kubernetes-backend": "workspace:^",
-3
View File
@@ -48,7 +48,6 @@ import techdocs from './plugins/techdocs';
import app from './plugins/app';
import permission from './plugins/permission';
import signals from './plugins/signals';
import devtools from './plugins/devtools';
import { PluginEnvironment } from './types';
import { ServerPermissionClient } from '@backstage/plugin-permission-node';
import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
@@ -138,7 +137,6 @@ async function main() {
const appEnv = useHotMemoize(module, () => createEnv('app'));
const permissionEnv = useHotMemoize(module, () => createEnv('permission'));
const eventsEnv = useHotMemoize(module, () => createEnv('events'));
const devToolsEnv = useHotMemoize(module, () => createEnv('devtools'));
const signalsEnv = useHotMemoize(module, () => createEnv('signals'));
const apiRouter = Router();
@@ -151,7 +149,6 @@ async function main() {
apiRouter.use('/kubernetes', await kubernetes(kubernetesEnv));
apiRouter.use('/proxy', await proxy(proxyEnv));
apiRouter.use('/permission', await permission(permissionEnv));
apiRouter.use('/devtools', await devtools(devToolsEnv));
apiRouter.use('/signals', await signals(signalsEnv));
apiRouter.use(notFoundHandler());
@@ -1,30 +0,0 @@
/*
* 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 { createRouter } from '@backstage/plugin-devtools-backend';
import { Router } from 'express';
import type { PluginEnvironment } from '../types';
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return createRouter({
logger: env.logger,
config: env.config,
permissions: env.permissions,
discovery: env.discovery,
});
}
-48
View File
@@ -25,54 +25,6 @@ Here's how to get the DevTools Backend up and running in the new backend system:
3. Now run `yarn start-backend` from the repo root
4. Finally open `http://localhost:7007/api/devtools/health` in a browser and it should return `{"status":"ok"}`
## Old Backend System
If you are still on the old backend system, please consider migrating to the new backend system. But to install this plugin in an old backend, see below.
1. First we need to add the `@backstage/plugin-devtools-backend` package to your backend:
```sh
# From the Backstage root directory
yarn --cwd packages/backend add @backstage/plugin-devtools-backend
```
2. Then we will create a new file named `packages/backend/src/plugins/devtools.ts`, and add the
following to it:
```ts
import { createRouter } from '@backstage/plugin-devtools-backend';
import { Router } from 'express';
import type { PluginEnvironment } from '../types';
export default function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return createRouter({
logger: env.logger,
config: env.config,
permissions: env.permissions,
discovery: env.discovery,
});
}
```
3. Next we wire this into the overall backend router, edit `packages/backend/src/index.ts`:
```ts
import devTools from './plugins/devtools';
// ...
async function main() {
// ...
// Add this line under the other lines that follow the useHotMemoize pattern
const devToolsEnv = useHotMemoize(module, () => createEnv('devtools'));
// ...
// Insert this line under the other lines that add their routers to apiRouter in the same way
apiRouter.use('/devtools', await devTools(devToolsEnv));
```
4. Now run `yarn start-backend` from the repo root
5. Finally open `http://localhost:7007/api/devtools/health` in a browser and it should return `{"status":"ok"}`
## Links
- [Frontend part of the plugin](https://github.com/backstage/backstage/tree/master/plugins/devtools)
+2 -2
View File
@@ -38,7 +38,7 @@
"test": "backstage-cli package test"
},
"dependencies": {
"@backstage/backend-common": "^0.25.0",
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/cli-common": "workspace:^",
"@backstage/config": "workspace:^",
@@ -49,7 +49,6 @@
"@backstage/plugin-permission-node": "workspace:^",
"@backstage/types": "workspace:^",
"@manypkg/get-packages": "^1.1.3",
"@types/express": "^4.17.6",
"@yarnpkg/lockfile": "^1.1.0",
"@yarnpkg/parsers": "^3.0.0",
"express": "^4.18.1",
@@ -65,6 +64,7 @@
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"@types/express": "^4.17.6",
"@types/ping": "^0.4.1",
"@types/supertest": "^2.0.8",
"@types/yarnpkg__lockfile": "^1.1.4",
-24
View File
@@ -7,16 +7,8 @@ import { BackendFeature } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { ConfigInfo } from '@backstage/plugin-devtools-common';
import { DevToolsInfo } from '@backstage/plugin-devtools-common';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import express from 'express';
import { ExternalDependency } from '@backstage/plugin-devtools-common';
import { HttpAuthService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PermissionsService } from '@backstage/backend-plugin-api';
import { RootConfigService } from '@backstage/backend-plugin-api';
// @public @deprecated (undocumented)
export function createRouter(options: RouterOptions): Promise<express.Router>;
// @public (undocumented)
export class DevToolsBackendApi {
@@ -32,20 +24,4 @@ export class DevToolsBackendApi {
// @public
const devtoolsPlugin: BackendFeature;
export default devtoolsPlugin;
// @public @deprecated (undocumented)
export interface RouterOptions {
// (undocumented)
config: RootConfigService;
// (undocumented)
devToolsBackendApi?: DevToolsBackendApi;
// (undocumented)
discovery: DiscoveryService;
// (undocumented)
httpAuth?: HttpAuthService;
// (undocumented)
logger: LoggerService;
// (undocumented)
permissions: PermissionsService;
}
```
-1
View File
@@ -21,5 +21,4 @@
*/
export { DevToolsBackendApi } from './api';
export * from './service/router';
export { devtoolsPlugin as default } from './plugin';
@@ -51,6 +51,7 @@ describe('createRouter', () => {
}),
discovery: mockServices.discovery(),
permissions: permissionEvaluator,
httpAuth: mockServices.httpAuth(),
});
app = express().use(router);
});
+8 -13
View File
@@ -24,10 +24,6 @@ import {
import { DevToolsBackendApi } from '../api';
import { NotAllowedError } from '@backstage/errors';
import Router from 'express-promise-router';
import {
createLegacyAuthAdapters,
errorHandler,
} from '@backstage/backend-common';
import express from 'express';
import { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';
import {
@@ -37,10 +33,10 @@ import {
PermissionsService,
RootConfigService,
} from '@backstage/backend-plugin-api';
import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';
/**
* @public
* @deprecated Please migrate to the new backend system as this will be removed in the future.
* @internal
*/
export interface RouterOptions {
devToolsBackendApi?: DevToolsBackendApi;
@@ -48,19 +44,16 @@ export interface RouterOptions {
config: RootConfigService;
permissions: PermissionsService;
discovery: DiscoveryService;
httpAuth?: HttpAuthService;
httpAuth: HttpAuthService;
}
/**
* @deprecated Please migrate to the new backend system as this will be removed in the future.
* @public
* @internal
* */
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const { logger, config, permissions } = options;
const { httpAuth } = createLegacyAuthAdapters(options);
const { logger, config, permissions, httpAuth } = options;
const devToolsBackendApi =
options.devToolsBackendApi || new DevToolsBackendApi(logger, config);
@@ -128,6 +121,8 @@ export async function createRouter(
response.status(200).json(health);
});
router.use(errorHandler());
const middleware = MiddlewareFactory.create({ logger, config });
router.use(middleware.error());
return router;
}
-2
View File
@@ -6556,7 +6556,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@backstage/plugin-devtools-backend@workspace:plugins/devtools-backend"
dependencies:
"@backstage/backend-common": ^0.25.0
"@backstage/backend-defaults": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
@@ -28753,7 +28752,6 @@ __metadata:
"@backstage/plugin-catalog-backend-module-scaffolder-entity-model": "workspace:^"
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^"
"@backstage/plugin-catalog-node": "workspace:^"
"@backstage/plugin-devtools-backend": "workspace:^"
"@backstage/plugin-events-backend": "workspace:^"
"@backstage/plugin-events-node": "workspace:^"
"@backstage/plugin-kubernetes-backend": "workspace:^"