chore: rename printers to avoid stuttering

This commit is contained in:
Karl Isenberg 2022-02-09 13:38:17 -08:00
parent 280f3e2c8f
commit 8dfc33dd8e
3 changed files with 16 additions and 16 deletions

View File

@ -14,15 +14,15 @@ import (
"sigs.k8s.io/cli-utils/pkg/object"
)
// EventPrinter implements the Printer interface and outputs the resource
// Printer implements the Printer interface and outputs the resource
// status information as a list of events as they happen.
type EventPrinter struct {
type Printer struct {
IOStreams genericclioptions.IOStreams
}
// NewEventPrinter returns a new instance of the eventPrinter.
func NewEventPrinter(ioStreams genericclioptions.IOStreams) *EventPrinter {
return &EventPrinter{
// NewPrinter returns a new instance of the eventPrinter.
func NewPrinter(ioStreams genericclioptions.IOStreams) *Printer {
return &Printer{
IOStreams: ioStreams,
}
}
@ -31,7 +31,7 @@ func NewEventPrinter(ioStreams genericclioptions.IOStreams) *EventPrinter {
// until the channel is closed. The provided cancelFunc is consulted on
// every event and is responsible for stopping the poller when appropriate.
// This function will block.
func (ep *EventPrinter) Print(ch <-chan pollevent.Event, identifiers object.ObjMetadataSet,
func (ep *Printer) Print(ch <-chan pollevent.Event, identifiers object.ObjMetadataSet,
cancelFunc collector.ObserverFunc) error {
coll := collector.NewResourceStatusCollector(identifiers)
// The actual work is done by the collector, which will invoke the
@ -52,7 +52,7 @@ func (ep *EventPrinter) Print(ch <-chan pollevent.Event, identifiers object.ObjM
return err
}
func (ep *EventPrinter) printStatusEvent(se pollevent.Event) {
func (ep *Printer) printStatusEvent(se pollevent.Event) {
switch se.Type {
case pollevent.ResourceUpdateEvent:
id := se.Resource.Identifier

View File

@ -16,8 +16,8 @@ import (
func CreatePrinter(printerType string, ioStreams genericclioptions.IOStreams) (printer.Printer, error) {
switch printerType {
case "table":
return table.NewTablePrinter(ioStreams), nil
return table.NewPrinter(ioStreams), nil
default:
return event.NewEventPrinter(ioStreams), nil
return event.NewPrinter(ioStreams), nil
}
}

View File

@ -18,22 +18,22 @@ const (
updateInterval = 1 * time.Second
)
// TablePrinter is an implementation of the Printer interface that outputs
// Printer is an implementation of the Printer interface that outputs
// status information about resources in a table format with in-place updates.
type TablePrinter struct {
type Printer struct {
IOStreams genericclioptions.IOStreams
}
// NewTablePrinter returns a new instance of the tablePrinter.
func NewTablePrinter(ioStreams genericclioptions.IOStreams) *TablePrinter {
return &TablePrinter{
// NewPrinter returns a new instance of the tablePrinter.
func NewPrinter(ioStreams genericclioptions.IOStreams) *Printer {
return &Printer{
IOStreams: ioStreams,
}
}
// Print take an event channel and outputs the status events on the channel
// until the channel is closed .
func (t *TablePrinter) Print(ch <-chan event.Event, identifiers object.ObjMetadataSet,
func (t *Printer) Print(ch <-chan event.Event, identifiers object.ObjMetadataSet,
cancelFunc collector.ObserverFunc) error {
coll := collector.NewResourceStatusCollector(identifiers)
stop := make(chan struct{})
@ -76,7 +76,7 @@ var columns = []table.ColumnDefinition{
// Print prints the table of resources with their statuses until the
// provided stop channel is closed.
func (t *TablePrinter) runPrintLoop(coll *CollectorAdapter, stop <-chan struct{}) <-chan struct{} {
func (t *Printer) runPrintLoop(coll *CollectorAdapter, stop <-chan struct{}) <-chan struct{} {
finished := make(chan struct{})
baseTablePrinter := table.BaseTablePrinter{