package printers
import "k8s.io/kubernetes/pkg/printers"
Index ¶
- func GetNewTabWriter(output io.Writer) *tabwriter.Writer
- func RelaxedJSONPathExpression(pathExpression string) (string, error)
- func ShortHumanDuration(d time.Duration) string
- type Column
- type CustomColumnsPrinter
- func NewCustomColumnsPrinterFromSpec(spec string, decoder runtime.Decoder, noHeaders bool) (*CustomColumnsPrinter, error)
- func NewCustomColumnsPrinterFromTemplate(templateReader io.Reader, decoder runtime.Decoder) (*CustomColumnsPrinter, error)
- func (s *CustomColumnsPrinter) AfterPrint(w io.Writer, res string) error
- func (s *CustomColumnsPrinter) HandledResources() []string
- func (s *CustomColumnsPrinter) PrintObj(obj runtime.Object, out io.Writer) error
- type Describer
- type DescriberSettings
- type ErrNoDescriber
- type HumanReadablePrinter
- func NewHumanReadablePrinter(encoder runtime.Encoder, decoder runtime.Decoder, options PrintOptions) *HumanReadablePrinter
- func (h *HumanReadablePrinter) AfterPrint(output io.Writer, res string) error
- func (h *HumanReadablePrinter) EnsurePrintHeaders()
- func (h *HumanReadablePrinter) EnsurePrintWithKind(kind string)
- func (h *HumanReadablePrinter) GetResourceKind() string
- func (h *HumanReadablePrinter) HandledResources() []string
- func (h *HumanReadablePrinter) Handler(columns, columnsWithWide []string, printFunc interface{}) error
- func (h *HumanReadablePrinter) PrintObj(obj runtime.Object, output io.Writer) error
- type JSONPathPrinter
- func NewJSONPathPrinter(tmpl string) (*JSONPathPrinter, error)
- func (j *JSONPathPrinter) AfterPrint(w io.Writer, res string) error
- func (p *JSONPathPrinter) HandledResources() []string
- func (j *JSONPathPrinter) PrintObj(obj runtime.Object, w io.Writer) error
- type JSONPrinter
- func (p *JSONPrinter) AfterPrint(w io.Writer, res string) error
- func (p *JSONPrinter) HandledResources() []string
- func (p *JSONPrinter) PrintObj(obj runtime.Object, w io.Writer) error
- type NamePrinter
- func (p *NamePrinter) AfterPrint(w io.Writer, res string) error
- func (p *NamePrinter) HandledResources() []string
- func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error
- type ObjectDescriber
- type PrintOptions
- type ResourcePrinter
- func GetStandardPrinter(format, formatArgument string, noHeaders, allowMissingTemplateKeys bool, mapper meta.RESTMapper, typer runtime.ObjectTyper, decoders []runtime.Decoder) (ResourcePrinter, bool, error)
- func NewVersionedPrinter(printer ResourcePrinter, converter runtime.ObjectConvertor, versions ...schema.GroupVersion) ResourcePrinter
- type ResourcePrinterFunc
- func (fn ResourcePrinterFunc) AfterPrint(io.Writer, string) error
- func (fn ResourcePrinterFunc) HandledResources() []string
- func (fn ResourcePrinterFunc) PrintObj(obj runtime.Object, w io.Writer) error
- type TemplatePrinter
- func NewTemplatePrinter(tmpl []byte) (*TemplatePrinter, error)
- func (p *TemplatePrinter) AfterPrint(w io.Writer, res string) error
- func (p *TemplatePrinter) AllowMissingKeys(allow bool)
- func (p *TemplatePrinter) HandledResources() []string
- func (p *TemplatePrinter) PrintObj(obj runtime.Object, w io.Writer) error
- type VersionedPrinter
- func (p *VersionedPrinter) AfterPrint(w io.Writer, res string) error
- func (p *VersionedPrinter) HandledResources() []string
- func (p *VersionedPrinter) PrintObj(obj runtime.Object, w io.Writer) error
- type YAMLPrinter
Functions ¶
func GetNewTabWriter ¶
GetNewTabWriter returns a tabwriter that translates tabbed columns in input into properly aligned text.
func RelaxedJSONPathExpression ¶
RelaxedJSONPathExpression attempts to be flexible with JSONPath expressions, it accepts:
- metadata.name (no leading '.' or curly brances '{...}'
- {metadata.name} (no leading '.')
- .metadata.name (no curly braces '{...}')
- {.metadata.name} (complete expression)
And transforms them all into a valid jsonpath expression:
{.metadata.name}
func ShortHumanDuration ¶
Types ¶
type Column ¶
type Column struct { // The header to print above the column, general style is ALL_CAPS Header string // The pointer to the field in the object to print in JSONPath form // e.g. {.ObjectMeta.Name}, see pkg/util/jsonpath for more details. FieldSpec string }
Column represents a user specified column
type CustomColumnsPrinter ¶
CustomColumnPrinter is a printer that knows how to print arbitrary columns of data from templates specified in the `Columns` array
func NewCustomColumnsPrinterFromSpec ¶
func NewCustomColumnsPrinterFromSpec(spec string, decoder runtime.Decoder, noHeaders bool) (*CustomColumnsPrinter, error)
NewCustomColumnsPrinterFromSpec creates a custom columns printer from a comma separated list of <header>:<jsonpath-field-spec> pairs. e.g. NAME:metadata.name,API_VERSION:apiVersion creates a printer that prints:
NAME API_VERSION foo bar
func NewCustomColumnsPrinterFromTemplate ¶
func NewCustomColumnsPrinterFromTemplate(templateReader io.Reader, decoder runtime.Decoder) (*CustomColumnsPrinter, error)
NewCustomColumnsPrinterFromTemplate creates a custom columns printer from a template stream. The template is expected to consist of two lines, whitespace separated. The first line is the header line, the second line is the jsonpath field spec For example, the template below: NAME API_VERSION {metadata.name} {apiVersion}
func (*CustomColumnsPrinter) AfterPrint ¶
func (s *CustomColumnsPrinter) AfterPrint(w io.Writer, res string) error
func (*CustomColumnsPrinter) HandledResources ¶
func (s *CustomColumnsPrinter) HandledResources() []string
func (*CustomColumnsPrinter) PrintObj ¶
type Describer ¶
type Describer interface { Describe(namespace, name string, describerSettings DescriberSettings) (output string, err error) }
Describer generates output for the named resource or an error if the output could not be generated. Implementers typically abstract the retrieval of the named object from a remote server.
type DescriberSettings ¶
type DescriberSettings struct { ShowEvents bool }
DescriberSettings holds display configuration for each object describer to control what is printed.
type ErrNoDescriber ¶
type ErrNoDescriber struct { Types []string }
ErrNoDescriber is a structured error indicating the provided object or objects cannot be described.
func (ErrNoDescriber) Error ¶
func (e ErrNoDescriber) Error() string
Error implements the error interface.
type HumanReadablePrinter ¶
type HumanReadablePrinter struct {
// contains filtered or unexported fields
}
HumanReadablePrinter is an implementation of ResourcePrinter which attempts to provide more elegant output. It is not threadsafe, but you may call PrintObj repeatedly; headers will only be printed if the object type changes. This makes it useful for printing items received from watches.
func NewHumanReadablePrinter ¶
func NewHumanReadablePrinter(encoder runtime.Encoder, decoder runtime.Decoder, options PrintOptions) *HumanReadablePrinter
NewHumanReadablePrinter creates a HumanReadablePrinter. If encoder and decoder are provided, an attempt to convert unstructured types to internal types is made.
func (*HumanReadablePrinter) AfterPrint ¶
func (h *HumanReadablePrinter) AfterPrint(output io.Writer, res string) error
func (*HumanReadablePrinter) EnsurePrintHeaders ¶
func (h *HumanReadablePrinter) EnsurePrintHeaders()
EnsurePrintHeaders sets the HumanReadablePrinter option "NoHeaders" to false and removes the .lastType that was printed, which forces headers to be printed in cases where multiple lists of the same resource are printed consecutively, but are separated by non-printer related information.
func (*HumanReadablePrinter) EnsurePrintWithKind ¶
func (h *HumanReadablePrinter) EnsurePrintWithKind(kind string)
EnsurePrintWithKind sets HumanReadablePrinter options "WithKind" to true and "Kind" to the string arg it receives, pre-pending this string to the "NAME" column in an output of resources.
func (*HumanReadablePrinter) GetResourceKind ¶
func (h *HumanReadablePrinter) GetResourceKind() string
GetResourceKind returns the type currently set for a resource
func (*HumanReadablePrinter) HandledResources ¶
func (h *HumanReadablePrinter) HandledResources() []string
func (*HumanReadablePrinter) Handler ¶
func (h *HumanReadablePrinter) Handler(columns, columnsWithWide []string, printFunc interface{}) error
Handler adds a print handler with a given set of columns to HumanReadablePrinter instance. See validatePrintHandlerFunc for required method signature.
func (*HumanReadablePrinter) PrintObj ¶
PrintObj prints the obj in a human-friendly format according to the type of the obj.
type JSONPathPrinter ¶
JSONPathPrinter is an implementation of ResourcePrinter which formats data with jsonpath expression.
func NewJSONPathPrinter ¶
func NewJSONPathPrinter(tmpl string) (*JSONPathPrinter, error)
func (*JSONPathPrinter) AfterPrint ¶
func (j *JSONPathPrinter) AfterPrint(w io.Writer, res string) error
func (*JSONPathPrinter) HandledResources ¶
func (p *JSONPathPrinter) HandledResources() []string
TODO: implement HandledResources()
func (*JSONPathPrinter) PrintObj ¶
PrintObj formats the obj with the JSONPath Template.
type JSONPrinter ¶
type JSONPrinter struct { }
JSONPrinter is an implementation of ResourcePrinter which outputs an object as JSON.
func (*JSONPrinter) AfterPrint ¶
func (p *JSONPrinter) AfterPrint(w io.Writer, res string) error
func (*JSONPrinter) HandledResources ¶
func (p *JSONPrinter) HandledResources() []string
TODO: implement HandledResources()
func (*JSONPrinter) PrintObj ¶
PrintObj is an implementation of ResourcePrinter.PrintObj which simply writes the object to the Writer.
type NamePrinter ¶
type NamePrinter struct { Decoders []runtime.Decoder Typer runtime.ObjectTyper Mapper meta.RESTMapper }
NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object.
func (*NamePrinter) AfterPrint ¶
func (p *NamePrinter) AfterPrint(w io.Writer, res string) error
func (*NamePrinter) HandledResources ¶
func (p *NamePrinter) HandledResources() []string
TODO: implement HandledResources()
func (*NamePrinter) PrintObj ¶
PrintObj is an implementation of ResourcePrinter.PrintObj which decodes the object and print "resource/name" pair. If the object is a List, print all items in it.
type ObjectDescriber ¶
type ObjectDescriber interface { DescribeObject(object interface{}, extra ...interface{}) (output string, err error) }
ObjectDescriber is an interface for displaying arbitrary objects with extra information. Use when an object is in hand (on disk, or already retrieved). Implementers may ignore the additional information passed on extra, or use it by default. ObjectDescribers may return ErrNoDescriber if no suitable describer is found.
type PrintOptions ¶
type PrintOptions struct { NoHeaders bool WithNamespace bool WithKind bool Wide bool ShowAll bool ShowLabels bool AbsoluteTimestamps bool Kind string ColumnLabels []string }
type ResourcePrinter ¶
type ResourcePrinter interface { // Print receives a runtime object, formats it and prints it to a writer. PrintObj(runtime.Object, io.Writer) error HandledResources() []string //Can be used to print out warning/clarifications if needed //after all objects were printed AfterPrint(io.Writer, string) error }
ResourcePrinter is an interface that knows how to print runtime objects.
func GetStandardPrinter ¶
func GetStandardPrinter(format, formatArgument string, noHeaders, allowMissingTemplateKeys bool, mapper meta.RESTMapper, typer runtime.ObjectTyper, decoders []runtime.Decoder) (ResourcePrinter, bool, error)
GetStandardPrinter takes a format type, an optional format argument. It will return true if the format is generic (untyped), otherwise it will return false. The printer is agnostic to schema versions, so you must send arguments to PrintObj in the version you wish them to be shown using a VersionedPrinter (typically when generic is true).
func NewVersionedPrinter ¶
func NewVersionedPrinter(printer ResourcePrinter, converter runtime.ObjectConvertor, versions ...schema.GroupVersion) ResourcePrinter
NewVersionedPrinter wraps a printer to convert objects to a known API version prior to printing.
type ResourcePrinterFunc ¶
ResourcePrinterFunc is a function that can print objects
func (ResourcePrinterFunc) AfterPrint ¶
func (fn ResourcePrinterFunc) AfterPrint(io.Writer, string) error
func (ResourcePrinterFunc) HandledResources ¶
func (fn ResourcePrinterFunc) HandledResources() []string
TODO: implement HandledResources()
func (ResourcePrinterFunc) PrintObj ¶
PrintObj implements ResourcePrinter
type TemplatePrinter ¶
type TemplatePrinter struct {
// contains filtered or unexported fields
}
TemplatePrinter is an implementation of ResourcePrinter which formats data with a Go Template.
func NewTemplatePrinter ¶
func NewTemplatePrinter(tmpl []byte) (*TemplatePrinter, error)
func (*TemplatePrinter) AfterPrint ¶
func (p *TemplatePrinter) AfterPrint(w io.Writer, res string) error
func (*TemplatePrinter) AllowMissingKeys ¶
func (p *TemplatePrinter) AllowMissingKeys(allow bool)
AllowMissingKeys tells the template engine if missing keys are allowed.
func (*TemplatePrinter) HandledResources ¶
func (p *TemplatePrinter) HandledResources() []string
TODO: implement HandledResources()
func (*TemplatePrinter) PrintObj ¶
PrintObj formats the obj with the Go Template.
type VersionedPrinter ¶
type VersionedPrinter struct {
// contains filtered or unexported fields
}
VersionedPrinter takes runtime objects and ensures they are converted to a given API version prior to being passed to a nested printer.
func (*VersionedPrinter) AfterPrint ¶
func (p *VersionedPrinter) AfterPrint(w io.Writer, res string) error
func (*VersionedPrinter) HandledResources ¶
func (p *VersionedPrinter) HandledResources() []string
TODO: implement HandledResources()
func (*VersionedPrinter) PrintObj ¶
PrintObj implements ResourcePrinter
type YAMLPrinter ¶
type YAMLPrinter struct {
// contains filtered or unexported fields
}
YAMLPrinter is an implementation of ResourcePrinter which outputs an object as YAML. The input object is assumed to be in the internal version of an API and is converted to the given version first.
func (*YAMLPrinter) AfterPrint ¶
func (p *YAMLPrinter) AfterPrint(w io.Writer, res string) error
func (*YAMLPrinter) HandledResources ¶
func (p *YAMLPrinter) HandledResources() []string
TODO: implement HandledResources()
func (*YAMLPrinter) PrintObj ¶
PrintObj prints the data as YAML.
Source Files ¶
common.go customcolumn.go humanreadable.go interface.go json.go jsonpath.go name.go printers.go tabwriter.go template.go versioned.go
Directories ¶
Path | Synopsis |
---|---|
pkg/printers/internalversion |
- Version
- v1.6.12
- Published
- Oct 25, 2017
- Platform
- js/wasm
- Imports
- 21 packages
- Last checked
- 38 seconds ago –
Tools for package owners.