Skip to content

Commit 19f9afe

Browse files
authored
Merge pull request kubernetes-sigs#1775 from kmodules/lf
🐛 Trim List if List GVK is provided
2 parents b8db76e + b84b9bb commit 19f9afe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/cache/informer_cache.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ func (ip *informerCache) objectTypeForListObject(list client.ObjectList) (*schem
9696
return nil, nil, err
9797
}
9898

99-
if !strings.HasSuffix(gvk.Kind, "List") {
100-
return nil, nil, fmt.Errorf("non-list type %T (kind %q) passed as output", list, gvk)
101-
}
10299
// we need the non-list GVK, so chop off the "List" from the end of the kind
103-
gvk.Kind = gvk.Kind[:len(gvk.Kind)-4]
100+
if strings.HasSuffix(gvk.Kind, "List") && apimeta.IsListType(list) {
101+
gvk.Kind = gvk.Kind[:len(gvk.Kind)-4]
102+
}
103+
104104
_, isUnstructured := list.(*unstructured.UnstructuredList)
105105
var cacheTypeObj runtime.Object
106106
if isUnstructured {

0 commit comments

Comments
 (0)