added support to Lighthouse for new backend

Signed-off-by: Jonathan Roebuck <jroebuck@spotify.com>
This commit is contained in:
Jonathan Roebuck
2023-07-10 16:00:31 +01:00
parent ba3b7d1782
commit 402749b005
10 changed files with 91 additions and 1 deletions
+2 -1
View File
@@ -14,4 +14,5 @@
* limitations under the License.
*/
export * from './service/plugin';
export * from './service/createScheduler';
export { lighthousePlugin } from './plugin';
+55
View File
@@ -0,0 +1,55 @@
/*
* 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 { CatalogClient } from '@backstage/catalog-client';
import { createScheduler } from './service/createScheduler';
/**
* Lighthouse backend plugin
*
* @public
*/
export const lighthousePlugin = createBackendPlugin({
pluginId: 'lighthouse',
register(env) {
env.registerInit({
deps: {
config: coreServices.config,
discovery: coreServices.discovery,
logger: coreServices.logger,
scheduler: coreServices.scheduler,
tokenManager: coreServices.tokenManager,
},
async init({ config, discovery, logger, scheduler, tokenManager }) {
const winstonLogger = loggerToWinstonLogger(logger);
const catalogClient = new CatalogClient({ discoveryApi: discovery });
await createScheduler({
catalogClient,
config,
logger: winstonLogger,
scheduler,
tokenManager,
});
},
});
},
});