Skip to content

Commit 1ebacf2

Browse files
committed
UPSTREAM: SQUASH: instantiate kube index informers by default
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
1 parent d9d2080 commit 1ebacf2

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

pkg/cache/cache.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"net/http"
2323
"time"
2424

25-
"github.com/kcp-dev/apimachinery/v2/third_party/informers"
2625
"golang.org/x/exp/maps"
2726
corev1 "k8s.io/api/core/v1"
2827
"k8s.io/apimachinery/pkg/api/meta"
@@ -486,7 +485,7 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
486485
}
487486

488487
if opts.NewInformerFunc == nil {
489-
opts.NewInformerFunc = informers.NewSharedIndexInformer
488+
opts.NewInformerFunc = toolscache.NewSharedIndexInformer
490489
}
491490
return opts, nil
492491
}

pkg/cache/internal/informers.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import (
2424
"sync"
2525
"time"
2626

27-
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
28-
"github.com/kcp-dev/apimachinery/v2/third_party/informers"
2927
apierrors "k8s.io/apimachinery/pkg/api/errors"
3028
"k8s.io/apimachinery/pkg/api/meta"
3129
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -48,7 +46,7 @@ type InformersOpts struct {
4846
Mapper meta.RESTMapper
4947
ResyncPeriod time.Duration
5048
Namespace string
51-
NewInformer func(cache.ListerWatcher, runtime.Object, time.Duration, cache.Indexers) kcpcache.ScopeableSharedIndexInformer
49+
NewInformer func(cache.ListerWatcher, runtime.Object, time.Duration, cache.Indexers) cache.SharedIndexInformer
5250
Selector Selector
5351
Transform cache.TransformFunc
5452
UnsafeDisableDeepCopy bool
@@ -57,7 +55,7 @@ type InformersOpts struct {
5755

5856
// NewInformers creates a new InformersMap that can create informers under the hood.
5957
func NewInformers(config *rest.Config, options *InformersOpts) *Informers {
60-
newInformer := informers.NewSharedIndexInformer
58+
newInformer := cache.NewSharedIndexInformer
6159
if options.NewInformer != nil {
6260
newInformer = options.NewInformer
6361
}
@@ -177,7 +175,7 @@ type Informers struct {
177175
unsafeDisableDeepCopy bool
178176

179177
// NewInformer allows overriding of the shared index informer constructor for testing.
180-
newInformer func(cache.ListerWatcher, runtime.Object, time.Duration, cache.Indexers) kcpcache.ScopeableSharedIndexInformer
178+
newInformer func(cache.ListerWatcher, runtime.Object, time.Duration, cache.Indexers) cache.SharedIndexInformer
181179

182180
// WatchErrorHandler allows the shared index informer's
183181
// watchErrorHandler to be set by overriding the options

pkg/client/interfaces.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"time"
2222

23-
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
2423
apierrors "k8s.io/apimachinery/pkg/api/errors"
2524
"k8s.io/apimachinery/pkg/runtime/schema"
2625
"k8s.io/client-go/tools/cache"
@@ -49,7 +48,7 @@ type Patch interface {
4948

5049
// NewInformerFunc describes a function that creates SharedIndexInformers.
5150
// Its signature matches cache.NewSharedIndexInformer from client-go.
52-
type NewInformerFunc func(cache.ListerWatcher, runtime.Object, time.Duration, cache.Indexers) kcpcache.ScopeableSharedIndexInformer
51+
type NewInformerFunc func(cache.ListerWatcher, runtime.Object, time.Duration, cache.Indexers) cache.SharedIndexInformer
5352

5453
// TODO(directxman12): is there a sane way to deal with get/delete options?
5554

pkg/kcp/wrappers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func NewClusterAwareCache(config *rest.Config, opts cache.Options) (cache.Cache,
7070
c := rest.CopyConfig(config)
7171
c.Host += "/clusters/*"
7272

73-
opts.NewInformerFunc = func(lw k8scache.ListerWatcher, obj runtime.Object, syncPeriod time.Duration, indexers k8scache.Indexers) kcpcache.ScopeableSharedIndexInformer {
73+
opts.NewInformerFunc = func(lw k8scache.ListerWatcher, obj runtime.Object, syncPeriod time.Duration, indexers k8scache.Indexers) k8scache.SharedIndexInformer {
7474
indexers[kcpcache.ClusterIndexName] = kcpcache.ClusterIndexFunc
7575
indexers[kcpcache.ClusterAndNamespaceIndexName] = kcpcache.ClusterAndNamespaceIndexFunc
7676

0 commit comments

Comments
 (0)