Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin(blackduck): remove usages and references to @backstage/backend-common #2586

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions workspaces/blackduck/.changeset/eight-ladybugs-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@backstage-community/plugin-blackduck-backend': minor
'@backstage-community/plugin-blackduck': minor
---

Removed usages and references of @backstage/backend-common
Removed support for legacy backend system
63 changes: 0 additions & 63 deletions workspaces/blackduck/plugins/blackduck-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,69 +31,6 @@ const backend = createBackend();
backend.start();
```

### Legacy Backend System

Create a file called blackduck.ts inside `packages/backend/src/plugins/` and add the following:

### blackduck.ts

```typescript
import {
createRouter,
BlackDuckConfig,
} from '@backstage-community/plugin-blackduck-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter({
logger: env.logger,
config: env.config,
permissions: env.permissions,
discovery: env.discovery,
blackDuckConfig: BlackDuckConfig.fromConfig(env.config),
});
}
```

And import the plugin to `packages/backend/src/index.ts`.

### src/index.ts

```diff
diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts
index c4736a5..5822302 100644
--- a/packages/backend/src/index.ts
+++ b/packages/backend/src/index.ts
@@ -28,6 +28,7 @@ import scaffolder from './plugins/scaffolder';
import proxy from './plugins/proxy';
import techdocs from './plugins/techdocs';
import search from './plugins/search';
+import blackduck from './plugins/blackduck';
import { PluginEnvironment } from './types';
import { ServerPermissionClient } from '@backstage/plugin-permission-node';
import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
@@ -85,6 +86,7 @@ async function main() {
const techdocsEnv = useHotMemoize(module, () => createEnv('techdocs'));
const searchEnv = useHotMemoize(module, () => createEnv('search'));
const appEnv = useHotMemoize(module, () => createEnv('app'));
+ const blackduckEnv = useHotMemoize(module, () => createEnv('blackduck'));

const apiRouter = Router();
apiRouter.use('/catalog', await catalog(catalogEnv));
@@ -93,6 +95,7 @@ async function main() {
apiRouter.use('/techdocs', await techdocs(techdocsEnv));
apiRouter.use('/proxy', await proxy(proxyEnv));
apiRouter.use('/search', await search(searchEnv));
+ apiRouter.use('/blackduck', await blackduck(blackduckEnv));

// Add backends ABOVE this line; this 404 handler is the catch-all fallback
apiRouter.use(notFoundHandler());

```

## Configuration

### Integrate Permission Framework
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
},
"dependencies": {
"@backstage-community/plugin-blackduck-common": "workspace:^",
"@backstage/backend-common": "^0.25.0",
"@backstage/backend-defaults": "^0.6.1",
"@backstage/backend-plugin-api": "^1.1.0",
"@backstage/config": "^1.3.1",
Expand Down
24 changes: 0 additions & 24 deletions workspaces/blackduck/plugins/blackduck-backend/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
```ts
import { BackendFeature } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import express from 'express';
import { HttpAuthService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PermissionsService } from '@backstage/backend-plugin-api';

// @public
export class BlackDuckConfig {
Expand All @@ -34,24 +29,5 @@ export interface BlackDuckHostConfig {
const blackduckPlugin: BackendFeature;
export default blackduckPlugin;

// @public @deprecated (undocumented)
export function createRouter(options: RouterOptions): Promise<express.Router>;

// @public @deprecated (undocumented)
export interface RouterOptions {
// (undocumented)
blackDuckConfig: BlackDuckConfig;
// (undocumented)
config: Config;
// (undocumented)
discovery: DiscoveryService;
// (undocumented)
httpAuth?: HttpAuthService;
// (undocumented)
logger: LoggerService;
// (undocumented)
permissions: PermissionsService;
}

// (No @packageDocumentation comment for this package)
```
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('createRouter', () => {
permissions: mockServices.permissions.mock(),
discovery: mockServices.discovery.mock(),
blackDuckConfig: BlackDuckConfig.fromConfig(config),
httpAuth: mockServices.httpAuth(),
});
app = express().use(router);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import Router from 'express-promise-router';
import { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';
import { InputError, NotAllowedError } from '@backstage/errors';
import { AuthorizeResult } from '@backstage/plugin-permission-common';
import { createLegacyAuthAdapters } from '@backstage/backend-common';
import {
blackduckPermissions,
blackduckRiskProfileReadPermission,
Expand All @@ -35,28 +34,21 @@ import {
import { BlackDuckRestApi } from '../api/BlackDuckRestApi';
import { BlackDuckConfig } from './BlackDuckConfig';

/**
* @deprecated Please migrate to the new backend system as this will be removed in the future.
*
* @public */
/** @internal */
export interface RouterOptions {
logger: LoggerService;
config: Config;
permissions: PermissionsService;
discovery: DiscoveryService;
httpAuth?: HttpAuthService;
httpAuth: HttpAuthService;
blackDuckConfig: BlackDuckConfig;
}

/**
* @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, permissions, config, blackDuckConfig } = options;
const { httpAuth } = createLegacyAuthAdapters(options);
const { logger, permissions, config, blackDuckConfig, httpAuth } = options;
const permissionIntegrationRouter = createPermissionIntegrationRouter({
permissions: blackduckPermissions,
});
Expand Down
1 change: 0 additions & 1 deletion workspaces/blackduck/plugins/blackduck/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
},
"dependencies": {
"@backstage-community/plugin-blackduck-common": "workspace:^",
"@backstage/backend-common": "^0.25.0",
"@backstage/backend-plugin-api": "^1.1.0",
"@backstage/catalog-model": "^1.7.2",
"@backstage/config": "^1.3.1",
Expand Down
2 changes: 0 additions & 2 deletions workspaces/blackduck/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2741,7 +2741,6 @@ __metadata:
resolution: "@backstage-community/plugin-blackduck-backend@workspace:plugins/blackduck-backend"
dependencies:
"@backstage-community/plugin-blackduck-common": "workspace:^"
"@backstage/backend-common": ^0.25.0
"@backstage/backend-defaults": ^0.6.1
"@backstage/backend-plugin-api": ^1.1.0
"@backstage/backend-test-utils": ^1.2.0
Expand Down Expand Up @@ -2775,7 +2774,6 @@ __metadata:
resolution: "@backstage-community/plugin-blackduck@workspace:plugins/blackduck"
dependencies:
"@backstage-community/plugin-blackduck-common": "workspace:^"
"@backstage/backend-common": ^0.25.0
"@backstage/backend-plugin-api": ^1.1.0
"@backstage/catalog-model": ^1.7.2
"@backstage/cli": ^0.29.4
Expand Down
Loading