...

Package output

import "k8s.io/kubernetes/cmd/kubeadm/app/util/output"
Overview
Index

Overview ▾

Index ▾

Constants
type PrintFlags
    func NewOutputFlags(textPrintFlags TextPrintFlags) *PrintFlags
    func (pf *PrintFlags) AddFlags(cmd *cobra.Command)
    func (pf *PrintFlags) AllowedFormats() []string
    func (pf *PrintFlags) ToPrinter() (Printer, error)
    func (pf *PrintFlags) WithDefaultOutput(outputFormat string) *PrintFlags
    func (pf *PrintFlags) WithTypeSetter(scheme *runtime.Scheme) *PrintFlags
type Printer
    func NewResourcePrinterWrapper(resourcePrinter printers.ResourcePrinter, err error) (Printer, error)
type ResourcePrinterWrapper
    func (rpw *ResourcePrinterWrapper) Fprintf(writer io.Writer, format string, args ...interface{}) (n int, err error)
    func (rpw *ResourcePrinterWrapper) Fprintln(writer io.Writer, args ...interface{}) (n int, err error)
    func (rpw *ResourcePrinterWrapper) PrintObj(obj runtime.Object, writer io.Writer) error
    func (rpw *ResourcePrinterWrapper) Printf(format string, args ...interface{}) (n int, err error)
    func (rpw *ResourcePrinterWrapper) Println(args ...interface{}) (n int, err error)
type TextPrintFlags
type TextPrinter
    func (tp *TextPrinter) Fprintf(writer io.Writer, format string, args ...interface{}) (n int, err error)
    func (tp *TextPrinter) Fprintln(writer io.Writer, args ...interface{}) (n int, err error)
    func (tp *TextPrinter) PrintObj(obj runtime.Object, writer io.Writer) error
    func (tp *TextPrinter) Printf(format string, args ...interface{}) (n int, err error)
    func (tp *TextPrinter) Println(args ...interface{}) (n int, err error)

Package files

output.go

Constants

const (
    // TextOutput describes the plain text output
    TextOutput = "text"

    // JSONOutput describes the JSON output
    JSONOutput = "json"

    // YAMLOutput describes the YAML output
    YAMLOutput = "yaml"
)

type PrintFlags

PrintFlags composes common printer flag structs used across kubeadm commands, and provides a method of retrieving a known printer based on flag values provided.

type PrintFlags struct {
    // JSONYamlPrintFlags provides default flags necessary for json/yaml printing.
    JSONYamlPrintFlags *genericclioptions.JSONYamlPrintFlags
    // KubeTemplatePrintFlags composes print flags that provide both a JSONPath and a go-template printer.
    KubeTemplatePrintFlags *genericclioptions.KubeTemplatePrintFlags
    // TextPrintFlags provides default flags necessary for kubeadm text printing.
    TextPrintFlags TextPrintFlags
    // TypeSetterPrinter is an implementation of ResourcePrinter that wraps another printer with types set on the objects
    TypeSetterPrinter *printers.TypeSetterPrinter
    // OutputFormat contains currently set output format
    OutputFormat *string
}

func NewOutputFlags

func NewOutputFlags(textPrintFlags TextPrintFlags) *PrintFlags

NewOutputFlags creates new KubeadmOutputFlags

func (*PrintFlags) AddFlags

func (pf *PrintFlags) AddFlags(cmd *cobra.Command)

AddFlags receives a *cobra.Command reference and binds flags related to Kubeadm printing to it

func (*PrintFlags) AllowedFormats

func (pf *PrintFlags) AllowedFormats() []string

AllowedFormats returns a list of allowed output formats

func (*PrintFlags) ToPrinter

func (pf *PrintFlags) ToPrinter() (Printer, error)

ToPrinter receives an outputFormat and returns a printer capable of handling format printing. Returns error if the specified outputFormat does not match supported formats.

func (*PrintFlags) WithDefaultOutput

func (pf *PrintFlags) WithDefaultOutput(outputFormat string) *PrintFlags

WithDefaultOutput sets a default output format if one is not provided through a flag value

func (*PrintFlags) WithTypeSetter

func (pf *PrintFlags) WithTypeSetter(scheme *runtime.Scheme) *PrintFlags

WithTypeSetter sets a wrapper than will surround the returned printer with a printer to type resources

type Printer

Printer is a common printing interface in Kubeadm

type Printer interface {
    PrintObj(obj runtime.Object, writer io.Writer) error
    Fprintf(writer io.Writer, format string, args ...interface{}) (n int, err error)
    Fprintln(writer io.Writer, args ...interface{}) (n int, err error)
    Printf(format string, args ...interface{}) (n int, err error)
    Println(args ...interface{}) (n int, err error)
}

func NewResourcePrinterWrapper

func NewResourcePrinterWrapper(resourcePrinter printers.ResourcePrinter, err error) (Printer, error)

NewResourcePrinterWrapper creates new ResourcePrinter object

type ResourcePrinterWrapper

ResourcePrinterWrapper wraps ResourcePrinter and implements Printer interface

type ResourcePrinterWrapper struct {
    Printer printers.ResourcePrinter
}

func (*ResourcePrinterWrapper) Fprintf

func (rpw *ResourcePrinterWrapper) Fprintf(writer io.Writer, format string, args ...interface{}) (n int, err error)

Fprintf is an empty method to satisfy Printer interface and silent info printing for structured output This method is usually redefined for the text output

func (*ResourcePrinterWrapper) Fprintln

func (rpw *ResourcePrinterWrapper) Fprintln(writer io.Writer, args ...interface{}) (n int, err error)

Fprintln is an empty method to satisfy the Printer interface and silent info printing for structured output This method is usually redefined for the text output

func (*ResourcePrinterWrapper) PrintObj

func (rpw *ResourcePrinterWrapper) PrintObj(obj runtime.Object, writer io.Writer) error

PrintObj is an implementation of ResourcePrinter.PrintObj that calls underlying printer API

func (*ResourcePrinterWrapper) Printf

func (rpw *ResourcePrinterWrapper) Printf(format string, args ...interface{}) (n int, err error)

Printf is an empty method to satisfy Printer interface and silent info printing for structured output This method is usually redefined for the text output

func (*ResourcePrinterWrapper) Println

func (rpw *ResourcePrinterWrapper) Println(args ...interface{}) (n int, err error)

Println is an empty method to satisfy Printer interface and silent info printing for structured output This method is usually redefined for the text output

type TextPrintFlags

TextPrintFlags is an interface to handle custom text output

type TextPrintFlags interface {
    ToPrinter(outputFormat string) (Printer, error)
}

type TextPrinter

TextPrinter implements Printer interface for generic text output

type TextPrinter struct {
}

func (*TextPrinter) Fprintf

func (tp *TextPrinter) Fprintf(writer io.Writer, format string, args ...interface{}) (n int, err error)

Fprintf is a wrapper around fmt.Fprintf

func (*TextPrinter) Fprintln

func (tp *TextPrinter) Fprintln(writer io.Writer, args ...interface{}) (n int, err error)

Fprintln is a wrapper around fmt.Fprintln

func (*TextPrinter) PrintObj

func (tp *TextPrinter) PrintObj(obj runtime.Object, writer io.Writer) error

PrintObj is an implementation of ResourcePrinter.PrintObj that prints object

func (*TextPrinter) Printf

func (tp *TextPrinter) Printf(format string, args ...interface{}) (n int, err error)

Printf is a wrapper around fmt.Printf

func (*TextPrinter) Println

func (tp *TextPrinter) Println(args ...interface{}) (n int, err error)

Println is a wrapper around fmt.Printf