mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #37142 from AdoHe/fix_kubectl_get_all
Automatic merge from submit-queue kubectl resource filter convert unstructured obj before apply filter … Fix #37128 @pwittrock @saad-ali ptal.
This commit is contained in:
		@@ -58,6 +58,17 @@ func filterPods(obj runtime.Object, options PrintOptions) bool {
 | 
			
		||||
 | 
			
		||||
// Filter loops through a collection of FilterFuncs until it finds one that can filter the given resource
 | 
			
		||||
func (f Filters) Filter(obj runtime.Object, opts *PrintOptions) (bool, error) {
 | 
			
		||||
	// check if the object is unstructured. If so, let's attempt to convert it to a type we can understand
 | 
			
		||||
	// before apply filter func.
 | 
			
		||||
	switch obj.(type) {
 | 
			
		||||
	case *runtime.UnstructuredList, *runtime.Unstructured, *runtime.Unknown:
 | 
			
		||||
		if objBytes, err := runtime.Encode(api.Codecs.LegacyCodec(), obj); err == nil {
 | 
			
		||||
			if decodedObj, err := runtime.Decode(api.Codecs.UniversalDecoder(), objBytes); err == nil {
 | 
			
		||||
				obj = decodedObj
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, filter := range f {
 | 
			
		||||
		if ok := filter(obj, *opts); ok {
 | 
			
		||||
			return true, nil
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user