reconciler: allow custom comparison function (#4727)

reconciler: allow custom comparison function (#4726)

Co-authored-by: Denis Mishin <dmishin@pomerium.com>
This commit is contained in:
backport-actions-token[bot] 2023-11-08 20:30:06 -05:00 committed by GitHub
parent da9b14db44
commit c9583c828c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 9 deletions

View file

@ -9,13 +9,13 @@ import (
// GetChangeSet returns list of changes between the current and target record sets,
// that may be applied to the databroker to bring it to the target state.
func GetChangeSet(current, target RecordSetBundle) []*Record {
func GetChangeSet(current, target RecordSetBundle, cmpFn RecordCompareFn) []*Record {
cs := &changeSet{now: timestamppb.Now()}
for _, rec := range current.GetRemoved(target).Flatten() {
cs.Remove(rec.GetType(), rec.GetId())
}
for _, rec := range current.GetModified(target).Flatten() {
for _, rec := range current.GetModified(target, cmpFn).Flatten() {
cs.Upsert(rec)
}
for _, rec := range current.GetAdded(target).Flatten() {