Skip to content

Commit

Permalink
Azure DevOps - Removed Deprecated Code (#1803)
Browse files Browse the repository at this point in the history
* Azure DevOps - Removed Deprecated Code

Signed-off-by: Andre Wanlin <[email protected]>

* Fixed typo

Signed-off-by: Andre Wanlin <[email protected]>

---------

Signed-off-by: Andre Wanlin <[email protected]>
  • Loading branch information
awanlin authored Nov 4, 2024
1 parent 6412222 commit 0880746
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 103 deletions.
5 changes: 5 additions & 0 deletions workspaces/azure-devops/.changeset/lazy-poems-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage-community/plugin-scaffolder-backend-module-azure-devops': patch
---

Updated code with proper TSDoc comments to generate API Reports
5 changes: 5 additions & 0 deletions workspaces/azure-devops/.changeset/odd-masks-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage-community/plugin-azure-devops-backend': minor
---

**BREAKING** Removed support for what is known as the legacy backend, please use the New Backend System. Also removed the long deprecated `azureDevOps.token` configuration option, use `integrations.azure` instead.
2 changes: 1 addition & 1 deletion workspaces/azure-devops/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"prettier:write": "prettier --write .",
"new": "backstage-cli new --scope @backstage-community",
"build:api-reports": "yarn build:api-reports:only --tsc",
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type, ae-undocumented --validate-release-tags",
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
"build:knip-reports": "backstage-repo-tools knip-reports",
"postinstall": "cd ../../ && yarn install"
},
Expand Down
1 change: 0 additions & 1 deletion workspaces/azure-devops/packages/backend/knip-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
| @backstage/plugin-permission-common | package.json | error |
| @backstage/plugin-permission-node | package.json | error |
| @backstage/plugin-auth-node | package.json | error |
| @backstage/backend-common | package.json | error |
| @backstage/backend-tasks | package.json | error |
| @backstage/config | package.json | error |
| better-sqlite3 | package.json | error |
Expand Down
1 change: 0 additions & 1 deletion workspaces/azure-devops/packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@backstage-community/plugin-azure-devops-backend": "workspace:^",
"@backstage-community/plugin-catalog-backend-module-azure-devops-annotator-processor": "workspace:^",
"@backstage-community/plugin-scaffolder-backend-module-azure-devops": "workspace:^",
"@backstage/backend-common": "^0.23.3",
"@backstage/backend-defaults": "^0.5.2",
"@backstage/backend-tasks": "^0.6.1",
"@backstage/config": "^1.2.0",
Expand Down
43 changes: 1 addition & 42 deletions workspaces/azure-devops/plugins/azure-devops-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,10 @@ Here's how to get the backend up and running:
1. First we need to add the `@backstage-community/plugin-azure-devops-backend` package to your backend:

```sh
# From your Backstage root directory
yarn --cwd packages/backend add @backstage-community/plugin-azure-devops-backend
```

2. Then we will create a new file named `packages/backend/src/plugins/azure-devops.ts`, and add the
following to it:

```ts
import { createRouter } from '@backstage-community/plugin-azure-devops-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,
reader: env.reader,
});
}
```

3. Next we wire this into the overall backend router, edit `packages/backend/src/index.ts`:

```ts
import azureDevOps from './plugins/azure-devops';
// ...
async function main() {
// ...
// Add this line under the other lines that follow the useHotMemoize pattern
const azureDevOpsEnv = useHotMemoize(module, () => createEnv('azure-devops'));
// ...
// Insert this line under the other lines that add their routers to apiRouter in the same way
apiRouter.use('/azure-devops', await azureDevOps(azureDevOpsEnv));
```

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 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:
2. Then in your `packages/backend/src/index.ts` make the following changes:

```diff
import { createBackend } from '@backstage/backend-defaults';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ export interface Config {
* The hostname of the given Azure instance
*/
host: string;
/**
* Token used to authenticate requests.
* @visibility secret
* @deprecated Use `integrations.azure` instead, see {@link https://backstage.io/docs/integrations/azure/locations}
*/
token?: string;
/**
* The organization of the given Azure instance
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
},
"dependencies": {
"@backstage-community/plugin-azure-devops-common": "workspace:^",
"@backstage/backend-common": "^0.25.0",
"@backstage/backend-defaults": "^0.5.2",
"@backstage/backend-plugin-api": "^1.0.1",
"@backstage/catalog-model": "^1.7.0",
Expand Down
25 changes: 0 additions & 25 deletions workspaces/azure-devops/plugins/azure-devops-backend/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import { BuildDefinitionReference } from 'azure-devops-node-api/interfaces/Build
import { BuildRun } from '@backstage-community/plugin-azure-devops-common';
import { Config } from '@backstage/config';
import { DashboardPullRequest } from '@backstage-community/plugin-azure-devops-common';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import express from 'express';
import { GitRepository } from 'azure-devops-node-api/interfaces/GitInterfaces';
import { GitTag } from '@backstage-community/plugin-azure-devops-common';
import { HttpAuthService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PermissionsService } from '@backstage/backend-plugin-api';
import { Project } from '@backstage-community/plugin-azure-devops-common';
import { PullRequest } from '@backstage-community/plugin-azure-devops-common';
import { PullRequestOptions } from '@backstage-community/plugin-azure-devops-common';
Expand Down Expand Up @@ -127,25 +123,4 @@ export class AzureDevOpsApi {
// @public
const azureDevOpsPlugin: BackendFeature;
export default azureDevOpsPlugin;

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

// @public @deprecated (undocumented)
export interface RouterOptions {
// (undocumented)
azureDevOpsApi?: AzureDevOpsApi;
// (undocumented)
config: Config;
// (undocumented)
discovery: DiscoveryService;
// (undocumented)
httpAuth?: HttpAuthService;
// (undocumented)
logger: LoggerService;
// (undocumented)
permissions: PermissionsService;
// (undocumented)
reader: UrlReaderService;
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@
*/

export { AzureDevOpsApi } from './api';
export * from './service/router';
export { azureDevOpsPlugin as default } from './plugin';
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const azureDevOpsPlugin = createBackendPlugin({
reader: coreServices.urlReader,
permissions: coreServices.permissions,
httpRouter: coreServices.httpRouter,
discovery: coreServices.discovery,
httpAuth: coreServices.httpAuth,
},
async init({
Expand All @@ -44,7 +43,6 @@ export const azureDevOpsPlugin = createBackendPlugin({
reader,
permissions,
httpRouter,
discovery,
httpAuth,
}) {
httpRouter.use(
Expand All @@ -53,7 +51,6 @@ export const azureDevOpsPlugin = createBackendPlugin({
logger,
reader,
permissions,
discovery,
httpAuth,
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('createRouter', () => {
azureDevOpsApi,
reader: mockUrlReader,
permissions: mockPermissionEvaluator,
discovery: mockServices.discovery(),
httpAuth: mockServices.httpAuth(),
});

app = express().use(router);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ import {
PullRequestsDashboardProvider,
} from '../api/PullRequestsDashboardProvider';
import Router from 'express-promise-router';
import { createLegacyAuthAdapters } from '@backstage/backend-common';
import { UrlReaderService } from '@backstage/backend-plugin-api';
import express from 'express';
import { InputError, NotAllowedError } from '@backstage/errors';
import { AuthorizeResult } from '@backstage/plugin-permission-common';
import { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';
import {
DiscoveryService,
HttpAuthService,
LoggerService,
PermissionsService,
Expand All @@ -49,35 +47,24 @@ import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';
const DEFAULT_TOP = 10;

/**
* @deprecated Please migrate to the new backend system as this will be removed in the future.
* @public
* @internal
* */
export interface RouterOptions {
azureDevOpsApi?: AzureDevOpsApi;
logger: LoggerService;
config: Config;
reader: UrlReaderService;
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, reader, config, permissions } = options;

const { httpAuth } = createLegacyAuthAdapters(options);

if (config.getOptionalString('azureDevOps.token')) {
logger.warn(
"The 'azureDevOps.token' has been deprecated, use 'integrations.azure' instead, for more details see: https://backstage.io/docs/integrations/azure/locations",
);
}
const { logger, reader, config, permissions, httpAuth } = options;

const permissionIntegrationRouter = createPermissionIntegrationRouter({
permissions: azureDevOpsPermissions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
| Name | Location | Severity |
| :---------------------------------------------- | :----------- | :------- |
| @backstage-community/plugin-azure-devops-common | package.json | error |
| @backstage/backend-common | package.json | error |

## Unused devDependencies (1)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## API Report File for "@backstage-community/plugin-scaffolder-backend-module-azure-devops"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { BackendFeatureCompat } from '@backstage/backend-plugin-api';

// @public
const scaffolderModule: BackendFeatureCompat;
export default scaffolderModule;
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/**
* The azure-devops module for @backstage/plugin-scaffolder-backend.
* The azure-devops module for the Scaffolder.
*
* @packageDocumentation
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ScmIntegrations } from '@backstage/integration';

/**
* A backend module that registers the action into the scaffolder
* @public
*/
export const scaffolderModule = createBackendModule({
moduleId: 'azure-devops',
Expand Down
2 changes: 0 additions & 2 deletions workspaces/azure-devops/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2662,7 +2662,6 @@ __metadata:
resolution: "@backstage-community/plugin-azure-devops-backend@workspace:plugins/azure-devops-backend"
dependencies:
"@backstage-community/plugin-azure-devops-common": "workspace:^"
"@backstage/backend-common": ^0.25.0
"@backstage/backend-defaults": ^0.5.2
"@backstage/backend-plugin-api": ^1.0.1
"@backstage/backend-test-utils": ^1.0.2
Expand Down Expand Up @@ -15420,7 +15419,6 @@ __metadata:
"@backstage-community/plugin-azure-devops-backend": "workspace:^"
"@backstage-community/plugin-catalog-backend-module-azure-devops-annotator-processor": "workspace:^"
"@backstage-community/plugin-scaffolder-backend-module-azure-devops": "workspace:^"
"@backstage/backend-common": ^0.23.3
"@backstage/backend-defaults": ^0.5.2
"@backstage/backend-tasks": ^0.6.1
"@backstage/cli": ^0.28.0
Expand Down

0 comments on commit 0880746

Please sign in to comment.