Skip to content

Commit

Permalink
fix: dont append
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
  • Loading branch information
vishal-chdhry committed Jul 4, 2024
1 parent a9b825d commit 45d5e86
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
16 changes: 8 additions & 8 deletions pkg/api/cephr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check failure on line 294 in pkg/api/cephr.go

View workflow job for this annotation

GitHub Actions / required

exporting a pointer for the loop variable pol (exportloopref)
}
} else {
events = append(events, watch.Event{
events[i] = watch.Event{
Type: watch.Modified,
Object: &p,
})
Object: &pol,

Check failure on line 299 in pkg/api/cephr.go

View workflow job for this annotation

GitHub Actions / required

exporting a pointer for the loop variable pol (exportloopref)
}
}

Check warning on line 301 in pkg/api/cephr.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/cephr.go#L281-L301

Added lines #L281 - L301 were not covered by tests
}
return c.broadcaster.WatchWithPrefix(events)

Check warning on line 303 in pkg/api/cephr.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/cephr.go#L303

Added line #L303 was not covered by tests
Expand Down
16 changes: 8 additions & 8 deletions pkg/api/cpolr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check failure on line 293 in pkg/api/cpolr.go

View workflow job for this annotation

GitHub Actions / required

exporting a pointer for the loop variable pol (exportloopref)
}
} else {
events = append(events, watch.Event{
events[i] = watch.Event{
Type: watch.Modified,
Object: &p,
})
Object: &pol,
}
}

Check warning on line 300 in pkg/api/cpolr.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/cpolr.go#L280-L300

Added lines #L280 - L300 were not covered by tests
}
return c.broadcaster.WatchWithPrefix(events)

Check warning on line 302 in pkg/api/cpolr.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/cpolr.go#L302

Added line #L302 was not covered by tests
Expand Down
16 changes: 8 additions & 8 deletions pkg/api/ephr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Check warning on line 321 in pkg/api/ephr.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/ephr.go#L301-L321

Added lines #L301 - L321 were not covered by tests
}
return p.broadcaster.WatchWithPrefix(events)

Check warning on line 323 in pkg/api/ephr.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/ephr.go#L323

Added line #L323 was not covered by tests
Expand Down
16 changes: 8 additions & 8 deletions pkg/api/polr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Check warning on line 321 in pkg/api/polr.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/polr.go#L301-L321

Added lines #L301 - L321 were not covered by tests
}
return p.broadcaster.WatchWithPrefix(events)

Check warning on line 323 in pkg/api/polr.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/polr.go#L323

Added line #L323 was not covered by tests
Expand Down

0 comments on commit 45d5e86

Please sign in to comment.