Added alpha support for new backend system

Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com>
This commit is contained in:
Andre Wanlin
2023-06-16 17:24:23 -05:00
parent cb91dac435
commit ae261e79d2
19 changed files with 479 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/plugin-azure-devops-backend': patch
'@backstage/plugin-devtools-backend': patch
'@backstage/plugin-linguist-backend': patch
---
Added alpha support for the [new backend system](https://backstage.io/docs/backend-system/)
+4
View File
@@ -26,13 +26,17 @@
},
"dependencies": {
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-tasks": "workspace:^",
"@backstage/plugin-app-backend": "workspace:^",
"@backstage/plugin-auth-node": "workspace:^",
"@backstage/plugin-azure-devops-backend": "workspace:^",
"@backstage/plugin-badges-backend": "workspace:^",
"@backstage/plugin-catalog-backend": "workspace:^",
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^",
"@backstage/plugin-devtools-backend": "workspace:^",
"@backstage/plugin-entity-feedback-backend": "workspace:^",
"@backstage/plugin-kubernetes-backend": "workspace:^",
"@backstage/plugin-linguist-backend": "workspace:^",
"@backstage/plugin-permission-backend": "workspace:^",
"@backstage/plugin-permission-common": "workspace:^",
"@backstage/plugin-permission-node": "workspace:^",
+26
View File
@@ -33,6 +33,10 @@ 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';
import { azureDevOpsPlugin } from '@backstage/plugin-azure-devops-backend/alpha';
import { linguistPlugin } from '@backstage/plugin-linguist-backend/alpha';
import { devtoolsPlugin } from '@backstage/plugin-devtools-backend/alpha';
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
const backend = createBackend();
@@ -41,9 +45,31 @@ backend.add(appPlugin({ appPackageName: 'example-app' }));
// Badges
backend.add(badgesPlugin());
// Azure DevOps
backend.add(azureDevOpsPlugin());
// DevTools
backend.add(devtoolsPlugin());
// Entity Feedback
backend.add(entityFeedbackPlugin());
// Linguist
const linguistSchedule: TaskScheduleDefinition = {
frequency: { minutes: 2 },
timeout: { minutes: 15 },
initialDelay: { seconds: 15 },
};
backend.add(
linguistPlugin({
schedule: linguistSchedule,
age: { days: 30 },
batchSize: 2,
useSourceLocation: false,
}),
);
// Todo
backend.add(todoPlugin());
+28
View File
@@ -70,6 +70,34 @@ Here's how to get the backend up and running:
4. Now run `yarn start-backend` from the repo root
5. Finally open `http://localhost:7007/api/azure-devops/health` in a browser and it should return `{"status":"ok"}`
#### New Backend System
The Azure DevOps backend plugin has alpha 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 { appPlugin } from '@backstage/plugin-app-backend';
import { catalogPlugin } from '@backstage/plugin-catalog-backend';
import {
scaffolderPlugin,
catalogModuleTemplateKind,
} from '@backstage/plugin-scaffolder-backend';
+ import { azureDevOpsPlugin } from '@backstage/plugin-azure-devops-backend/alpha';
const backend = createBackend();
backend.add(appPlugin());
backend.add(catalogPlugin());
backend.add(catalogModuleTemplateKind());
backend.add(scaffolderPlugin());
+ backend.add(azureDevOpsPlugin());
backend.start();
```
## Links
- [Frontend part of the plugin](https://github.com/backstage/backstage/tree/master/plugins/azure-devops)
@@ -0,0 +1,12 @@
## API Report File for "@backstage/plugin-azure-devops-backend"
> 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';
// @alpha
export const azureDevOpsPlugin: () => BackendFeature;
// (No @packageDocumentation comment for this package)
```
+16
View File
@@ -9,6 +9,21 @@
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha.ts",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha.ts"
],
"package.json": [
"package.json"
]
}
},
"backstage": {
"role": "backend-plugin"
},
@@ -23,6 +38,7 @@
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/config": "workspace:^",
"@backstage/plugin-azure-devops-common": "workspace:^",
"@types/express": "^4.17.6",
+16
View File
@@ -0,0 +1,16 @@
/*
* 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.
*/
export { azureDevOpsPlugin } from './plugin';
@@ -0,0 +1,50 @@
/*
* 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';
/**
* Azure DevOps backend plugin
*
* @alpha
*/
export const azureDevOpsPlugin = createBackendPlugin({
pluginId: 'azure-devops',
register(env) {
env.registerInit({
deps: {
config: coreServices.config,
logger: coreServices.logger,
reader: coreServices.urlReader,
httpRouter: coreServices.httpRouter,
},
async init({ config, logger, reader, httpRouter }) {
httpRouter.use(
await createRouter({
config,
logger: loggerToWinstonLogger(logger),
reader,
}),
);
},
});
},
});
+28
View File
@@ -49,6 +49,34 @@ Here's how to get the DevTools Backend up and running:
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"}`
### New Backend System
The DevTools backend plugin has alpha 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 { appPlugin } from '@backstage/plugin-app-backend';
import { catalogPlugin } from '@backstage/plugin-catalog-backend';
import {
scaffolderPlugin,
catalogModuleTemplateKind,
} from '@backstage/plugin-scaffolder-backend';
+ import { devtoolsPlugin } from '@backstage/plugin-devtools-backend/alpha';
const backend = createBackend();
backend.add(appPlugin());
backend.add(catalogPlugin());
backend.add(catalogModuleTemplateKind());
backend.add(scaffolderPlugin());
+ backend.add(devtoolsPlugin());
backend.start();
```
## Links
- [Frontend part of the plugin](../devtools/README.md)
@@ -0,0 +1,12 @@
## API Report File for "@backstage/plugin-devtools-backend"
> 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';
// @alpha
export const devtoolsPlugin: () => BackendFeature;
// (No @packageDocumentation comment for this package)
```
+16
View File
@@ -9,6 +9,21 @@
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha.ts",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha.ts"
],
"package.json": [
"package.json"
]
}
},
"backstage": {
"role": "backend-plugin"
},
@@ -23,6 +38,7 @@
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/cli-common": "workspace:^",
"@backstage/config": "workspace:^",
"@backstage/config-loader": "workspace:^",
+16
View File
@@ -0,0 +1,16 @@
/*
* 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.
*/
export { devtoolsPlugin } from './plugin';
+50
View File
@@ -0,0 +1,50 @@
/*
* 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';
/**
* Azure DevOps backend plugin
*
* @alpha
*/
export const devtoolsPlugin = createBackendPlugin({
pluginId: 'devtools',
register(env) {
env.registerInit({
deps: {
config: coreServices.config,
logger: coreServices.logger,
permissions: coreServices.permissions,
httpRouter: coreServices.httpRouter,
},
async init({ config, logger, permissions, httpRouter }) {
httpRouter.use(
await createRouter({
config,
logger: loggerToWinstonLogger(logger),
permissions,
}),
);
},
});
},
});
+41
View File
@@ -56,6 +56,47 @@ Here's how to get the backend up and running:
4. Now run `yarn start-backend` from the repo root
5. Finally open `http://localhost:7007/api/linguist/health` in a browser and it should return `{"status":"ok"}`
#### New Backend System
The Linguist backend plugin has alpha 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 { appPlugin } from '@backstage/plugin-app-backend';
import { catalogPlugin } from '@backstage/plugin-catalog-backend';
import {
scaffolderPlugin,
catalogModuleTemplateKind,
} from '@backstage/plugin-scaffolder-backend';
+ import { linguistPlugin } from '@backstage/plugin-linguist-backend/alpha';
const backend = createBackend();
backend.add(appPlugin());
backend.add(catalogPlugin());
backend.add(catalogModuleTemplateKind());
backend.add(scaffolderPlugin());
+ const linguistSchedule: TaskScheduleDefinition = {
+ frequency: { minutes: 2 },
+ timeout: { minutes: 15 },
+ initialDelay: { seconds: 15 },
+ };
+ backend.add(
+ linguistPlugin({
+ schedule: linguistSchedule,
+ age: { days: 30 },
+ batchSize: 2,
+ useSourceLocation: false,
+ }),
+ );
backend.start();
```
## Plugin Option
The Linguist backend has various plugin options that you can provide to the `createRouter` function in your `packages/backend/src/plugins/linguist.ts` file that will allow you to configure various aspects of how it works. The following sections go into the details of these options
@@ -0,0 +1,30 @@
## API Report File for "@backstage/plugin-linguist-backend"
> 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 { HumanDuration } from '@backstage/types';
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
// @alpha
export const linguistPlugin: (options: LinguistPluginOptions) => BackendFeature;
// @alpha
export interface LinguistPluginOptions {
// (undocumented)
age?: HumanDuration;
// (undocumented)
batchSize?: number;
// (undocumented)
kind?: string[];
// (undocumented)
linguistJsOptions?: Record<string, unknown>;
// (undocumented)
schedule?: TaskScheduleDefinition;
// (undocumented)
useSourceLocation?: boolean;
}
// (No @packageDocumentation comment for this package)
```
+16
View File
@@ -9,6 +9,21 @@
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha.ts",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha.ts"
],
"package.json": [
"package.json"
]
}
},
"backstage": {
"role": "backend-plugin"
},
@@ -23,6 +38,7 @@
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/backend-tasks": "workspace:^",
"@backstage/catalog-client": "workspace:^",
"@backstage/catalog-model": "workspace:^",
+17
View File
@@ -0,0 +1,17 @@
/*
* 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.
*/
export { linguistPlugin } from './plugin';
export type { LinguistPluginOptions } from './plugin';
+87
View File
@@ -0,0 +1,87 @@
/*
* 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';
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
import { HumanDuration } from '@backstage/types';
/**
* Options for Linguist backend plugin
*
* @alpha
*/
export interface LinguistPluginOptions {
schedule?: TaskScheduleDefinition;
age?: HumanDuration;
batchSize?: number;
useSourceLocation?: boolean;
linguistJsOptions?: Record<string, unknown>;
kind?: string[];
}
/**
* Linguist backend plugin
*
* @alpha
*/
export const linguistPlugin = createBackendPlugin(
(options: LinguistPluginOptions) => ({
pluginId: 'linguist',
register(env) {
env.registerInit({
deps: {
logger: coreServices.logger,
reader: coreServices.urlReader,
database: coreServices.database,
discovery: coreServices.discovery,
scheduler: coreServices.scheduler,
tokenManager: coreServices.tokenManager,
httpRouter: coreServices.httpRouter,
},
async init({
logger,
reader,
database,
discovery,
scheduler,
tokenManager,
httpRouter,
}) {
httpRouter.use(
await createRouter(
{
...options,
},
{
logger: loggerToWinstonLogger(logger),
reader,
database,
discovery,
scheduler,
tokenManager,
},
),
);
},
});
},
}),
);
+7
View File
@@ -5011,6 +5011,7 @@ __metadata:
resolution: "@backstage/plugin-azure-devops-backend@workspace:plugins/azure-devops-backend"
dependencies:
"@backstage/backend-common": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/cli": "workspace:^"
"@backstage/config": "workspace:^"
"@backstage/plugin-azure-devops-common": "workspace:^"
@@ -6353,6 +6354,7 @@ __metadata:
resolution: "@backstage/plugin-devtools-backend@workspace:plugins/devtools-backend"
dependencies:
"@backstage/backend-common": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/cli": "workspace:^"
"@backstage/cli-common": "workspace:^"
"@backstage/config": "workspace:^"
@@ -7723,6 +7725,7 @@ __metadata:
resolution: "@backstage/plugin-linguist-backend@workspace:plugins/linguist-backend"
dependencies:
"@backstage/backend-common": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-tasks": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
"@backstage/catalog-client": "workspace:^"
@@ -24925,14 +24928,18 @@ __metadata:
resolution: "example-backend-next@workspace:packages/backend-next"
dependencies:
"@backstage/backend-defaults": "workspace:^"
"@backstage/backend-tasks": "workspace:^"
"@backstage/cli": "workspace:^"
"@backstage/plugin-app-backend": "workspace:^"
"@backstage/plugin-auth-node": "workspace:^"
"@backstage/plugin-azure-devops-backend": "workspace:^"
"@backstage/plugin-badges-backend": "workspace:^"
"@backstage/plugin-catalog-backend": "workspace:^"
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^"
"@backstage/plugin-devtools-backend": "workspace:^"
"@backstage/plugin-entity-feedback-backend": "workspace:^"
"@backstage/plugin-kubernetes-backend": "workspace:^"
"@backstage/plugin-linguist-backend": "workspace:^"
"@backstage/plugin-permission-backend": "workspace:^"
"@backstage/plugin-permission-common": "workspace:^"
"@backstage/plugin-permission-node": "workspace:^"