address comments
This commit is contained in:
		@@ -19,7 +19,6 @@ package cmd
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"text/tabwriter"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/spf13/cobra"
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/meta"
 | 
						"k8s.io/kubernetes/pkg/api/meta"
 | 
				
			||||||
@@ -224,7 +223,7 @@ func RunGet(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
 | 
				
			|||||||
	// use the default printer for each object
 | 
						// use the default printer for each object
 | 
				
			||||||
	printer = nil
 | 
						printer = nil
 | 
				
			||||||
	var lastMapping *meta.RESTMapping
 | 
						var lastMapping *meta.RESTMapping
 | 
				
			||||||
	w := tabwriter.NewWriter(out, kubectl.TabwriterMinWidth, kubectl.TabwriterWidth, kubectl.TabwriterPadding, kubectl.TabwriterPadChar, kubectl.TabwriterFlags)
 | 
						w := kubectl.GetNewTabWriter(out)
 | 
				
			||||||
	defer w.Flush()
 | 
						defer w.Flush()
 | 
				
			||||||
	return b.Flatten().Do().Visit(func(r *resource.Info, err error) error {
 | 
						return b.Flatten().Do().Visit(func(r *resource.Info, err error) error {
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,11 +46,11 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	TabwriterMinWidth = 10
 | 
						tabwriterMinWidth = 10
 | 
				
			||||||
	TabwriterWidth    = 4
 | 
						tabwriterWidth    = 4
 | 
				
			||||||
	TabwriterPadding  = 3
 | 
						tabwriterPadding  = 3
 | 
				
			||||||
	TabwriterPadChar  = ' '
 | 
						tabwriterPadChar  = ' '
 | 
				
			||||||
	TabwriterFlags    = 0
 | 
						tabwriterFlags    = 0
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPrinter takes a format type, an optional format argument. It will return true
 | 
					// GetPrinter takes a format type, an optional format argument. It will return true
 | 
				
			||||||
@@ -1475,11 +1475,17 @@ func formatWideHeaders(wide bool, t reflect.Type) []string {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetNewTabWriter returns a tabwriter that translates tabbed columns in input into properly aligned text.
 | 
				
			||||||
 | 
					func GetNewTabWriter(output io.Writer) *tabwriter.Writer {
 | 
				
			||||||
 | 
						return tabwriter.NewWriter(output, tabwriterMinWidth, tabwriterWidth, tabwriterPadding, tabwriterPadChar, tabwriterFlags)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PrintObj prints the obj in a human-friendly format according to the type of the obj.
 | 
					// PrintObj prints the obj in a human-friendly format according to the type of the obj.
 | 
				
			||||||
func (h *HumanReadablePrinter) PrintObj(obj runtime.Object, output io.Writer) error {
 | 
					func (h *HumanReadablePrinter) PrintObj(obj runtime.Object, output io.Writer) error {
 | 
				
			||||||
 | 
						// if output is a tabwriter (when it's called by kubectl get), we use it; create a new tabwriter otherwise
 | 
				
			||||||
	w, found := output.(*tabwriter.Writer)
 | 
						w, found := output.(*tabwriter.Writer)
 | 
				
			||||||
	if !found {
 | 
						if !found {
 | 
				
			||||||
		w = tabwriter.NewWriter(output, TabwriterMinWidth, TabwriterWidth, TabwriterPadding, TabwriterPadChar, TabwriterFlags)
 | 
							w = GetNewTabWriter(output)
 | 
				
			||||||
		defer w.Flush()
 | 
							defer w.Flush()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	t := reflect.TypeOf(obj)
 | 
						t := reflect.TypeOf(obj)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user