@@ -40,7 +40,6 @@
|
||||
"@backstage/plugin-azure-sites-backend": "workspace:^",
|
||||
"@backstage/plugin-badges-backend": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend-module-github": "workspace:^",
|
||||
"@backstage/plugin-catalog-node": "workspace:^",
|
||||
"@backstage/plugin-code-coverage-backend": "workspace:^",
|
||||
"@backstage/plugin-entity-feedback-backend": "workspace:^",
|
||||
|
||||
@@ -38,10 +38,11 @@ import {
|
||||
import { TaskScheduler } from '@backstage/backend-tasks';
|
||||
import { Config } from '@backstage/config';
|
||||
import healthcheck from './plugins/healthcheck';
|
||||
import { metricsHandler, metricsInit } from './metrics';
|
||||
import { metricsInit, metricsHandler } from './metrics';
|
||||
import auth from './plugins/auth';
|
||||
import azureDevOps from './plugins/azure-devops';
|
||||
import catalog from './plugins/catalog';
|
||||
import catalogEventBasedProviders from './plugins/catalogEventBasedProviders';
|
||||
import codeCoverage from './plugins/codecoverage';
|
||||
import entityFeedback from './plugins/entityFeedback';
|
||||
import events from './plugins/events';
|
||||
@@ -67,7 +68,6 @@ import linguist from './plugins/linguist';
|
||||
import { PluginEnvironment } from './types';
|
||||
import { ServerPermissionClient } from '@backstage/plugin-permission-node';
|
||||
import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
|
||||
import createCatalogEventBasedProviders from './plugins/catalogEventBasedProviders';
|
||||
|
||||
function makeCreateEnv(config: Config) {
|
||||
const root = getRootLogger();
|
||||
@@ -156,7 +156,7 @@ async function main() {
|
||||
const exploreEnv = useHotMemoize(module, () => createEnv('explore'));
|
||||
const lighthouseEnv = useHotMemoize(module, () => createEnv('lighthouse'));
|
||||
|
||||
const eventBasedEntityProviders = await createCatalogEventBasedProviders(
|
||||
const eventBasedEntityProviders = await catalogEventBasedProviders(
|
||||
catalogEnv,
|
||||
);
|
||||
const linguistEnv = useHotMemoize(module, () => createEnv('linguist'));
|
||||
|
||||
@@ -19,32 +19,14 @@ import { EntityProvider } from '@backstage/plugin-catalog-node';
|
||||
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend';
|
||||
import { Router } from 'express';
|
||||
import { PluginEnvironment } from '../types';
|
||||
import { InMemoryEventBroker } from '@backstage/plugin-events-backend';
|
||||
import { GithubEntityProvider } from '@backstage/plugin-catalog-backend-module-github';
|
||||
import { ConflictEventSubscriber } from './conflictEventSubscriber';
|
||||
|
||||
export default async function createPlugin(
|
||||
env: PluginEnvironment,
|
||||
providers?: Array<EntityProvider>,
|
||||
): Promise<Router> {
|
||||
const builder = await CatalogBuilder.create(env);
|
||||
const githubEntityProviders = GithubEntityProvider.fromConfig(env.config, {
|
||||
logger: env.logger,
|
||||
// optional: alternatively, use scheduler with schedule defined in app-config.yaml
|
||||
schedule: env.scheduler.createScheduledTaskRunner({
|
||||
frequency: { minutes: 5 },
|
||||
timeout: { minutes: 3 },
|
||||
}),
|
||||
scheduler: env.scheduler,
|
||||
});
|
||||
builder.addEntityProvider(githubEntityProviders);
|
||||
builder.addProcessor(new ScaffolderEntitiesProcessor());
|
||||
builder.addEntityProvider(providers ?? []);
|
||||
const conflictBroker = new InMemoryEventBroker(env.logger);
|
||||
conflictBroker.subscribe(
|
||||
new ConflictEventSubscriber(env.logger, ['conflicts']),
|
||||
);
|
||||
builder.setConflictEventBroker(conflictBroker);
|
||||
const { processingEngine, router } = await builder.build();
|
||||
await processingEngine.start();
|
||||
return router;
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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 {
|
||||
EntityProvider,
|
||||
EntityProviderConnection,
|
||||
} from '@backstage/plugin-catalog-node';
|
||||
import { EventParams, EventSubscriber } from '@backstage/plugin-events-node';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
export class ConflictEventSubscriber
|
||||
implements EntityProvider, EventSubscriber
|
||||
{
|
||||
constructor(
|
||||
private readonly logger: Logger,
|
||||
private readonly topics: string[],
|
||||
) {}
|
||||
|
||||
async onEvent(params: EventParams): Promise<void> {
|
||||
this.logger.info(
|
||||
`onEvent: topic=${params.topic}, metadata=${JSON.stringify(
|
||||
params.metadata,
|
||||
)}, payload=${JSON.stringify(params.eventPayload)}`,
|
||||
);
|
||||
}
|
||||
|
||||
supportsEventTopics(): string[] {
|
||||
return this.topics;
|
||||
}
|
||||
|
||||
async connect(_: EntityProviderConnection): Promise<void> {
|
||||
// not doing anything here
|
||||
}
|
||||
|
||||
getProviderName(): string {
|
||||
return ConflictEventSubscriber.name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user