printers

package
v0.2.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonPrinter

type JsonPrinter[T any] struct {
	Sanitizer *sanitize.Sanitizer
}

func NewJsonPrinter

func NewJsonPrinter[T any]() (*JsonPrinter[T], error)

func (JsonPrinter[T]) PrintResource

func (p JsonPrinter[T]) PrintResource(ctx context.Context, r types.PrintableResource[T], writer io.Writer) error

type ResourcePrinter

type ResourcePrinter[T any] interface {
	// PrintResource receives a runtime object, formats it and prints it to a writer.
	PrintResource(context.Context, types.PrintableResource[T], io.Writer) error
}

Inspired by Kubernetes

ResourcePrinter is an interface that knows how to print runtime objects.

func GetPrinter

func GetPrinter[T any](cmd *cobra.Command) (ResourcePrinter[T], error)

type StringPrinter

type StringPrinter[T any] struct {
	Sanitizer *sanitize.Sanitizer
	// contains filtered or unexported fields
}

func NewStringPrinter

func NewStringPrinter[T any]() (*StringPrinter[T], error)

func (StringPrinter[T]) PrintResource

func (p StringPrinter[T]) PrintResource(_ context.Context, r types.PrintableResource[T], writer io.Writer) error

type TablePrinter

type TablePrinter[T any] struct {
	Sanitizer *sanitize.Sanitizer
}

Inspired by Kubernetes TablePrinter decodes table objects into typed objects before delegating to another printer. Non-table types are simply passed through

func NewTablePrinter

func NewTablePrinter[T any]() (*TablePrinter[T], error)

func (TablePrinter[T]) PrintResource

func (p TablePrinter[T]) PrintResource(_ context.Context, items types.PrintableResource[T], writer io.Writer) error

func (TablePrinter[T]) PrintTable

func (p TablePrinter[T]) PrintTable(table types.Table, writer io.Writer) error

type YamlPrinter

type YamlPrinter[T any] struct {
	Sanitizer *sanitize.Sanitizer
}

Inspired by https://github.com/goccy/go-yaml/blob/master/cmd/ycat/ycat.go

func NewYamlPrinter

func NewYamlPrinter[T any]() (*YamlPrinter[T], error)

func (YamlPrinter[T]) PrintResource

func (px YamlPrinter[T]) PrintResource(ctx context.Context, r types.PrintableResource[T], writer io.Writer) error

Jump to

Keyboard shortcuts

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