Merge pull request #18464 from awanlin/topic/badges-support-new-backend

Added support to Badges for new backend
This commit is contained in:
Ben Lambert
2023-06-28 14:25:03 +02:00
committed by GitHub
9 changed files with 97 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-badges-backend': patch
---
Added support for the [new backend system](https://backstage.io/docs/backend-system/)
+1
View File
@@ -28,6 +28,7 @@
"@backstage/backend-defaults": "workspace:^",
"@backstage/plugin-app-backend": "workspace:^",
"@backstage/plugin-auth-node": "workspace:^",
"@backstage/plugin-badges-backend": "workspace:^",
"@backstage/plugin-catalog-backend": "workspace:^",
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^",
"@backstage/plugin-entity-feedback-backend": "workspace:^",
+4
View File
@@ -32,11 +32,15 @@ import { techdocsPlugin } from '@backstage/plugin-techdocs-backend/alpha';
import { todoPlugin } from '@backstage/plugin-todo-backend';
import { entityFeedbackPlugin } from '@backstage/plugin-entity-feedback-backend';
import { catalogModuleUnprocessedEntities } from '@backstage/plugin-catalog-backend-module-unprocessed';
import { badgesPlugin } from '@backstage/plugin-badges-backend';
const backend = createBackend();
backend.add(appPlugin({ appPackageName: 'example-app' }));
// Badges
backend.add(badgesPlugin());
// Entity Feedback
backend.add(entityFeedbackPlugin());
+18
View File
@@ -76,6 +76,24 @@ const createEnv = makeCreateEnv(config);
apiRouter.use(notFoundHandler());
```
### New Backend System
The Badges backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:
In your `packages/backend/src/index.ts` make the following changes:
```diff
import { createBackend } from '@backstage/backend-defaults';
+ import { badgesPlugin } from '@backstage/plugin-badges-backend';
const backend = createBackend();
// ... other feature additions
+ backend.add(badgesPlugin());
backend.start();
```
## Badge builder
Badges are created by classes implementing the `BadgeBuilder` type. The default
+4
View File
@@ -3,6 +3,7 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { BackendFeature } from '@backstage/backend-plugin-api';
import { CatalogApi } from '@backstage/catalog-client';
import { Config } from '@backstage/config';
import { Entity } from '@backstage/catalog-model';
@@ -81,6 +82,9 @@ export type BadgeSpec = {
markdown: string;
};
// @public
export const badgesPlugin: () => BackendFeature;
// @public
export interface BadgesStore {
// (undocumented)
+1
View File
@@ -34,6 +34,7 @@
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/catalog-client": "workspace:^",
"@backstage/catalog-model": "workspace:^",
"@backstage/config": "workspace:^",
+1
View File
@@ -25,3 +25,4 @@ export * from './lib';
export * from './service/router';
export * from './types';
export * from './database/badgesStore';
export { badgesPlugin } from './plugin';
+61
View File
@@ -0,0 +1,61 @@
/*
* Copyright 2023 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 { loggerToWinstonLogger } from '@backstage/backend-common';
import {
coreServices,
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import { createRouter } from './service/router';
/**
* Badges backend plugin
*
* @public
*/
export const badgesPlugin = createBackendPlugin({
pluginId: 'badges',
register(env) {
env.registerInit({
deps: {
config: coreServices.config,
logger: coreServices.logger,
discovery: coreServices.discovery,
tokenManager: coreServices.tokenManager,
identity: coreServices.identity,
httpRouter: coreServices.httpRouter,
},
async init({
config,
logger,
discovery,
tokenManager,
identity,
httpRouter,
}) {
httpRouter.use(
await createRouter({
config,
logger: loggerToWinstonLogger(logger),
discovery,
tokenManager,
identity,
}),
);
},
});
},
});
+2
View File
@@ -5139,6 +5139,7 @@ __metadata:
resolution: "@backstage/plugin-badges-backend@workspace:plugins/badges-backend"
dependencies:
"@backstage/backend-common": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
"@backstage/catalog-client": "workspace:^"
"@backstage/catalog-model": "workspace:^"
@@ -24927,6 +24928,7 @@ __metadata:
"@backstage/cli": "workspace:^"
"@backstage/plugin-app-backend": "workspace:^"
"@backstage/plugin-auth-node": "workspace:^"
"@backstage/plugin-badges-backend": "workspace:^"
"@backstage/plugin-catalog-backend": "workspace:^"
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^"
"@backstage/plugin-entity-feedback-backend": "workspace:^"