printer

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KeyColor    = color.Cyan
	StringColor = color.Green
	BoolColor   = color.MagentaLight
	NumberColor = color.Magenta
	NullColor   = color.Gray
	HeaderColor = color.GrayLight // for plain table
)

Functions

func ColorStatus

func ColorStatus(status string) (color.Color, bool)

Types

type ApplyPrinter

type ApplyPrinter struct{}

func (*ApplyPrinter) Print

func (ap *ApplyPrinter) Print(r io.Reader, w io.Writer)

kubectl apply deployment.apps/foo unchanged deployment.apps/bar created deployment.apps/quux configured

type DescribePrinter

type DescribePrinter struct {
	TablePrinter *TablePrinter
}

DescribePrinter is a specific printer to print kubectl describe format.

func (*DescribePrinter) Print

func (dp *DescribePrinter) Print(r io.Reader, w io.Writer)

type ExplainPrinter

type ExplainPrinter struct {
	Recursive bool
	// contains filtered or unexported fields
}

ExplainPrinter is a specific printer to print kubectl explain format.

func (*ExplainPrinter) Print

func (ep *ExplainPrinter) Print(r io.Reader, w io.Writer)

type JsonPrinter

type JsonPrinter struct {
}

func (*JsonPrinter) Print

func (jp *JsonPrinter) Print(r io.Reader, w io.Writer)

type KubectlOutputColoredPrinter

type KubectlOutputColoredPrinter struct {
	SubcommandInfo    *kubectl.SubcommandInfo
	Recursive         bool
	ObjFreshThreshold time.Duration
}

KubectlOutputColoredPrinter is a printer to print data depending on which kubectl subcommand is executed.

func (*KubectlOutputColoredPrinter) Print

func (kp *KubectlOutputColoredPrinter) Print(r io.Reader, w io.Writer)

Print reads r then write it to w, its format is based on kubectl subcommand. If given subcommand is not supported by the printer, it prints data in Green.

type OptionsPrinter

type OptionsPrinter struct{}

func (*OptionsPrinter) Print

func (op *OptionsPrinter) Print(r io.Reader, w io.Writer)

type Printer

type Printer interface {
	Print(r io.Reader, w io.Writer)
}

Printer can print something. It reads data from r, then write them in w.

type SingleColoredPrinter

type SingleColoredPrinter struct {
	Color color.Color
}

SingleColoredPrinter is a printer to print something in pre-cofigured color.

func (*SingleColoredPrinter) Print

func (sp *SingleColoredPrinter) Print(r io.Reader, w io.Writer)

Print reads r then writes it in w in sp.Color

type TablePrinter

type TablePrinter struct {
	WithHeader     bool
	ColorDeciderFn func(index int, column string) (color.Color, bool)
	// contains filtered or unexported fields
}

func NewTablePrinter

func NewTablePrinter(withHeader bool, colorDeciderFn func(index int, column string) (color.Color, bool)) *TablePrinter

func (*TablePrinter) Print

func (tp *TablePrinter) Print(r io.Reader, w io.Writer)

type VersionPrinter

type VersionPrinter struct {
	DarkBackground bool
}

func (*VersionPrinter) Print

func (vp *VersionPrinter) Print(r io.Reader, w io.Writer)

type VersionShortPrinter

type VersionShortPrinter struct{}

func (*VersionShortPrinter) Print

func (vsp *VersionShortPrinter) Print(r io.Reader, w io.Writer)

kubectl version --short format Client Version: v1.19.3 Server Version: v1.19.2

type WithFuncPrinter

type WithFuncPrinter struct {
	Fn func(line string) color.Color
}

WithFuncPrinter is a printer to print something based on injected logic.

func (*WithFuncPrinter) Print

func (wp *WithFuncPrinter) Print(r io.Reader, w io.Writer)

Print reads r then writes it in w but its color is decided by pre-injected function. The function must not be nil, otherwise it panics.

type YamlPrinter

type YamlPrinter struct {
}

func (*YamlPrinter) Print

func (yp *YamlPrinter) Print(r io.Reader, w io.Writer)

Jump to

Keyboard shortcuts

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