printers

package
v0.65.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2021 License: Apache-2.0 Imports: 13 Imported by: 4 modules, 23 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// YAMLType represents a printer of YAML type.
	YAMLType = Type("yaml")
	// JSONType represents a printer of JSON type.
	JSONType = Type("json")
	// TableType represents a printer of Table type.
	TableType = Type("table")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONPrinter

type JSONPrinter struct {
	// contains filtered or unexported fields
}

JSONPrinter is a printer that outputs an object formatted as JSON

func (*JSONPrinter) LogObj

func (j *JSONPrinter) LogObj(log logger.LoggerFunc, msgFmt string, obj interface{}) error

LogObj will print the passed object formatted as JSON to the logger.

func (*JSONPrinter) PrintObj

func (j *JSONPrinter) PrintObj(obj interface{}, writer io.Writer) error

PrintObj will print the passed object formatted as JSON to the supplied writer.

func (*JSONPrinter) PrintObjWithKind

func (j *JSONPrinter) PrintObjWithKind(kind string, obj interface{}, writer io.Writer) error

PrintObjWithKind will print the passed object formatted as YAML to the supplied writer. This printer ignores kind argument.

type OutputPrinter

type OutputPrinter interface {
	PrintObjWithKind(kind string, obj interface{}, writer io.Writer) error
	PrintObj(obj interface{}, writer io.Writer) error
	LogObj(log logger.LoggerFunc, msgFmt string, obj interface{}) error
}

OutputPrinter is the interface that printer must implement. This allows new printers to be added in the future.

func NewJSONPrinter

func NewJSONPrinter() OutputPrinter

NewJSONPrinter creates a new JsonPrinter with defaults for level of indentation.

func NewPrinter

func NewPrinter(printerType Type) (OutputPrinter, error)

NewPrinter creates a new printer based in the printer type requested.

func NewTablePrinter

func NewTablePrinter() OutputPrinter

NewTablePrinter creates a new TablePrinter with defaults.

func NewYAMLPrinter

func NewYAMLPrinter() OutputPrinter

NewYAMLPrinter creates a new YAMLPrinter

type TablePrinter

type TablePrinter struct {
	// contains filtered or unexported fields
}

TablePrinter is a printer that outputs an object formatted as table

func (*TablePrinter) AddColumn

func (t *TablePrinter) AddColumn(name string, getter interface{})

AddColumn adds a column to the table that will be printed

func (*TablePrinter) LogObj

func (t *TablePrinter) LogObj(log logger.LoggerFunc, msgFmt string, obj interface{}) error

LogObj will print the passed object formatted as a table to the logger.

func (*TablePrinter) PrintObj

func (t *TablePrinter) PrintObj(obj interface{}, writer io.Writer) error

PrintObj will print the passed object formatted as textual table to the supplied writer.

func (*TablePrinter) PrintObjWithKind

func (t *TablePrinter) PrintObjWithKind(kind string, obj interface{}, writer io.Writer) error

PrintObjWithKind will print the passed object formatted as textual table to the supplied writer.

type Type

type Type = string

Type is the type representing all supported printer types.

type YAMLPrinter

type YAMLPrinter struct {
	// contains filtered or unexported fields
}

YAMLPrinter is a printer that outputs an object formatted as YAML

func (*YAMLPrinter) LogObj

func (y *YAMLPrinter) LogObj(log logger.LoggerFunc, msgFmt string, obj interface{}) error

LogObj will print the passed object formatted as YAML to the logger.

func (*YAMLPrinter) PrintObj

func (y *YAMLPrinter) PrintObj(obj interface{}, writer io.Writer) error

PrintObj will print the passed object formatted as YAML to the supplied writer.

func (*YAMLPrinter) PrintObjWithKind

func (y *YAMLPrinter) PrintObjWithKind(kind string, obj interface{}, writer io.Writer) error

PrintObjWithKind will print the passed object formatted as YAML to the supplied writer. This printer ignores kind argument.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL