mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #12772 from smarterclayton/allow_nil_reflector
Allow a nil expectedType in cache.Reflector
This commit is contained in:
commit
50de5404dd
10
pkg/client/unversioned/cache/reflector.go
vendored
10
pkg/client/unversioned/cache/reflector.go
vendored
@ -79,10 +79,10 @@ func NewNamespaceKeyedIndexerAndReflector(lw ListerWatcher, expectedType interfa
|
|||||||
|
|
||||||
// NewReflector creates a new Reflector object which will keep the given store up to
|
// NewReflector creates a new Reflector object which will keep the given store up to
|
||||||
// date with the server's contents for the given resource. Reflector promises to
|
// date with the server's contents for the given resource. Reflector promises to
|
||||||
// only put things in the store that have the type of expectedType.
|
// only put things in the store that have the type of expectedType, unless expectedType
|
||||||
// If resyncPeriod is non-zero, then lists will be executed after every resyncPeriod,
|
// is nil. If resyncPeriod is non-zero, then lists will be executed after every
|
||||||
// so that you can use reflectors to periodically process everything as well as
|
// resyncPeriod, so that you can use reflectors to periodically process everything as
|
||||||
// incrementally processing the things that change.
|
// well as incrementally processing the things that change.
|
||||||
func NewReflector(lw ListerWatcher, expectedType interface{}, store Store, resyncPeriod time.Duration) *Reflector {
|
func NewReflector(lw ListerWatcher, expectedType interface{}, store Store, resyncPeriod time.Duration) *Reflector {
|
||||||
return NewNamedReflector(getDefaultReflectorName(internalPackages...), lw, expectedType, store, resyncPeriod)
|
return NewNamedReflector(getDefaultReflectorName(internalPackages...), lw, expectedType, store, resyncPeriod)
|
||||||
}
|
}
|
||||||
@ -265,7 +265,7 @@ loop:
|
|||||||
if event.Type == watch.Error {
|
if event.Type == watch.Error {
|
||||||
return apierrs.FromObject(event.Object)
|
return apierrs.FromObject(event.Object)
|
||||||
}
|
}
|
||||||
if e, a := r.expectedType, reflect.TypeOf(event.Object); e != a {
|
if e, a := r.expectedType, reflect.TypeOf(event.Object); e != nil && e != a {
|
||||||
util.HandleError(fmt.Errorf("%s: expected type %v, but watch event object had type %v", r.name, e, a))
|
util.HandleError(fmt.Errorf("%s: expected type %v, but watch event object had type %v", r.name, e, a))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user