Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vishal-chdhry committed Jul 7, 2024
2 parents d873c19 + 3dd1083 commit 862c7c4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 58 deletions.
13 changes: 3 additions & 10 deletions pkg/api/cephr.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,9 @@ func (c *cephrStore) Watch(ctx context.Context, options *metainternalversion.Lis
events := make([]watch.Event, len(list.Items))
for i, pol := range list.Items {
report := pol.DeepCopy()
if report.Generation == 1 || report.Generation == 0 {
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
} else {
events[i] = watch.Event{
Type: watch.Modified,
Object: report,
}
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
}
return c.broadcaster.WatchWithPrefix(events)
Expand Down
13 changes: 3 additions & 10 deletions pkg/api/cpolr.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,9 @@ func (c *cpolrStore) Watch(ctx context.Context, options *metainternalversion.Lis
events := make([]watch.Event, len(list.Items))
for i, pol := range list.Items {
report := pol.DeepCopy()
if report.Generation == 1 || report.Generation == 0 {
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
} else {
events[i] = watch.Event{
Type: watch.Modified,
Object: report,
}
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
}
return c.broadcaster.WatchWithPrefix(events)
Expand Down
13 changes: 3 additions & 10 deletions pkg/api/ephr.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,9 @@ func (p *ephrStore) Watch(ctx context.Context, options *metainternalversion.List
events := make([]watch.Event, len(list.Items))
for i, pol := range list.Items {
report := pol.DeepCopy()
if report.Generation == 1 || report.Generation == 0 {
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
} else {
events[i] = watch.Event{
Type: watch.Modified,
Object: report,
}
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
}
return p.broadcaster.WatchWithPrefix(events)
Expand Down
34 changes: 16 additions & 18 deletions pkg/api/filter.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
package api

import (
"strconv"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
)

func allowObjectListWatch(object metav1.ObjectMeta, labelSelector labels.Selector, desiredRv uint64, rvmatch metav1.ResourceVersionMatch) (bool, uint64, error) {
rv, err := strconv.ParseUint(object.ResourceVersion, 10, 64)
if err != nil {
return false, 0, err
}
// rv, err := strconv.ParseUint(object.ResourceVersion, 10, 64)
// if err != nil {
// return false, 0, err
// }

switch rvmatch {
case metav1.ResourceVersionMatchExact:
if rv != desiredRv {
return false, 0, nil
}
default:
if rv < desiredRv {
return false, 0, nil
}
}
// switch rvmatch {
// case metav1.ResourceVersionMatchExact:
// if rv != desiredRv {
// return false, 0, nil
// }
// default:
// if rv < desiredRv {
// return false, 0, nil
// }
// }

if labelSelector == nil {
return true, rv, nil
return true, 1, nil
}

if labelSelector.Matches(labels.Set(object.Labels)) {
return true, rv, nil
return true, 1, nil
} else {
return false, 0, nil
}
Expand Down
13 changes: 3 additions & 10 deletions pkg/api/polr.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,9 @@ func (p *polrStore) Watch(ctx context.Context, options *metainternalversion.List
events := make([]watch.Event, len(list.Items))
for i, pol := range list.Items {
report := pol.DeepCopy()
if report.Generation == 1 || report.Generation == 0 {
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
} else {
events[i] = watch.Event{
Type: watch.Modified,
Object: report,
}
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
}
return p.broadcaster.WatchWithPrefix(events)
Expand Down

0 comments on commit 862c7c4

Please sign in to comment.