printer

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

AllOutputFormats is a list of all possible output formats.

Functions

func GetAllOutputFormatStrings

func GetAllOutputFormatStrings() []string

GetAllOutputFormatStrings returns a list of all possible output formats as a slice of strings.

func GetPrinter

func GetPrinter(output OutputFormat) (printers.ResourcePrinter, error)

GetPrinter returns the ResourcePrinter associated with output. Most implementations are taken from cli-runtime itself, so we don't need to really implement too much.

func MaybeAppendTimeAgo

func MaybeAppendTimeAgo(kvs [][]string, key string, t *metav1.Time) [][]string

MaybeAppendTimeAgo is a helper that appends a key-value description pair to kvs if t is non-zero, formatted as a time with relative duration from now.

func PrintObject

func PrintObject(gvk schema.GroupVersionKind, output OutputFormat, out io.Writer, object Object) error

PrintObject will print a single object using the printer corresponding to the specified output format.

func PrintObjects

func PrintObjects(gvk schema.GroupVersionKind, output OutputFormat, out io.Writer, objs []Object) error

PrintObjects takes the list of items and converts it to a single List, before printing it with PrintObject.

Types

type DescriptionPrinter

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

DescriptionPrinter prints key-value pairs, separated by sections.

func NewDescriptionPrinter

func NewDescriptionPrinter(out io.Writer) *DescriptionPrinter

func (*DescriptionPrinter) Descriptions

func (p *DescriptionPrinter) Descriptions(kvs [][]string)

func (*DescriptionPrinter) Divider

func (p *DescriptionPrinter) Divider()

func (*DescriptionPrinter) Header

func (p *DescriptionPrinter) Header(header string)

func (*DescriptionPrinter) NewLine

func (p *DescriptionPrinter) NewLine()

func (*DescriptionPrinter) Print

func (p *DescriptionPrinter) Print(kvs [][]string)

Print prints each of the given key-value pairs.

type NamePrinter

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

NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object. This printer extends the default printers.NamePrinter to work with lists by assuming that all items have a GroupVersionKind already set.

func NewNamePrinter

func NewNamePrinter() *NamePrinter

func (*NamePrinter) PrintObj

func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error

type Object

type Object interface {
	schema.ObjectKind
	runtime.Object
}

Object is a runtime object that also has a Kind.

type OutputFormat

type OutputFormat string

OutputFormat specifies a format to print output.

const (
	OutputFormatPretty OutputFormat = "pretty"
	OutputFormatDetail OutputFormat = "detail"
	OutputFormatName   OutputFormat = "name"
	OutputFormatJSON   OutputFormat = "json"
	OutputFormatYAML   OutputFormat = "yaml"
)

func (OutputFormat) IsValid

func (f OutputFormat) IsValid() bool

type Section

type Section struct {
	Name  string
	Descs [][]string
}

Section contains a section name and a list of description key-value pairs.

type SectionGenerator

type SectionGenerator func() (Section, error)

func ToSectionGenerator

func ToSectionGenerator(section Section) SectionGenerator

ToSectionGenerator converts a Section into a SectionGenerator.

type TablePrinter

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

TablePrinter prints tables with header and body rows. TODO(irvinlim): Maybe we could use printers.TablePrinter instead of rolling our own.

func NewTablePrinter

func NewTablePrinter(out io.Writer) *TablePrinter

func (*TablePrinter) Print

func (p *TablePrinter) Print(header []string, rows [][]string)

Print the header and each row to standard output.

Jump to

Keyboard shortcuts

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