Skip to content

Commit

Permalink
source: make the Informer source compatible with cache.Informer
Browse files Browse the repository at this point in the history
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
`source.Informer`, restoring the prior capability while remaining compatible
with `SharedIndexInformer` use.
  • Loading branch information
ironcladlou committed Apr 3, 2019
1 parent 90226f9 commit b2aef81
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/source/source.go
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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{}
Expand Down

0 comments on commit b2aef81

Please sign in to comment.