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:
Andy Goldstein
2022-08-17 15:49:26 -04:00
committed by Kubernetes Publisher
parent d21defd4b1
commit 37897aff8d
5 changed files with 228 additions and 97 deletions

View File

@@ -120,7 +120,7 @@ func (f *dynamicSharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{})
func NewFilteredDynamicInformer(client dynamic.Interface, gvr schema.GroupVersionResource, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions TweakListOptionsFunc) informers.GenericInformer {
return &dynamicInformer{
gvr: gvr,
informer: cache.NewSharedIndexInformer(
informer: cache.NewSharedIndexInformerWithOptions(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
@@ -136,8 +136,11 @@ func NewFilteredDynamicInformer(client dynamic.Interface, gvr schema.GroupVersio
},
},
&unstructured.Unstructured{},
resyncPeriod,
indexers,
cache.SharedIndexInformerOptions{
ResyncPeriod: resyncPeriod,
Indexers: indexers,
ObjectDescription: gvr.String(),
},
),
}
}