mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #15667 from JanetKuo/kubectl-watch-list
Auto commit by PR queue bot
This commit is contained in:
		@@ -808,7 +808,6 @@ __EOF__
 | 
				
			|||||||
  ######################
 | 
					  ######################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  kube::log::status "Testing kubectl(${version}:multiple resources)"
 | 
					  kube::log::status "Testing kubectl(${version}:multiple resources)"
 | 
				
			||||||
  # TODO: add test for types like ReplicationControllerList, ServiceList
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  FILES="hack/testdata/multi-resource-yaml
 | 
					  FILES="hack/testdata/multi-resource-yaml
 | 
				
			||||||
  hack/testdata/multi-resource-list
 | 
					  hack/testdata/multi-resource-list
 | 
				
			||||||
@@ -866,8 +865,13 @@ __EOF__
 | 
				
			|||||||
      fi
 | 
					      fi
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    # Command
 | 
					    # Command
 | 
				
			||||||
    # kubectl create -f "${file}" "${kube_flags[@]}" # test fails here now
 | 
					 | 
				
			||||||
    kubectl get -f "${file}" "${kube_flags[@]}"
 | 
					    kubectl get -f "${file}" "${kube_flags[@]}"
 | 
				
			||||||
 | 
					    # Command: watching multiple resources should return "not supported" error
 | 
				
			||||||
 | 
					    WATCH_ERROR_FILE="${KUBE_TEMP}/kubectl-watch-error"
 | 
				
			||||||
 | 
					    kubectl get -f "${file}" "${kube_flags[@]}" "--watch" 2> ${WATCH_ERROR_FILE} || true
 | 
				
			||||||
 | 
					    if ! grep -q "watch is only supported on individual resources and resource collections" "${WATCH_ERROR_FILE}"; then
 | 
				
			||||||
 | 
					      kube::log::error_exit "kubectl watch multiple resource returns unexpected error or non-error: $(cat ${WATCH_ERROR_FILE})" "1"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
    kubectl describe -f "${file}" "${kube_flags[@]}"
 | 
					    kubectl describe -f "${file}" "${kube_flags[@]}"
 | 
				
			||||||
    # Command
 | 
					    # Command
 | 
				
			||||||
    kubectl replace -f $replace_file --force "${kube_flags[@]}"
 | 
					    kubectl replace -f $replace_file --force "${kube_flags[@]}"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -146,7 +146,7 @@ func RunGet(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
 | 
				
			|||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if len(infos) != 1 {
 | 
							if len(infos) != 1 {
 | 
				
			||||||
			return fmt.Errorf("watch is only supported on a single resource - %d resources were found", len(infos))
 | 
								return fmt.Errorf("watch is only supported on individual resources and resource collections - %d resources were found", len(infos))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		info := infos[0]
 | 
							info := infos[0]
 | 
				
			||||||
		mapping := info.ResourceMapping()
 | 
							mapping := info.ResourceMapping()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -199,7 +199,7 @@ func (r *Result) Watch(resourceVersion string) (watch.Interface, error) {
 | 
				
			|||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if len(info) != 1 {
 | 
							if len(info) != 1 {
 | 
				
			||||||
			return nil, fmt.Errorf("watch is only supported on a single resource - %d resources were found", len(info))
 | 
								return nil, fmt.Errorf("watch is only supported on individual resources and resource collections - %d resources were found", len(info))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return info[0].Watch(resourceVersion)
 | 
							return info[0].Watch(resourceVersion)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -564,6 +564,9 @@ func RetrieveLatest(info *Info, err error) error {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if runtime.IsListType(info.Object) {
 | 
				
			||||||
 | 
							return fmt.Errorf("watch is only supported on individual resources and resource collections, but a list of resources is found")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if len(info.Name) == 0 {
 | 
						if len(info.Name) == 0 {
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user