Skip to content

Commit bb84391

Browse files
committed
source: make the Informer source compatible with cache.Informer
Before fc804a4 (#267), the `cache.Informers` interface methods returned `k8s.io/client-go/tools/cache.SharedIndexInformer`s which were by default compatible with the built-in `source.Informer`. Users could create arbitrary `cache.Cache` instances (or get them from the `Manager`) and then use `controller.Watch` to drive a controller with a `source.Informer` from the `cache.Cache`. With fc804a4, the `cache.Informers` interface was changed to return `cache.Informer` instances; however, `source.Informer` was not updated to accept a `cache.Informer`, and so users can no longer use the built-in `source.Informer` with `cache.Cache`. The `cache.Informer` interface appears to satisfy the needs of `source.Informer`. This commit broadens `source.Informer` to accept a `cache.Informer`, restoring the prior capability while remaining compatible with `SharedIndexInformer` use.
1 parent 90226f9 commit bb84391

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pkg/source/source.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"sigs.k8s.io/controller-runtime/pkg/runtime/inject"
3030
"sigs.k8s.io/controller-runtime/pkg/source/internal"
3131

32-
toolscache "k8s.io/client-go/tools/cache"
3332
"sigs.k8s.io/controller-runtime/pkg/cache"
3433
"sigs.k8s.io/controller-runtime/pkg/predicate"
3534
)
@@ -243,8 +242,8 @@ func (cs *Channel) syncLoop() {
243242

244243
// Informer is used to provide a source of events originating inside the cluster from Watches (e.g. Pod Create)
245244
type Informer struct {
246-
// Informer is the generated client-go Informer
247-
Informer toolscache.SharedIndexInformer
245+
// Informer is the controller-runtime Informer
246+
Informer cache.Informer
248247
}
249248

250249
var _ Source = &Informer{}

0 commit comments

Comments
 (0)