Fix error printing objects from kubectl get -w

This commit is contained in:
Jordan Liggitt
2017-02-28 17:45:09 -05:00
parent 35c2e70dd1
commit 31b3e01f1e
7 changed files with 70 additions and 27 deletions

View File

@@ -253,8 +253,16 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
// print the current object
filteredResourceCount := 0
if !isWatchOnly {
if err := printer.PrintObj(obj, out); err != nil {
return fmt.Errorf("unable to output the provided object: %v", err)
var objsToPrint []runtime.Object
if isList {
objsToPrint, _ = meta.ExtractList(obj)
} else {
objsToPrint = append(objsToPrint, obj)
}
for _, objToPrint := range objsToPrint {
if err := printer.PrintObj(objToPrint, out); err != nil {
return fmt.Errorf("unable to output the provided object: %v", err)
}
}
filteredResourceCount++
cmdutil.PrintFilterCount(filteredResourceCount, mapping.Resource, filterOpts)