util

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	NormalMsg  = "normal"
	SuccessMsg = "success"
	ErrorMsg   = "error"
)

Variables

View Source
var (
	Yellow       = color.New(color.FgHiYellow, color.Bold).SprintFunc()
	YellowItalic = color.New(color.FgHiYellow, color.Bold, color.Italic).SprintFunc()
	Green        = color.New(color.FgHiGreen, color.Bold).SprintFunc()
	Blue         = color.New(color.FgHiBlue, color.Bold).SprintFunc()
	Cyan         = color.New(color.FgCyan, color.Bold, color.Underline).SprintFunc()
	Red          = color.New(color.FgHiRed, color.Bold).SprintFunc()
	White        = color.New(color.FgWhite).SprintFunc()
	WhiteBold    = color.New(color.FgWhite, color.Bold).SprintFunc()
)

Functions

func AllDone added in v0.5.2

func AllDone(t time.Duration)

func BeforeTask added in v0.5.2

func BeforeTask(msg string)

func CheckErr

func CheckErr(err error)

CheckErr prints a user friendly error to STDERR

func IgnoreNotFoundErr

func IgnoreNotFoundErr(err error) error

func IsToTable

func IsToTable(printer *Printer) bool

IsToTable if printer output format want prilnt object detail,return false

func PrintInventory added in v0.5.2

func PrintInventory(inventory map[string]string)

func PrintOpenFunction added in v0.5.2

func PrintOpenFunction()

func TaskFail added in v0.5.2

func TaskFail(msg string) string

func ToTable

func ToTable(tableRow TableRow, objs ...runtime.Object) (*metav1.Table, error)

ToTable runtime.Object convert metav1.Table to facilitate printing

func TranslateTimestampSince

func TranslateTimestampSince(timestamp metav1.Time) string

func UsageErrorf

func UsageErrorf(cmd *cobra.Command, format string, args ...interface{}) error

Types

type MessageLevel

type MessageLevel string

type Printer

type Printer struct {
	PrintFlags  *genericclioptions.PrintFlags
	PrinterFunc PrinterFunc

	ForceDetail bool
}

func NewPrinter

func NewPrinter(operation string, scheme *runtime.Scheme) *Printer

func (*Printer) AddFlags

func (p *Printer) AddFlags(cmd *cobra.Command)

func (*Printer) SetForceDefail

func (p *Printer) SetForceDefail()

func (*Printer) SetPrinterFunc

func (p *Printer) SetPrinterFunc(fc PrinterFunc)

func (*Printer) ShouldPrintObject

func (p *Printer) ShouldPrintObject() bool

func (*Printer) ToPrinter

func (p *Printer) ToPrinter() (printers.ResourcePrinter, error)

func (*Printer) ToPrinterWitchColumn

func (p *Printer) ToPrinterWitchColumn(columnLabels []string) (printers.ResourcePrinter, error)

type PrinterFunc

type PrinterFunc func(*Printer) (printers.ResourcePrinter, error)

func WithDefaultPrinter

func WithDefaultPrinter(operation string) PrinterFunc

func WithTablePrinter

func WithTablePrinter(options printers.PrintOptions) PrinterFunc

type TableRow

type TableRow func(obj interface{}) (metav1.TableRow, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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