mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 21:53:52 +00:00
List output with differing types should be more resilient
kubectl get can output a series of objects as a List in versioned form, but not all API objects are available in the same schema. Make the act of converting a []runtime.Object to api.List more robust and add a test to verify its behavior in Get. Makes it easier for client code to output unified objects.
This commit is contained in:
@@ -53,7 +53,7 @@ func (s *Scheme) EncodeToVersion(obj interface{}, destVersion string) (data []by
|
||||
obj = maybeCopy(obj)
|
||||
v, _ := EnforcePtr(obj) // maybeCopy guarantees a pointer
|
||||
if _, registered := s.typeToVersion[v.Type()]; !registered {
|
||||
return nil, fmt.Errorf("type %v is not registered and it will be impossible to Decode it, therefore Encode will refuse to encode it.", v.Type())
|
||||
return nil, fmt.Errorf("type %v is not registered for %q and it will be impossible to Decode it, therefore Encode will refuse to encode it.", v.Type(), destVersion)
|
||||
}
|
||||
|
||||
objVersion, objKind, err := s.ObjectVersionAndKind(obj)
|
||||
|
Reference in New Issue
Block a user