avoid panic when subresource is a list

Kubernetes-commit: 2e3b937dcdb02cab74213a5608cc4dac39c6423e
This commit is contained in:
Ryan McKinley
2024-09-09 09:40:38 +03:00
committed by Kubernetes Publisher
parent 51f5488cb9
commit fae3dcdbf6
2 changed files with 18 additions and 2 deletions

View File

@@ -289,11 +289,12 @@ func (c *dynamicResourceClient) Get(ctx context.Context, name string, opts metav
if err != nil {
return nil, err
}
uncastObj, err := runtime.Decode(unstructured.UnstructuredJSONScheme, retBytes)
obj := &unstructured.Unstructured{}
err = runtime.DecodeInto(unstructured.UnstructuredJSONScheme, retBytes, obj)
if err != nil {
return nil, err
}
return uncastObj.(*unstructured.Unstructured), nil
return obj, nil
}
func (c *dynamicResourceClient) List(ctx context.Context, opts metav1.ListOptions) (*unstructured.UnstructuredList, error) {