Merge pull request #29215 from Erob711/incremental-docs

docs: fix example location annotations in IncrementalEntityProvider
This commit is contained in:
Fredrik Adelöw
2025-03-25 11:03:58 +01:00
committed by GitHub
3 changed files with 29 additions and 6 deletions
@@ -1157,13 +1157,21 @@ export class MyIncrementalEntityProvider
The last step is to implement the actual `next` method that will accept the cursor, call the API, process the result and return the result.
```ts
import {
ANNOTATION_LOCATION,
ANNOTATION_ORIGIN_LOCATION,
} from '@backstage/catalog-model';
import { IncrementalEntityProvider } from '@backstage/plugin-catalog-backend-module-incremental-ingestion';
export class MyIncrementalEntityProvider
implements IncrementalEntityProvider<Cursor, Context>
{
private readonly token: string;
private readonly mySource: string;
constructor(token: string) {
constructor(token: string, mySource: string) {
this.token = token;
this.mySource = mySource;
}
getProviderName() {
@@ -1181,6 +1189,7 @@ export class MyIncrementalEntityProvider
cursor: Cursor = { page: 1 },
): Promise<EntityIteratorResult<Cursor>> {
const { apiClient } = context;
const location = `${this.getProviderName()}:${this.mySource}`;
// call your API with the current cursor
const data = await apiClient.getServices(cursor);
@@ -1200,8 +1209,8 @@ export class MyIncrementalEntityProvider
name: item.name,
annotations: {
// You need to define these, otherwise they'll fail validation
[ANNOTATION_LOCATION]: this.getProviderName(),
[ANNOTATION_ORIGIN_LOCATION]: this.getProviderName(),
[ANNOTATION_LOCATION]: location,
[ANNOTATION_ORIGIN_LOCATION]: location,
},
},
spec: {