catalog-backend: ignore relations when comparing entities

This commit is contained in:
Fredrik Adelöw
2020-12-10 12:07:32 +01:00
parent 6349ea7a16
commit 0e6298f7e3
2 changed files with 13 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/catalog-model': patch
---
Ignore relations when comparing entities. This stops the refresh loop from rewriting entities over and over.
@@ -46,6 +46,10 @@ export function generateEntityEtag(): string {
* are added or existing annotations were changed (since they are effectively
* merged when doing updates).
*
* Note that this comparison does NOT take state, relations or similar into
* account. It only compares the actual input entity data, i.e. metadata and
* spec.
*
* @param previous The old state of the entity
* @param next The new state of the entity
*/
@@ -76,6 +80,10 @@ export function entityHasChanges(previous: Entity, next: Entity): boolean {
delete e1.metadata.annotations;
delete e2.metadata.annotations;
// Remove things that we explicitly do not compare
delete e1.relations;
delete e2.relations;
return !lodash.isEqual(e1, e2);
}