From 45d5e867605ff2d566fb21a58dd8c0b4dd1d982c Mon Sep 17 00:00:00 2001 From: Vishal Choudhary Date: Thu, 4 Jul 2024 19:16:05 +0530 Subject: [PATCH] fix: dont append Signed-off-by: Vishal Choudhary --- pkg/api/cephr.go | 16 ++++++++-------- pkg/api/cpolr.go | 16 ++++++++-------- pkg/api/ephr.go | 16 ++++++++-------- pkg/api/polr.go | 16 ++++++++-------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/pkg/api/cephr.go b/pkg/api/cephr.go index b155a6f..ede852c 100644 --- a/pkg/api/cephr.go +++ b/pkg/api/cephr.go @@ -287,17 +287,17 @@ func (c *cephrStore) Watch(ctx context.Context, options *metainternalversion.Lis return nil, fmt.Errorf("failed to convert runtime object into cluster ephemeral report list") } events := make([]watch.Event, len(list.Items)) - for _, p := range list.Items { - if p.Generation == 1 || p.Generation == 0 { - events = append(events, watch.Event{ + for i, pol := range list.Items { + if pol.Generation == 1 || pol.Generation == 0 { + events[i] = watch.Event{ Type: watch.Added, - Object: &p, - }) + Object: &pol, + } } else { - events = append(events, watch.Event{ + events[i] = watch.Event{ Type: watch.Modified, - Object: &p, - }) + Object: &pol, + } } } return c.broadcaster.WatchWithPrefix(events) diff --git a/pkg/api/cpolr.go b/pkg/api/cpolr.go index 710d753..525d161 100644 --- a/pkg/api/cpolr.go +++ b/pkg/api/cpolr.go @@ -286,17 +286,17 @@ func (c *cpolrStore) Watch(ctx context.Context, options *metainternalversion.Lis return nil, fmt.Errorf("failed to convert runtime object into cluster policy report list") } events := make([]watch.Event, len(list.Items)) - for _, p := range list.Items { - if p.Generation == 1 || p.Generation == 0 { - events = append(events, watch.Event{ + for i, pol := range list.Items { + if pol.Generation == 1 || pol.Generation == 0 { + events[i] = watch.Event{ Type: watch.Added, - Object: &p, - }) + Object: &pol, + } } else { - events = append(events, watch.Event{ + events[i] = watch.Event{ Type: watch.Modified, - Object: &p, - }) + Object: &pol, + } } } return c.broadcaster.WatchWithPrefix(events) diff --git a/pkg/api/ephr.go b/pkg/api/ephr.go index 24d214c..d90955e 100644 --- a/pkg/api/ephr.go +++ b/pkg/api/ephr.go @@ -307,17 +307,17 @@ func (p *ephrStore) Watch(ctx context.Context, options *metainternalversion.List return nil, fmt.Errorf("failed to convert runtime object into ephemeral report list") } events := make([]watch.Event, len(list.Items)) - for _, p := range list.Items { - if p.Generation == 1 || p.Generation == 0 { - events = append(events, watch.Event{ + for i, pol := range list.Items { + if pol.Generation == 1 || pol.Generation == 0 { + events[i] = watch.Event{ Type: watch.Added, - Object: &p, - }) + Object: &pol, + } } else { - events = append(events, watch.Event{ + events[i] = watch.Event{ Type: watch.Modified, - Object: &p, - }) + Object: &pol, + } } } return p.broadcaster.WatchWithPrefix(events) diff --git a/pkg/api/polr.go b/pkg/api/polr.go index f970329..dfe9574 100644 --- a/pkg/api/polr.go +++ b/pkg/api/polr.go @@ -307,17 +307,17 @@ func (p *polrStore) Watch(ctx context.Context, options *metainternalversion.List return nil, fmt.Errorf("failed to convert runtime object into policy report list") } events := make([]watch.Event, len(list.Items)) - for _, p := range list.Items { - if p.Generation == 1 || p.Generation == 0 { - events = append(events, watch.Event{ + for i, pol := range list.Items { + if pol.Generation == 1 || pol.Generation == 0 { + events[i] = watch.Event{ Type: watch.Added, - Object: &p, - }) + Object: &pol, + } } else { - events = append(events, watch.Event{ + events[i] = watch.Event{ Type: watch.Modified, - Object: &p, - }) + Object: &pol, + } } } return p.broadcaster.WatchWithPrefix(events)