From b84b9bb0e29c91a5868425551cf20a6b8ba00d6a Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Wed, 12 Jan 2022 13:27:45 -0800 Subject: [PATCH] Trim List if List GVK is provided Signed-off-by: Tamal Saha --- pkg/cache/informer_cache.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cache/informer_cache.go b/pkg/cache/informer_cache.go index 90647c8e33..c5a25ca179 100644 --- a/pkg/cache/informer_cache.go +++ b/pkg/cache/informer_cache.go @@ -96,11 +96,11 @@ func (ip *informerCache) objectTypeForListObject(list client.ObjectList) (*schem return nil, nil, err } - if !strings.HasSuffix(gvk.Kind, "List") { - return nil, nil, fmt.Errorf("non-list type %T (kind %q) passed as output", list, gvk) - } // we need the non-list GVK, so chop off the "List" from the end of the kind - gvk.Kind = gvk.Kind[:len(gvk.Kind)-4] + if strings.HasSuffix(gvk.Kind, "List") && apimeta.IsListType(list) { + gvk.Kind = gvk.Kind[:len(gvk.Kind)-4] + } + _, isUnstructured := list.(*unstructured.UnstructuredList) var cacheTypeObj runtime.Object if isUnstructured {