operators

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GlobalParamsCollection

func GlobalParamsCollection() params.Collection

GlobalParamsCollection returns a collection of params of all registered operators

func Register

func Register(operator Operator)

Register adds a new operator to the registry

Types

type ContainerInfoFromMountNSID

type ContainerInfoFromMountNSID interface {
	ContainerInfoSetters
	GetMountNSID() uint64
}

ContainerInfoFromMountNSID is a typical kubernetes operator interface that adds node, pod, namespace and container information given the MountNSID

type ContainerInfoFromNetNSID

type ContainerInfoFromNetNSID interface {
	ContainerInfoSetters
	GetNetNSID() uint64
}

type ContainerInfoGetters added in v0.15.0

type ContainerInfoGetters interface {
	GetNode() string
	GetPod() string
	GetNamespace() string
	GetContainer() string
}

type ContainerInfoSetters

type ContainerInfoSetters interface {
	SetContainerInfo(pod, namespace, container string)
	SetNode(string)
}

type EnricherFunc

type EnricherFunc func(any) error

type GadgetContext

type GadgetContext interface {
	ID() string
	Context() context.Context
	GadgetDesc() gadgets.GadgetDesc
	Logger() logger.Logger
}

type Operator

type Operator interface {
	// Name must return a unique name for the operator
	Name() string

	// Description is an optional description to show to the user
	Description() string

	// GlobalParamDescs will return global params (required) for this operator
	GlobalParamDescs() params.ParamDescs

	// ParamDescs will return params (required) per gadget instance of the operator
	ParamDescs() params.ParamDescs

	// Dependencies can list other operators that this operator depends on
	Dependencies() []string

	// CanOperateOn should test whether the operator supports the given gadget. Init has not
	// necessarily been called at this point.
	CanOperateOn(gadgets.GadgetDesc) bool

	// Init allows the operator to initialize itself
	Init(params *params.Params) error

	// Close allows the operator to clean up stuff prior to exiting
	Close() error

	// Instantiate is called before a gadget is run with this operator.
	// This must return something that implements OperatorInstance.
	// This is useful to create a context for an operator by wrapping it.
	// Params given here are the ones returned by ParamDescs()
	Instantiate(gadgetContext GadgetContext, gadgetInstance any, params *params.Params) (OperatorInstance, error)
}

func GetRaw added in v0.15.0

func GetRaw(name string) Operator

type OperatorInstance

type OperatorInstance interface {
	// Name returns the name of the operator instance
	Name() string

	// PreGadgetRun in called before a gadget is run
	PreGadgetRun() error

	// PostGadgetRun is called after a gadget is run
	PostGadgetRun() error

	// EnrichEvent enriches the given event with additional data
	EnrichEvent(ev any) error
}

type OperatorInstances

type OperatorInstances []OperatorInstance

func (OperatorInstances) Enrich

func (oi OperatorInstances) Enrich(ev any) error

Enrich an event using all members of the operator collection

func (OperatorInstances) PostGadgetRun

func (oi OperatorInstances) PostGadgetRun() error

func (OperatorInstances) PreGadgetRun

func (oi OperatorInstances) PreGadgetRun() error

type Operators

type Operators []Operator

func GetAll

func GetAll() Operators

GetAll returns all registered operators

func GetOperatorsForGadget

func GetOperatorsForGadget(gadget gadgets.GadgetDesc) Operators

GetOperatorsForGadget checks which operators can work with the given gadgets and returns a collection of them

func SortOperators

func SortOperators(operators Operators) (Operators, error)

SortOperators builds a dependency tree of the given operator collection and sorts them by least dependencies first Returns an error, if there are loops or missing dependencies

func (Operators) Close

func (e Operators) Close()

Close closes all operators in the collection; errors will be written to the log

func (Operators) Init

func (e Operators) Init(pc params.Collection) error

Init initializes all operators in the collection using their respective params

func (Operators) Instantiate

func (e Operators) Instantiate(gadgetContext GadgetContext, trace any, perGadgetParamCollection params.Collection) (operatorInstances OperatorInstances, _ error)

Instantiate calls Instantiate on all operators and returns a collection of the results. It also calls PreGadgetRun on all instances.

func (Operators) ParamCollection

func (e Operators) ParamCollection() params.Collection

ParamCollection returns a collection of parameters for all members of the operator collection

func (Operators) ParamDescCollection

func (e Operators) ParamDescCollection() params.DescCollection

ParamDescCollection returns a collection of parameter descriptors for all members of the operator collection

Directories

Path Synopsis
Package kubeipresolver provides an operator that enriches events by looking up IP addresses in Kubernetes resources such as pods and services.
Package kubeipresolver provides an operator that enriches events by looking up IP addresses in Kubernetes resources such as pods and services.

Jump to

Keyboard shortcuts

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