diff --git a/.changeset/stale-cobras-beg.md b/.changeset/stale-cobras-beg.md new file mode 100644 index 0000000000..c68c5226d9 --- /dev/null +++ b/.changeset/stale-cobras-beg.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-kubernetes-backend': minor +--- + +Add support for the new plugin system to the Kubernetes plugin diff --git a/packages/backend-next/package.json b/packages/backend-next/package.json index bed4f10975..55d7807ac6 100644 --- a/packages/backend-next/package.json +++ b/packages/backend-next/package.json @@ -28,6 +28,7 @@ "@backstage/backend-defaults": "workspace:^", "@backstage/plugin-app-backend": "workspace:^", "@backstage/plugin-catalog-backend": "workspace:^", + "@backstage/plugin-kubernetes-backend": "workspace:^", "@backstage/plugin-scaffolder-backend": "workspace:^", "@backstage/plugin-search-backend": "workspace:^", "@backstage/plugin-search-backend-module-catalog": "workspace:^", diff --git a/packages/backend-next/src/index.ts b/packages/backend-next/src/index.ts index e3cbbd53b8..1ce63a8d51 100644 --- a/packages/backend-next/src/index.ts +++ b/packages/backend-next/src/index.ts @@ -24,6 +24,7 @@ import { searchPlugin } from '@backstage/plugin-search-backend/alpha'; import { searchModuleCatalogCollator } from '@backstage/plugin-search-backend-module-catalog/alpha'; import { searchModuleTechDocsCollator } from '@backstage/plugin-search-backend-module-techdocs/alpha'; import { searchModuleExploreCollator } from '@backstage/plugin-search-backend-module-explore/alpha'; +import { kubernetesPlugin } from '@backstage/plugin-kubernetes-backend/alpha'; const backend = createBackend(); @@ -45,4 +46,6 @@ backend.add(searchModuleCatalogCollator()); backend.add(searchModuleTechDocsCollator()); backend.add(searchModuleExploreCollator()); +// Kubernetes +backend.add(kubernetesPlugin()); backend.start(); diff --git a/plugins/kubernetes-backend/alpha-api-report.md b/plugins/kubernetes-backend/alpha-api-report.md new file mode 100644 index 0000000000..f95c1414f3 --- /dev/null +++ b/plugins/kubernetes-backend/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-kubernetes-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 kubernetesPlugin: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/kubernetes-backend/package.json b/plugins/kubernetes-backend/package.json index 8f7b071c9a..6f234014a4 100644 --- a/plugins/kubernetes-backend/package.json +++ b/plugins/kubernetes-backend/package.json @@ -10,6 +10,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" }, @@ -36,11 +51,13 @@ "dependencies": { "@azure/identity": "^2.0.4", "@backstage/backend-common": "workspace:^", + "@backstage/backend-plugin-api": "workspace:^", "@backstage/catalog-client": "workspace:^", "@backstage/catalog-model": "workspace:^", "@backstage/config": "workspace:^", "@backstage/errors": "workspace:^", "@backstage/plugin-auth-node": "workspace:^", + "@backstage/plugin-catalog-node": "workspace:^", "@backstage/plugin-kubernetes-common": "workspace:^", "@backstage/plugin-permission-common": "workspace:^", "@backstage/plugin-permission-node": "workspace:^", diff --git a/plugins/kubernetes-backend/src/alpha.ts b/plugins/kubernetes-backend/src/alpha.ts new file mode 100644 index 0000000000..3041a5682c --- /dev/null +++ b/plugins/kubernetes-backend/src/alpha.ts @@ -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 { kubernetesPlugin } from './plugin'; diff --git a/plugins/kubernetes-backend/src/plugin.ts b/plugins/kubernetes-backend/src/plugin.ts new file mode 100644 index 0000000000..a62d852937 --- /dev/null +++ b/plugins/kubernetes-backend/src/plugin.ts @@ -0,0 +1,54 @@ +/* + * 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 { + createBackendPlugin, + coreServices, +} from '@backstage/backend-plugin-api'; +import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha'; + +import { KubernetesBuilder } from '@backstage/plugin-kubernetes-backend'; + +/** + * This is the backend plugin that provides the Kubernetes integration. + * @alpha + */ +export const kubernetesPlugin = createBackendPlugin({ + pluginId: 'kubernetes-backend', + register(env) { + env.registerInit({ + deps: { + http: coreServices.httpRouter, + logger: coreServices.logger, + config: coreServices.config, + catalogApi: catalogServiceRef, + permissions: coreServices.permissions, + }, + async init({ http, logger, config, catalogApi, permissions }) { + const winstonLogger = loggerToWinstonLogger(logger); + // TODO: expose all of the customization & extension points of the builder here + const { router } = await KubernetesBuilder.createBuilder({ + logger: winstonLogger, + config, + catalogApi, + permissions, + }).build(); + http.use(router); + }, + }); + }, +}); diff --git a/yarn.lock b/yarn.lock index 9c8dd2b64e..949e1aa868 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7031,6 +7031,7 @@ __metadata: dependencies: "@azure/identity": ^2.0.4 "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/catalog-client": "workspace:^" "@backstage/catalog-model": "workspace:^" @@ -7038,6 +7039,7 @@ __metadata: "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" "@backstage/plugin-auth-node": "workspace:^" + "@backstage/plugin-catalog-node": "workspace:^" "@backstage/plugin-kubernetes-common": "workspace:^" "@backstage/plugin-permission-common": "workspace:^" "@backstage/plugin-permission-node": "workspace:^" @@ -23396,6 +23398,7 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/plugin-app-backend": "workspace:^" "@backstage/plugin-catalog-backend": "workspace:^" + "@backstage/plugin-kubernetes-backend": "workspace:^" "@backstage/plugin-scaffolder-backend": "workspace:^" "@backstage/plugin-search-backend": "workspace:^" "@backstage/plugin-search-backend-module-catalog": "workspace:^"