diff --git a/plugins/catalog-backend/src/next/DefaultCatalogProcessingEngine.ts b/plugins/catalog-backend/src/next/DefaultCatalogProcessingEngine.ts index b1cfc33885..6e3f6589d2 100644 --- a/plugins/catalog-backend/src/next/DefaultCatalogProcessingEngine.ts +++ b/plugins/catalog-backend/src/next/DefaultCatalogProcessingEngine.ts @@ -72,13 +72,6 @@ class Connection implements EntityProviderConnection { removed: mutation.removed, }); }); - } else if (mutation.type === 'refresh') { - // await db.transaction(async tx => { - // await db.refreshUnprocessedEntities(tx, { - // match: mutation.match, - // }); - // }); - console.log('wopoop'); } } @@ -249,19 +242,8 @@ export class DefaultCatalogProcessingEngine implements CatalogProcessingEngine { async refresh(options: EntityRefreshOptions) { await this.processingDatabase.transaction(async tx => { - await this.processingDatabase.refreshUnprocessedEntities(tx, options); + await this.processingDatabase.refresh(tx, options); }); - // await Promise.all( - // this.entityProviders.map(async provider => { - // try { - // await provider.refresh?.(options); - // } catch (e) { - // throw new Error( - // `Provider ${provider.getProviderName()} failed refresh, ${e}`, - // ); - // } - // }), - // ); } } diff --git a/plugins/catalog-backend/src/next/DefaultLocationStore.ts b/plugins/catalog-backend/src/next/DefaultLocationStore.ts index 09eacc3955..c9ffe9a682 100644 --- a/plugins/catalog-backend/src/next/DefaultLocationStore.ts +++ b/plugins/catalog-backend/src/next/DefaultLocationStore.ts @@ -19,12 +19,10 @@ import { ConflictError, NotFoundError } from '@backstage/errors'; import { Knex } from 'knex'; import { v4 as uuid } from 'uuid'; import { DbLocationsRow } from './database/tables'; -import { RefreshStateMatch } from './database/types'; import { getEntityLocationRef } from './processing/util'; import { EntityProvider, EntityProviderConnection, - EntityRefreshOptions, LocationStore, } from './types'; import { locationSpecToLocationEntity } from './util'; @@ -137,22 +135,6 @@ export class DefaultLocationStore implements LocationStore, EntityProvider { }); } - async refresh(_options: EntityRefreshOptions) { - // const match: RefreshStateMatch = {}; - // // locationKey?: string; - // // entityRef?: string; - // if (options.entityRef) { - // match.entityRef = options.entityRef; - // } - // if (options.locationRef) { - // // TODO - // } - // await this.connection.applyMutation({ - // type: 'refresh', - // match, - // }); - } - private async locations(dbOrTx: Knex.Transaction | Knex = this.db) { const locations = await dbOrTx('locations').select(); return ( diff --git a/plugins/catalog-backend/src/next/database/DefaultProcessingDatabase.ts b/plugins/catalog-backend/src/next/database/DefaultProcessingDatabase.ts index 58a384457d..e46ad8dbb2 100644 --- a/plugins/catalog-backend/src/next/database/DefaultProcessingDatabase.ts +++ b/plugins/catalog-backend/src/next/database/DefaultProcessingDatabase.ts @@ -14,11 +14,7 @@ * limitations under the License. */ -import { - Entity, - LOCATION_ANNOTATION, - stringifyEntityRef, -} from '@backstage/catalog-model'; +import { Entity, stringifyEntityRef } from '@backstage/catalog-model'; import { JsonObject } from '@backstage/config'; import { ConflictError, NotFoundError } from '@backstage/errors'; import { Knex } from 'knex'; @@ -40,7 +36,7 @@ import { GetProcessableEntitiesResult, ProcessingDatabase, RefreshStateItem, - RefreshUnprocessedEntitiesOptions, + RefreshOptions, ReplaceUnprocessedEntitiesOptions, UpdateProcessedEntityOptions, } from './types'; @@ -515,11 +511,7 @@ export class DefaultProcessingDatabase implements ProcessingDatabase { }; } - // TODO(jhaals): Rename this to refreshEntity/refreshEntities? - async refreshUnprocessedEntities( - txOpaque: Transaction, - options: RefreshUnprocessedEntitiesOptions, - ): Promise { + async refresh(txOpaque: Transaction, options: RefreshOptions): Promise { const tx = txOpaque as Knex.Transaction; if ('entityRef' in options) { const { entityRef } = options; diff --git a/plugins/catalog-backend/src/next/database/types.ts b/plugins/catalog-backend/src/next/database/types.ts index e8ced9d250..509d9d0d0e 100644 --- a/plugins/catalog-backend/src/next/database/types.ts +++ b/plugins/catalog-backend/src/next/database/types.ts @@ -79,19 +79,10 @@ export type ReplaceUnprocessedEntitiesOptions = type: 'delta'; }; -export type RefreshStateMatch = { - locationKey?: string; - entityRef?: string; - parentOfEntityRef: string; +export type RefreshOptions = { + entityRef: string; }; -export type RefreshUnprocessedEntitiesOptions = - | { - // match: RefreshStateMatch; - entityRef: string; - } - | { locationRef: string }; - export interface ProcessingDatabase { transaction(fn: (tx: Transaction) => Promise): Promise; @@ -121,8 +112,5 @@ export interface ProcessingDatabase { options: UpdateProcessedEntityErrorsOptions, ): Promise; - refreshUnprocessedEntities( - txOpaque: Transaction, - options: RefreshUnprocessedEntitiesOptions, - ): Promise; + refresh(txOpaque: Transaction, options: RefreshOptions): Promise; } diff --git a/plugins/catalog-backend/src/next/types.ts b/plugins/catalog-backend/src/next/types.ts index 0c34a873ff..91c8c47fe4 100644 --- a/plugins/catalog-backend/src/next/types.ts +++ b/plugins/catalog-backend/src/next/types.ts @@ -15,7 +15,6 @@ */ import { Entity, Location, LocationSpec } from '@backstage/catalog-model'; -import { RefreshStateMatch } from './database/types'; import { DeferredEntity } from './processing/types'; export interface LocationService { @@ -41,12 +40,9 @@ export interface CatalogProcessingEngine { refresh(options: EntityRefreshOptions): Promise; } -export type EntityRefreshOptions = - | { entityRef: string } // example: component:default/backstage - | { locationRef: string }; // example: url:https://github.com/backstage/backstage/blob/master/catalog-info.yaml +export type EntityRefreshOptions = { entityRef: string }; export type EntityProviderMutation = - | { type: 'refresh'; match: RefreshStateMatch } // TODO(jhaals): Should this really use a type from the db? | { type: 'full'; entities: DeferredEntity[] } | { type: 'delta'; added: DeferredEntity[]; removed: DeferredEntity[] }; @@ -57,5 +53,4 @@ export interface EntityProviderConnection { export interface EntityProvider { getProviderName(): string; connect(connection: EntityProviderConnection): Promise; - refresh?(options: EntityRefreshOptions): Promise; }