mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-05 09:01:06 +00:00
Reflector: support logging Unstructured type
Add an annotation that can be added to the exampleType passed to NewReflector to indicate the expected type for the Reflector. This is useful for types such as unstuctured.Unstructured, which, when used with a dynamic informer, do not have their TypeMeta filled in. Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com> Kubernetes-commit: 474fc8c5234000bce666a6b02f7ffbb295ef135f
This commit is contained in:
committed by
Kubernetes Publisher
parent
d21defd4b1
commit
37897aff8d
14
tools/cache/controller.go
vendored
14
tools/cache/controller.go
vendored
@@ -50,11 +50,12 @@ type Config struct {
|
||||
Process ProcessFunc
|
||||
|
||||
// ObjectType is an example object of the type this controller is
|
||||
// expected to handle. Only the type needs to be right, except
|
||||
// that when that is `unstructured.Unstructured` the object's
|
||||
// `"apiVersion"` and `"kind"` must also be right.
|
||||
// expected to handle.
|
||||
ObjectType runtime.Object
|
||||
|
||||
// ObjectDescription is the description to use when logging type-specific information about this controller.
|
||||
ObjectDescription string
|
||||
|
||||
// FullResyncPeriod is the period at which ShouldResync is considered.
|
||||
FullResyncPeriod time.Duration
|
||||
|
||||
@@ -131,11 +132,14 @@ func (c *controller) Run(stopCh <-chan struct{}) {
|
||||
<-stopCh
|
||||
c.config.Queue.Close()
|
||||
}()
|
||||
r := NewReflector(
|
||||
r := NewReflectorWithOptions(
|
||||
c.config.ListerWatcher,
|
||||
c.config.ObjectType,
|
||||
c.config.Queue,
|
||||
c.config.FullResyncPeriod,
|
||||
ReflectorOptions{
|
||||
ResyncPeriod: c.config.FullResyncPeriod,
|
||||
TypeDescription: c.config.ObjectDescription,
|
||||
},
|
||||
)
|
||||
r.ShouldResync = c.config.ShouldResync
|
||||
r.WatchListPageSize = c.config.WatchListPageSize
|
||||
|
Reference in New Issue
Block a user