Skip to content

Commit a1a470c

Browse files
authored
Merge pull request #46 from kcp-stuff/add-indexers-to-informers
fixes list issue #44
2 parents 49fa562 + ae4ce3d commit a1a470c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/kcp/wrappers.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121
"net/http"
2222
"regexp"
2323
"strings"
24+
"time"
2425

2526
"k8s.io/apimachinery/pkg/api/meta"
27+
"k8s.io/apimachinery/pkg/runtime"
2628
"k8s.io/client-go/rest"
2729
k8scache "k8s.io/client-go/tools/cache"
2830

@@ -67,12 +69,14 @@ func NewClusterAwareManager(cfg *rest.Config, options ctrl.Options) (manager.Man
6769
func NewClusterAwareCache(config *rest.Config, opts cache.Options) (cache.Cache, error) {
6870
c := rest.CopyConfig(config)
6971
c.Host += "/clusters/*"
70-
opts.NewInformerFunc = informers.NewSharedIndexInformer
7172

72-
opts.Indexers = k8scache.Indexers{
73-
kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc,
74-
kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc,
73+
opts.NewInformerFunc = func(lw k8scache.ListerWatcher, obj runtime.Object, syncPeriod time.Duration, indexers k8scache.Indexers) kcpcache.ScopeableSharedIndexInformer {
74+
indexers[kcpcache.ClusterIndexName] = kcpcache.ClusterIndexFunc
75+
indexers[kcpcache.ClusterAndNamespaceIndexName] = kcpcache.ClusterAndNamespaceIndexFunc
76+
77+
return informers.NewSharedIndexInformer(lw, obj, syncPeriod, indexers)
7578
}
79+
7680
return cache.New(c, opts)
7781
}
7882

0 commit comments

Comments
 (0)