get

package
v1.13.4-k3s.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmdGet

func NewCmdGet(parent string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command

NewCmdGet creates a command object for the generic "get" action, which retrieves one or more resources from a server.

func RelaxedJSONPathExpression

func RelaxedJSONPathExpression(pathExpression string) (string, error)

RelaxedJSONPathExpression attempts to be flexible with JSONPath expressions, it accepts:

  • metadata.name (no leading '.' or curly braces '{...}'
  • {metadata.name} (no leading '.')
  • .metadata.name (no curly braces '{...}')
  • {.metadata.name} (complete expression)

And transforms them all into a valid jsonpath expression:

{.metadata.name}

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 CustomColumnsPrintFlags

type CustomColumnsPrintFlags struct {
	NoHeaders        bool
	TemplateArgument string
}

CustomColumnsPrintFlags provides default flags necessary for printing custom resource columns from an inline-template or file.

func NewCustomColumnsPrintFlags

func NewCustomColumnsPrintFlags() *CustomColumnsPrintFlags

NewCustomColumnsPrintFlags returns flags associated with custom-column printing, with default values set. NoHeaders and TemplateArgument should be set by callers.

func (*CustomColumnsPrintFlags) AddFlags

func (f *CustomColumnsPrintFlags) AddFlags(c *cobra.Command)

AddFlags receives a *cobra.Command reference and binds flags related to custom-columns printing

func (*CustomColumnsPrintFlags) AllowedFormats

func (f *CustomColumnsPrintFlags) AllowedFormats() []string

func (*CustomColumnsPrintFlags) ToPrinter

func (f *CustomColumnsPrintFlags) ToPrinter(templateFormat string) (printers.ResourcePrinter, error)

ToPrinter receives an templateFormat and returns a printer capable of handling custom-column printing. Returns false if the specified templateFormat does not match a supported format. Supported format types can be found in pkg/printers/printers.go

type CustomColumnsPrinter

type CustomColumnsPrinter struct {
	Columns   []Column
	Decoder   runtime.Decoder
	NoHeaders bool
	// contains filtered or unexported fields
}

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) PrintObj

func (s *CustomColumnsPrinter) PrintObj(obj runtime.Object, out io.Writer) error

type GetOptions

type GetOptions struct {
	PrintFlags             *PrintFlags
	ToPrinter              func(*meta.RESTMapping, bool, bool) (printers.ResourcePrinterFunc, error)
	IsHumanReadablePrinter bool

	CmdParent string

	resource.FilenameOptions

	Raw       string
	Watch     bool
	WatchOnly bool
	ChunkSize int64

	LabelSelector     string
	FieldSelector     string
	AllNamespaces     bool
	Namespace         string
	ExplicitNamespace bool

	ServerPrint bool

	NoHeaders      bool
	Sort           bool
	IgnoreNotFound bool
	Export         bool

	IncludeUninitialized bool

	genericclioptions.IOStreams
}

GetOptions contains the input to the get command.

func NewGetOptions

func NewGetOptions(parent string, streams genericclioptions.IOStreams) *GetOptions

NewGetOptions returns a GetOptions with default chunk size 500.

func (*GetOptions) Complete

func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []string) error

Complete takes the command arguments and factory and infers any remaining options.

func (*GetOptions) Run

func (o *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) error

Run performs the get operation. TODO: remove the need to pass these arguments, like other commands.

func (*GetOptions) Validate

func (o *GetOptions) Validate(cmd *cobra.Command) error

Validate checks the set of flags provided by the user.

type HumanPrintFlags

type HumanPrintFlags struct {
	ShowKind     *bool
	ShowLabels   *bool
	SortBy       *string
	ColumnLabels *[]string

	// get.go-specific values
	NoHeaders bool

	Kind               schema.GroupKind
	AbsoluteTimestamps bool
	WithNamespace      bool
}

HumanPrintFlags provides default flags necessary for printing. Given the following flag values, a printer can be requested that knows how to handle printing based on these values.

func NewHumanPrintFlags

func NewHumanPrintFlags() *HumanPrintFlags

NewHumanPrintFlags returns flags associated with human-readable printing, with default values set.

func (*HumanPrintFlags) AddFlags

func (f *HumanPrintFlags) AddFlags(c *cobra.Command)

AddFlags receives a *cobra.Command reference and binds flags related to human-readable printing to it

func (*HumanPrintFlags) AllowedFormats

func (f *HumanPrintFlags) AllowedFormats() []string

func (*HumanPrintFlags) EnsureWithKind

func (f *HumanPrintFlags) EnsureWithKind() error

EnsureWithKind sets the "Showkind" humanreadable option to true.

func (*HumanPrintFlags) EnsureWithNamespace

func (f *HumanPrintFlags) EnsureWithNamespace() error

EnsureWithNamespace sets the "WithNamespace" humanreadable option to true.

func (*HumanPrintFlags) SetKind

func (f *HumanPrintFlags) SetKind(kind schema.GroupKind)

SetKind sets the Kind option

func (*HumanPrintFlags) ToPrinter

func (f *HumanPrintFlags) ToPrinter(outputFormat string) (printers.ResourcePrinter, error)

ToPrinter receives an outputFormat and returns a printer capable of handling human-readable output.

type NopPositioner

type NopPositioner struct{}

func (*NopPositioner) OriginalPosition

func (t *NopPositioner) OriginalPosition(ix int) int

type OriginalPositioner

type OriginalPositioner interface {
	OriginalPosition(int) int
}

type PrintFlags

type PrintFlags struct {
	JSONYamlPrintFlags *genericclioptions.JSONYamlPrintFlags
	NamePrintFlags     *genericclioptions.NamePrintFlags
	CustomColumnsFlags *CustomColumnsPrintFlags
	HumanReadableFlags *HumanPrintFlags
	TemplateFlags      *genericclioptions.KubeTemplatePrintFlags

	NoHeaders    *bool
	OutputFormat *string
}

PrintFlags composes common printer flag structs used in the Get command.

func NewGetPrintFlags

func NewGetPrintFlags() *PrintFlags

NewGetPrintFlags returns flags associated with humanreadable, template, and "name" printing, with default values set.

func (*PrintFlags) AddFlags

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

AddFlags receives a *cobra.Command reference and binds flags related to humanreadable and template printing.

func (*PrintFlags) AllowedFormats

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

func (*PrintFlags) Copy

func (f *PrintFlags) Copy() PrintFlags

Copy returns a copy of PrintFlags for mutation

func (*PrintFlags) EnsureWithKind

func (f *PrintFlags) EnsureWithKind() error

EnsureWithKind ensures that humanreadable flags return a printer capable of including resource kinds.

func (*PrintFlags) EnsureWithNamespace

func (f *PrintFlags) EnsureWithNamespace() error

EnsureWithNamespace ensures that humanreadable flags return a printer capable of printing with a "namespace" column.

func (*PrintFlags) SetKind

func (f *PrintFlags) SetKind(kind schema.GroupKind)

SetKind sets the Kind option of humanreadable flags

func (*PrintFlags) ToPrinter

func (f *PrintFlags) ToPrinter() (printers.ResourcePrinter, error)

ToPrinter attempts to find a composed set of PrintFlags suitable for returning a printer based on current flag values.

type RuntimeSort

type RuntimeSort struct {
	// contains filtered or unexported fields
}

RuntimeSort is an implementation of the golang sort interface that knows how to sort lists of runtime.Object

func NewRuntimeSort

func NewRuntimeSort(field string, objs []runtime.Object) *RuntimeSort

func SortObjects

func SortObjects(decoder runtime.Decoder, objs []runtime.Object, fieldInput string) (*RuntimeSort, error)

func (*RuntimeSort) Len

func (r *RuntimeSort) Len() int

func (*RuntimeSort) Less

func (r *RuntimeSort) Less(i, j int) bool

func (*RuntimeSort) OriginalPosition

func (r *RuntimeSort) OriginalPosition(ix int) int

OriginalPosition returns the starting (original) position of a particular index. e.g. If OriginalPosition(0) returns 5 than the the item currently at position 0 was at position 5 in the original unsorted array.

func (*RuntimeSort) Swap

func (r *RuntimeSort) Swap(i, j int)

type RuntimeSorter

type RuntimeSorter struct {
	// contains filtered or unexported fields
}

func NewRuntimeSorter

func NewRuntimeSorter(objects []runtime.Object, sortBy string) *RuntimeSorter

func (*RuntimeSorter) OriginalPosition

func (r *RuntimeSorter) OriginalPosition(ix int) int

func (*RuntimeSorter) Sort

func (r *RuntimeSorter) Sort() error

func (*RuntimeSorter) WithDecoder

func (r *RuntimeSorter) WithDecoder(decoder runtime.Decoder) *RuntimeSorter

allows custom decoder to be set for testing

type SortingPrinter

type SortingPrinter struct {
	SortField string
	Delegate  printers.ResourcePrinter
	Decoder   runtime.Decoder
}

SortingPrinter sorts list types before delegating to another printer. Non-list types are simply passed through

func (*SortingPrinter) PrintObj

func (s *SortingPrinter) PrintObj(obj runtime.Object, out io.Writer) error

type TableSorter

type TableSorter struct {
	// contains filtered or unexported fields
}

func NewTableSorter

func NewTableSorter(table *metav1beta1.Table, field string) (*TableSorter, error)

func (*TableSorter) Len

func (t *TableSorter) Len() int

func (*TableSorter) Less

func (t *TableSorter) Less(i, j int) bool

func (*TableSorter) Sort

func (t *TableSorter) Sort() error

func (*TableSorter) Swap

func (t *TableSorter) Swap(i, j int)

Jump to

Keyboard shortcuts

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