Skip to content

Commit

Permalink
catalog-backend: ignore relations when comparing entities
Browse files Browse the repository at this point in the history
  • Loading branch information
freben committed Dec 10, 2020
1 parent 6349ea7 commit 0e6298f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-ducks-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/catalog-model': patch
---

Ignore relations when comparing entities. This stops the refresh loop from rewriting entities over and over.
8 changes: 8 additions & 0 deletions packages/catalog-model/src/entity/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 0e6298f

Please sign in to comment.