From ae4ce3dfdc44685089a7e87530285c54cac91620 Mon Sep 17 00:00:00 2001 From: Premkumar Bhaskal Date: Thu, 1 Feb 2024 23:08:59 +0530 Subject: [PATCH] fixes list issue #44 , adding the cluster and cluster-and-namespace index to informer Signed-off-by: Premkumar Bhaskal --- pkg/kcp/wrappers.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/kcp/wrappers.go b/pkg/kcp/wrappers.go index 570947950b..2e173ccbc6 100644 --- a/pkg/kcp/wrappers.go +++ b/pkg/kcp/wrappers.go @@ -21,8 +21,10 @@ import ( "net/http" "regexp" "strings" + "time" "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/rest" k8scache "k8s.io/client-go/tools/cache" @@ -67,12 +69,14 @@ func NewClusterAwareManager(cfg *rest.Config, options ctrl.Options) (manager.Man func NewClusterAwareCache(config *rest.Config, opts cache.Options) (cache.Cache, error) { c := rest.CopyConfig(config) c.Host += "/clusters/*" - opts.NewInformerFunc = informers.NewSharedIndexInformer - opts.Indexers = k8scache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc, + opts.NewInformerFunc = func(lw k8scache.ListerWatcher, obj runtime.Object, syncPeriod time.Duration, indexers k8scache.Indexers) kcpcache.ScopeableSharedIndexInformer { + indexers[kcpcache.ClusterIndexName] = kcpcache.ClusterIndexFunc + indexers[kcpcache.ClusterAndNamespaceIndexName] = kcpcache.ClusterAndNamespaceIndexFunc + + return informers.NewSharedIndexInformer(lw, obj, syncPeriod, indexers) } + return cache.New(c, opts) }