From 5aca65cd356790b90cf51a034193ef95570e8a39 Mon Sep 17 00:00:00 2001 From: facchettos Date: Mon, 9 Sep 2024 13:54:01 +0200 Subject: [PATCH] [fix] : now prevents the generic syncer from continuously deleting objs --- pkg/controllers/generic/export_syncer.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/controllers/generic/export_syncer.go b/pkg/controllers/generic/export_syncer.go index b43eef266b..1c82802cf4 100644 --- a/pkg/controllers/generic/export_syncer.go +++ b/pkg/controllers/generic/export_syncer.go @@ -307,3 +307,18 @@ func (f *exporter) TranslateMetadata(ctx *synccontext.SyncContext, vObj client.O func (f *exporter) objectMatches(obj client.Object) bool { return f.selector == nil || f.selector.Matches(labels.Set(obj.GetLabels())) } + +var _ syncertypes.ObjectExcluder = &exporter{} + +func (f *exporter) ExcludeVirtual(vObj client.Object) bool { + return f.excludeObject(vObj) +} + +func (f *exporter) ExcludePhysical(_ client.Object) bool { + return false +} + +func (f *exporter) excludeObject(obj client.Object) bool { + matches := f.selector.Matches(labels.Set(obj.GetLabels())) + return !matches +}