From b2aef8193c34673bab4a08c7f5536cb0df76e4f0 Mon Sep 17 00:00:00 2001 From: Dan Mace Date: Wed, 3 Apr 2019 19:18:06 -0400 Subject: [PATCH] source: make the Informer source compatible with cache.Informer Before fc804a41 (#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 fc804a41, 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 `source.Informer`, restoring the prior capability while remaining compatible with `SharedIndexInformer` use. --- pkg/source/source.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/source/source.go b/pkg/source/source.go index 3d27bc4334..c777a8c719 100644 --- a/pkg/source/source.go +++ b/pkg/source/source.go @@ -29,7 +29,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/source/internal" - toolscache "k8s.io/client-go/tools/cache" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/predicate" ) @@ -243,8 +242,8 @@ func (cs *Channel) syncLoop() { // Informer is used to provide a source of events originating inside the cluster from Watches (e.g. Pod Create) type Informer struct { - // Informer is the generated client-go Informer - Informer toolscache.SharedIndexInformer + // Informer is the controller-runtime Informer + Informer cache.Informer } var _ Source = &Informer{}