mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Rename NewHumanReadablePrinter to NewTablePrinter
This commit is contained in:
parent
306740f81c
commit
bbc2886a3b
@ -87,7 +87,7 @@ func (f *HumanPrintFlags) ToPrinter(outputFormat string) (printers.ResourcePrint
|
||||
columnLabels = *f.ColumnLabels
|
||||
}
|
||||
|
||||
p := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
p := printers.NewTablePrinter(printers.PrintOptions{
|
||||
Kind: f.Kind,
|
||||
WithKind: showKind,
|
||||
NoHeaders: f.NoHeaders,
|
||||
|
@ -171,7 +171,7 @@ func TestPrintUnstructuredObject(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
out.Reset()
|
||||
printer := printers.NewHumanReadablePrinter(test.options).With(AddDefaultHandlers)
|
||||
printer := printers.NewTablePrinter(test.options).With(AddDefaultHandlers)
|
||||
printer.PrintObj(test.object, out)
|
||||
|
||||
matches, err := regexp.MatchString(test.expected, out.String())
|
||||
@ -299,7 +299,7 @@ func ErrorPrintHandler(obj *TestPrintType, options printers.PrintOptions) ([]met
|
||||
|
||||
func TestCustomTypePrinting(t *testing.T) {
|
||||
columns := []metav1beta1.TableColumnDefinition{{Name: "Data"}}
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{})
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{})
|
||||
printer.TableHandler(columns, PrintCustomType)
|
||||
|
||||
obj := TestPrintType{"test object"}
|
||||
@ -316,7 +316,7 @@ func TestCustomTypePrinting(t *testing.T) {
|
||||
|
||||
func TestPrintHandlerError(t *testing.T) {
|
||||
columns := []metav1beta1.TableColumnDefinition{{Name: "Data"}}
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{})
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{})
|
||||
printer.TableHandler(columns, ErrorPrintHandler)
|
||||
obj := TestPrintType{"test object"}
|
||||
buffer := &bytes.Buffer{}
|
||||
@ -327,7 +327,7 @@ func TestPrintHandlerError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUnknownTypePrinting(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{})
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{})
|
||||
buffer := &bytes.Buffer{}
|
||||
err := printer.PrintObj(&TestUnknownType{}, buffer)
|
||||
if err == nil {
|
||||
@ -588,10 +588,10 @@ func TestPrinters(t *testing.T) {
|
||||
|
||||
// a humanreadable printer deals with internal-versioned objects
|
||||
humanReadablePrinter := map[string]printers.ResourcePrinter{
|
||||
"humanReadable": printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
"humanReadable": printers.NewTablePrinter(printers.PrintOptions{
|
||||
NoHeaders: true,
|
||||
}),
|
||||
"humanReadableHeaders": printers.NewHumanReadablePrinter(printers.PrintOptions{}),
|
||||
"humanReadableHeaders": printers.NewTablePrinter(printers.PrintOptions{}),
|
||||
}
|
||||
AddHandlers((humanReadablePrinter["humanReadable"]).(*printers.HumanReadablePrinter))
|
||||
AddHandlers((humanReadablePrinter["humanReadableHeaders"]).(*printers.HumanReadablePrinter))
|
||||
@ -611,7 +611,7 @@ func TestPrinters(t *testing.T) {
|
||||
|
||||
func TestPrintEventsResultSorted(t *testing.T) {
|
||||
// Arrange
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{})
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{})
|
||||
AddHandlers(printer)
|
||||
|
||||
obj := api.EventList{
|
||||
@ -656,7 +656,7 @@ func TestPrintEventsResultSorted(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintNodeStatus(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{})
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{})
|
||||
AddHandlers(printer)
|
||||
table := []struct {
|
||||
node api.Node
|
||||
@ -746,7 +746,7 @@ func TestPrintNodeStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintNodeRole(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{})
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{})
|
||||
AddHandlers(printer)
|
||||
table := []struct {
|
||||
node api.Node
|
||||
@ -791,7 +791,7 @@ func TestPrintNodeRole(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintNodeOSImage(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{
|
||||
ColumnLabels: []string{},
|
||||
Wide: true,
|
||||
})
|
||||
@ -836,7 +836,7 @@ func TestPrintNodeOSImage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintNodeKernelVersion(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{
|
||||
ColumnLabels: []string{},
|
||||
Wide: true,
|
||||
})
|
||||
@ -881,7 +881,7 @@ func TestPrintNodeKernelVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintNodeContainerRuntimeVersion(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{
|
||||
ColumnLabels: []string{},
|
||||
Wide: true,
|
||||
})
|
||||
@ -926,7 +926,7 @@ func TestPrintNodeContainerRuntimeVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintNodeName(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{
|
||||
Wide: true,
|
||||
})
|
||||
AddHandlers(printer)
|
||||
@ -963,7 +963,7 @@ func TestPrintNodeName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintNodeExternalIP(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{
|
||||
Wide: true,
|
||||
})
|
||||
AddHandlers(printer)
|
||||
@ -1011,7 +1011,7 @@ func TestPrintNodeExternalIP(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintNodeInternalIP(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{
|
||||
Wide: true,
|
||||
})
|
||||
AddHandlers(printer)
|
||||
@ -1419,7 +1419,7 @@ func TestPrintHumanReadableWithNamespace(t *testing.T) {
|
||||
for i, test := range table {
|
||||
if test.isNamespaced {
|
||||
// Expect output to include namespace when requested.
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{
|
||||
WithNamespace: true,
|
||||
})
|
||||
AddHandlers(printer)
|
||||
@ -1434,7 +1434,7 @@ func TestPrintHumanReadableWithNamespace(t *testing.T) {
|
||||
}
|
||||
} else {
|
||||
// Expect error when trying to get all namespaces for un-namespaced object.
|
||||
printer := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
printer := printers.NewTablePrinter(printers.PrintOptions{
|
||||
WithNamespace: true,
|
||||
})
|
||||
buffer := &bytes.Buffer{}
|
||||
@ -1513,7 +1513,7 @@ func TestPrintPodTable(t *testing.T) {
|
||||
}
|
||||
verifyTable(t, table)
|
||||
buf := &bytes.Buffer{}
|
||||
p := printers.NewHumanReadablePrinter(test.opts).With(AddHandlers)
|
||||
p := printers.NewTablePrinter(test.opts).With(AddHandlers)
|
||||
if err := p.PrintObj(table, buf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -34,10 +34,10 @@ var _ ResourcePrinter = &HumanReadablePrinter{}
|
||||
|
||||
var withNamespacePrefixColumns = []string{"NAMESPACE"} // TODO(erictune): print cluster name too.
|
||||
|
||||
// NewHumanReadablePrinter creates a printer suitable for calling PrintObj().
|
||||
// NewTablePrinter creates a printer suitable for calling PrintObj().
|
||||
// TODO(seans3): Change return type to ResourcePrinter interface once we no longer need
|
||||
// to constuct the "handlerMap".
|
||||
func NewHumanReadablePrinter(options PrintOptions) *HumanReadablePrinter {
|
||||
func NewTablePrinter(options PrintOptions) *HumanReadablePrinter {
|
||||
printer := &HumanReadablePrinter{
|
||||
handlerMap: make(map[reflect.Type]*handlerEntry),
|
||||
options: options,
|
||||
|
Loading…
Reference in New Issue
Block a user