utils

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	OutputModeColumns    = "columns"
	OutputModeJSON       = "json"
	OutputModeJSONPretty = "jsonpretty"
	OutputModeYAML       = "yaml"
)
View Source
const (
	KubernetesTag       string = "kubernetes"
	ContainerRuntimeTag string = "runtime"
)

Variables

View Source
var (
	ErrGadgetPodNotFound      = errors.New("gadget pod not found")
	ErrMultipleGadgetPodFound = errors.New("multiple gadget pods found")
)

Gadget pod

View Source
var SupportedOutputModes = []string{OutputModeJSON, OutputModeColumns}

Functions

func AddOutputFlags

func AddOutputFlags(command *cobra.Command, outputConfig *OutputConfig)

func AddRegistryAuthVariablesAndFlags added in v0.22.0

func AddRegistryAuthVariablesAndFlags(cmd *cobra.Command, authOptions *oci.AuthOptions)

func AddRuntimesSocketPathFlags

func AddRuntimesSocketPathFlags(command *cobra.Command, config *RuntimesSocketPathConfig)

func CheckServerVersionSkew added in v0.28.0

func CheckServerVersionSkew(serverVersion string) error

func ClearScreen added in v0.12.0

func ClearScreen()

func GetContainerRuntimeColumns

func GetContainerRuntimeColumns() []string

func GetKubernetesColumns

func GetKubernetesColumns() []string

func HandleSpecialEvent added in v0.11.0

func HandleSpecialEvent(e *eventtypes.Event, verbose bool)

HandleSpecialEvent prints the special events. Notice it does not receive the OutputMode so it will always print the special events messages without any specific format to standard error.

func MarkExperimental added in v0.23.0

func MarkExperimental(cmd *cobra.Command) *cobra.Command

func ParseEarlyFlags added in v0.22.0

func ParseEarlyFlags(cmd *cobra.Command, rawArgs []string) error

func WrapInErrArgsNotSupported

func WrapInErrArgsNotSupported(args string) error

func WrapInErrGadgetTracerCreateAndRun

func WrapInErrGadgetTracerCreateAndRun(err error) error

func WrapInErrGenGadgetOutput

func WrapInErrGenGadgetOutput(err error) error

func WrapInErrGetGadgetOutput

func WrapInErrGetGadgetOutput(err error) error

func WrapInErrInvalidArg

func WrapInErrInvalidArg(arg string, err error) error

func WrapInErrListGadgetTraces

func WrapInErrListGadgetTraces(err error) error

func WrapInErrListNodes

func WrapInErrListNodes(err error) error

func WrapInErrListPods

func WrapInErrListPods(err error) error

func WrapInErrManagerCreateMountNsMap

func WrapInErrManagerCreateMountNsMap(err error) error

func WrapInErrManagerInit

func WrapInErrManagerInit(err error) error

func WrapInErrMarshalOutput

func WrapInErrMarshalOutput(err error) error

func WrapInErrMissingArgs

func WrapInErrMissingArgs(args string) error

func WrapInErrOutputModeNotSupported

func WrapInErrOutputModeNotSupported(mode string) error

func WrapInErrParserCreate

func WrapInErrParserCreate(err error) error

func WrapInErrRunGadget

func WrapInErrRunGadget(err error) error

func WrapInErrRunGadgetOnAllNode

func WrapInErrRunGadgetOnAllNode(err error) error

func WrapInErrRunGadgetOnNode

func WrapInErrRunGadgetOnNode(node string, err error) error

func WrapInErrSetupK8sClient

func WrapInErrSetupK8sClient(err error) error

func WrapInErrStopGadget

func WrapInErrStopGadget(err error) error

func WrapInErrUnmarshalOutput

func WrapInErrUnmarshalOutput(err error, output string) error

Types

type BaseElement

type BaseElement interface {
	any
}

BaseElement represent any element that needs to be transform into a requested format. For instance, it could be an event (for trace category) or a report (for the profile/cpu gadget).

type BaseParser

type BaseParser[E BaseElement] struct {
	// ColumnsWidth are the columns that can be configured to be printed with
	// the width to be used.
	ColumnsWidth map[string]int

	// SeparateWithTabs defines whether the columns has to be separated with the
	// width defined in ColumnsWidth (if false), or with tabs ignoring the width
	// defined in ColumnsWidth (if true).
	SeparateWithTabs bool

	// OutputConfig provides to the parser the flags that describes how to print
	// the gadget's output.
	OutputConfig *OutputConfig
}

BaseParser is a base for a parser that implements the most common methods.

func NewBaseTabParser

func NewBaseTabParser[E BaseElement](availableColumns []string, outputConfig *OutputConfig) BaseParser[E]

NewBaseTabParser returns a BaseParser configured to print columns separated by tabs.

func NewBaseWidthParser

func NewBaseWidthParser[E BaseElement](columnsWidth map[string]int, outputConfig *OutputConfig) BaseParser[E]

NewBaseWidthParser returns a BaseParser configured to print columns separated by their predefined with.

func (*BaseParser[E]) BuildColumnsHeader

func (p *BaseParser[E]) BuildColumnsHeader() string

func (*BaseParser[E]) GetOutputConfig

func (p *BaseParser[E]) GetOutputConfig() *OutputConfig

func (*BaseParser[E]) Transform

func (p *BaseParser[E]) Transform(element *E, toColumns func(*E) string) string

type GadgetParser

type GadgetParser[T any] struct {
	// contains filtered or unexported fields
}

GadgetParser is a parser that helps printing the gadget output in columns using the columns and formatter/textcolumns packages.

func NewGadgetParser

func NewGadgetParser[T any](outputConfig *OutputConfig, cols *columns.Columns[T], options ...Option) (*GadgetParser[T], error)

func NewGadgetParserWithK8sAndRuntimeInfo added in v0.21.0

func NewGadgetParserWithK8sAndRuntimeInfo[T any](outputConfig *OutputConfig, columns *columns.Columns[T]) (*GadgetParser[T], error)

func NewGadgetParserWithK8sInfo

func NewGadgetParserWithK8sInfo[T any](outputConfig *OutputConfig, columns *columns.Columns[T]) (*GadgetParser[T], error)

func NewGadgetParserWithRuntimeInfo

func NewGadgetParserWithRuntimeInfo[T any](outputConfig *OutputConfig, columns *columns.Columns[T]) (*GadgetParser[T], error)

func (*GadgetParser[T]) BuildColumnsHeader

func (p *GadgetParser[T]) BuildColumnsHeader() string

func (*GadgetParser[T]) Sort

func (p *GadgetParser[T]) Sort(entries []*T, sortBy []string)

func (*GadgetParser[T]) TransformIntoColumns

func (p *GadgetParser[T]) TransformIntoColumns(entry *T) string

func (*GadgetParser[T]) TransformIntoTable

func (p *GadgetParser[T]) TransformIntoTable(entries []*T) string

type GadgetParserOptions

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

type Option

type Option func(*GadgetParserOptions)

func WithMetadataTags added in v0.21.0

func WithMetadataTags(metadataTags ...string) Option

type OutputConfig

type OutputConfig struct {
	// OutputMode specifies the format output should be printed
	OutputMode string

	// List of columns to print (only meaningful when OutputMode is "columns=...")
	CustomColumns []string

	// Verbose prints additional information
	Verbose bool
}

OutputConfig contains the flags that describes how to print the gadget's output

func (*OutputConfig) ParseOutputConfig

func (config *OutputConfig) ParseOutputConfig() error

type RuntimesSocketPathConfig

type RuntimesSocketPathConfig struct {
	Docker     string
	Containerd string
	Crio       string
	Podman     string
}

Jump to

Keyboard shortcuts

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