@@ -417,7 +417,7 @@ follows.
|
||||
{
|
||||
// ...
|
||||
"status": {
|
||||
"backstage.io/processing-status": {
|
||||
"backstage.io/catalog-processing": {
|
||||
"errors": []
|
||||
}
|
||||
},
|
||||
@@ -428,9 +428,9 @@ follows.
|
||||
```
|
||||
|
||||
The keys of the `status` object are arbitrary strings. We recommend that any
|
||||
statuses, that are not strictly private within the organization, be namespaced
|
||||
to avoid collisions. Statuses emitted by Backstage core processes will for
|
||||
example be prefixed with `backstage.io/` as in the example above.
|
||||
statuses that are not strictly private within the organization be namespaced to
|
||||
avoid collisions. Statuses emitted by Backstage core processes will for example
|
||||
be prefixed with `backstage.io/` as in the example above.
|
||||
|
||||
The values of the `status` object are currently left unrestricted, except that
|
||||
they must be objects. We reserve the right to extend this model in the future,
|
||||
|
||||
@@ -27,7 +27,7 @@ a standard concept of "severity" or "level" to these.
|
||||
|
||||
This is a (non-exhaustive) list of statuses that are known to be in active use.
|
||||
|
||||
### `backstage.io/processing-status`
|
||||
### `backstage.io/catalog-processing`
|
||||
|
||||
Contains the current status of the catalog's ingestion of this entity. Errors
|
||||
that may appear here include inability to read from the remote SCM provider,
|
||||
@@ -42,7 +42,7 @@ successfully ingested. This is normal.
|
||||
```yaml
|
||||
# Example:
|
||||
status:
|
||||
backstage.io/processing-status:
|
||||
backstage.io/catalog-processing:
|
||||
errors: []
|
||||
```
|
||||
|
||||
|
||||
@@ -92,9 +92,7 @@ describe('Stitcher', () => {
|
||||
},
|
||||
],
|
||||
status: {
|
||||
'backstage.io/processing-status': {
|
||||
errors: [],
|
||||
},
|
||||
'backstage.io/catalog-processing': {},
|
||||
},
|
||||
apiVersion: 'a',
|
||||
kind: 'k',
|
||||
@@ -177,9 +175,7 @@ describe('Stitcher', () => {
|
||||
},
|
||||
]),
|
||||
status: {
|
||||
'backstage.io/processing-status': {
|
||||
errors: [],
|
||||
},
|
||||
'backstage.io/catalog-processing': {},
|
||||
},
|
||||
apiVersion: 'a',
|
||||
kind: 'k',
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { Entity, parseEntityRef } from '@backstage/catalog-model';
|
||||
import { JsonObject } from '@backstage/config';
|
||||
import { ConflictError } from '@backstage/errors';
|
||||
import { createHash } from 'crypto';
|
||||
import stableStringify from 'fast-json-stable-stringify';
|
||||
@@ -35,6 +36,10 @@ export type DbFinalEntitiesRow = {
|
||||
final_entity: string;
|
||||
};
|
||||
|
||||
type ProcessingStatus = {
|
||||
errors?: JsonObject[];
|
||||
};
|
||||
|
||||
function generateStableHash(entity: Entity) {
|
||||
return createHash('sha1')
|
||||
.update(stableStringify({ ...entity }))
|
||||
@@ -134,6 +139,7 @@ export class Stitcher {
|
||||
// it
|
||||
const entity = JSON.parse(processedEntity) as Entity;
|
||||
const isOrphan = Number(incomingReferenceCount) === 0;
|
||||
const processingStatus: ProcessingStatus = {};
|
||||
|
||||
if (isOrphan) {
|
||||
this.logger.debug(`${entityRef} is an orphan`);
|
||||
@@ -142,15 +148,13 @@ export class Stitcher {
|
||||
['backstage.io/orphan']: 'true',
|
||||
};
|
||||
}
|
||||
if (errors !== '') {
|
||||
if (errors) {
|
||||
const parsedErrors = JSON.parse(errors);
|
||||
entity.status = {
|
||||
...entity.status,
|
||||
'backstage.io/processing-status': {
|
||||
errors: parsedErrors,
|
||||
},
|
||||
};
|
||||
if (Array.isArray(parsedErrors) && parsedErrors.length) {
|
||||
processingStatus.errors = parsedErrors;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: entityRef is lower case and should be uppercase in the final
|
||||
// result
|
||||
entity.relations = result
|
||||
@@ -159,6 +163,10 @@ export class Stitcher {
|
||||
type: row.relationType!,
|
||||
target: parseEntityRef(row.relationTarget!),
|
||||
}));
|
||||
entity.status = {
|
||||
...entity.status,
|
||||
'backstage.io/catalog-processing': processingStatus,
|
||||
};
|
||||
|
||||
// If the output entity was actually not changed, just abort
|
||||
const hash = generateStableHash(entity);
|
||||
|
||||
Reference in New Issue
Block a user