table

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseTablePrinter

type BaseTablePrinter struct {
	IOStreams genericclioptions.IOStreams
	Columns   []ColumnDefinition
}

BaseTablePrinter provides functionality for printing information about a set of resources into a table format. The printer will print to the Out stream defined in IOStreams, and will print into the format defined by the Column definitions.

func (*BaseTablePrinter) PrintTable

func (t *BaseTablePrinter) PrintTable(rs ResourceStates,
	moveUpCount int) int

PrintTable prints the resources defined in ResourceStates. It will print subresources if they exist. moveUpCount defines how many lines the printer should move up before starting printing. The return value is how many lines were printed.

type ColumnDef

type ColumnDef struct {
	ColumnName        string
	ColumnHeader      string
	ColumnWidth       int
	PrintResourceFunc func(w io.Writer, width int, r Resource) (int, error)
}

ColumnDef is an implementation of the ColumnDefinition interface. It can be used to define simple columns that doesn't need additional knowledge about the actual type of the provided Resource besides the information available through the interface.

func MustColumn

func MustColumn(name string) ColumnDef

MustColumn returns the pre-defined column definition with the provided name. If the name doesn't exist, it will panic.

func (ColumnDef) Header

func (c ColumnDef) Header() string

Header returns the header that should be printed for the column.

func (ColumnDef) Name

func (c ColumnDef) Name() string

Name returns the name of the column.

func (ColumnDef) PrintResource

func (c ColumnDef) PrintResource(w io.Writer, width int, r Resource) (int, error)

PrintResource is called by the BaseTablePrinter to output the content of a particular column. This implementation just delegates to the provided PrintResourceFunc.

func (ColumnDef) Width

func (c ColumnDef) Width() int

Width returns the width of the column.

type ColumnDefinition

type ColumnDefinition interface {
	Name() string
	Header() string
	Width() int
	PrintResource(w io.Writer, width int, r Resource) (int, error)
}

ColumnDefinition defines the columns that should be printed.

type Resource

type Resource interface {
	Identifier() object.ObjMetadata
	ResourceStatus() *pe.ResourceStatus
	SubResources() []Resource
}

Resource defines the interface that each of the Resource objects must implement.

type ResourceStates

type ResourceStates interface {
	Resources() []Resource
	Error() error
}

ResourceStates defines the interface that must be implemented by the object that provides information about the resources that should be printed.

Jump to

Keyboard shortcuts

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