@@ -40,6 +40,7 @@
|
||||
"@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:^",
|
||||
|
||||
@@ -311,3 +311,29 @@ export type Cursor = {
|
||||
*/
|
||||
totalItems?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* The details of the conflicting entity.
|
||||
*/
|
||||
export type CatalogConflictEventPayload = {
|
||||
/**
|
||||
* The new conflicting entity
|
||||
*/
|
||||
entity: Entity;
|
||||
/**
|
||||
* The new conflicting entity's ref
|
||||
*/
|
||||
entityRef: string;
|
||||
/**
|
||||
* The location key of this new conflicting entity
|
||||
*/
|
||||
newLocationKey: string;
|
||||
/**
|
||||
* The location key of the entity already in the catalog that shares the same name and namespace as this entity
|
||||
*/
|
||||
existingLocationKey: string;
|
||||
/**
|
||||
* The datetime that the conflict was processed at
|
||||
*/
|
||||
lastConflictAt: string;
|
||||
};
|
||||
|
||||
@@ -44,9 +44,10 @@ import { checkLocationKeyConflict } from './operations/refreshState/checkLocatio
|
||||
import { insertUnprocessedEntity } from './operations/refreshState/insertUnprocessedEntity';
|
||||
import { updateUnprocessedEntity } from './operations/refreshState/updateUnprocessedEntity';
|
||||
import { generateStableHash } from './util';
|
||||
import { EventBroker } from '@backstage/plugin-events-node';
|
||||
import { EventBroker, EventParams } from '@backstage/plugin-events-node';
|
||||
import { DateTime } from 'luxon';
|
||||
import { CATALOG_CONFLICTS_TOPIC } from '../constants';
|
||||
import { CatalogConflictEventPayload } from '../catalog/types';
|
||||
|
||||
// The number of items that are sent per batch to the database layer, when
|
||||
// doing .batchInsert calls to knex. This needs to be low enough to not cause
|
||||
@@ -360,8 +361,8 @@ export class DefaultProcessingDatabase implements ProcessingDatabase {
|
||||
this.options.logger.warn(
|
||||
`Detected conflicting entityRef ${entityRef} already referenced by ${conflictingKey} and now also ${locationKey}`,
|
||||
);
|
||||
if (this.options.eventBroker) {
|
||||
await this.options.eventBroker?.publish({
|
||||
if (this.options.eventBroker && locationKey) {
|
||||
const eventParams: EventParams<CatalogConflictEventPayload> = {
|
||||
topic: CATALOG_CONFLICTS_TOPIC,
|
||||
eventPayload: {
|
||||
entity,
|
||||
@@ -370,7 +371,8 @@ export class DefaultProcessingDatabase implements ProcessingDatabase {
|
||||
existingLocationKey: conflictingKey,
|
||||
lastConflictAt: DateTime.now().toISO(),
|
||||
},
|
||||
});
|
||||
};
|
||||
await this.options.eventBroker?.publish(eventParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5142,7 +5142,7 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/plugin-catalog-backend-module-github@workspace:plugins/catalog-backend-module-github":
|
||||
"@backstage/plugin-catalog-backend-module-github@workspace:^, @backstage/plugin-catalog-backend-module-github@workspace:plugins/catalog-backend-module-github":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-catalog-backend-module-github@workspace:plugins/catalog-backend-module-github"
|
||||
dependencies:
|
||||
@@ -23482,6 +23482,7 @@ __metadata:
|
||||
"@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:^"
|
||||
|
||||
Reference in New Issue
Block a user