operators

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDataOperators added in v0.27.0

func GetDataOperators() map[string]DataOperator

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

func RegisterDataOperator added in v0.27.0

func RegisterDataOperator(operator DataOperator)

RegisterDataOperator registers a DataOperator

func RegisterOperatorForMediaType added in v0.27.0

func RegisterOperatorForMediaType(mediaType string, operator ImageOperator)

RegisterOperatorForMediaType registers operators for specific media types

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
	GetContainerImageName() string
}

type ContainerInfoSetters

type ContainerInfoSetters interface {
	NodeSetter
	SetPodMetadata(types.Container)
	SetContainerMetadata(types.Container)
}

type DataOperator added in v0.27.0

type DataOperator interface {
	Name() string

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

	// GlobalParams should return global params (required) for this operator; these are valid globally for the process
	GlobalParams() api.Params

	// InstanceParams should return parameters valid for a single gadget run
	InstanceParams() api.Params

	// InstantiateDataOperator should create a new (lightweight) instance for the operator that can read/write
	// from and to DataSources, register Params and read/write Variables; instanceParamValues can contain values for
	// both params defined by InstanceParams() as well as params defined by DataOperatorInstance.ExtraParams())
	InstantiateDataOperator(gadgetCtx GadgetContext, instanceParamValues api.ParamValues) (DataOperatorInstance, error)

	Priority() int
}

type DataOperatorExtraParams added in v0.27.0

type DataOperatorExtraParams interface {
	// ExtraParams can return dynamically created params; they are read after Prepare() has been called
	ExtraParams(gadgetCtx GadgetContext) api.Params
}

type DataOperatorInstance added in v0.27.0

type DataOperatorInstance interface {
	Name() string
	Start(gadgetCtx GadgetContext) error
	Stop(gadgetCtx GadgetContext) error
}

type EnricherFunc

type EnricherFunc func(any) error

type GadgetContext

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

	Cancel()
	SerializeGadgetInfo() (*api.GadgetInfo, error)
	ImageName() string
	RegisterDataSource(datasource.Type, string) (datasource.DataSource, error)
	GetDataSources() map[string]datasource.DataSource
	SetVar(string, any)
	GetVar(string) (any, bool)
	Params() []*api.Param
	SetParams([]*api.Param)
	SetMetadata([]byte)
}

type ImageOperator added in v0.27.0

type ImageOperator interface {
	Name() string

	// InstantiateImageOperator will be run to load information about a gadget and also to _possibly_
	// run the gadget afterward. It should only do things that are required to populate
	// DataSources and Params. It could use caching to speed things up, if necessary.
	InstantiateImageOperator(gadgetCtx GadgetContext, descriptor ocispec.Descriptor,
		paramValues api.ParamValues) (ImageOperatorInstance, error)
}

func GetImageOperatorForMediaType added in v0.27.0

func GetImageOperatorForMediaType(mediaType string) (ImageOperator, bool)

GetImageOperatorForMediaType returns a copy of the map of operators matching the given media type

type ImageOperatorInstance added in v0.27.0

type ImageOperatorInstance interface {
	Name() string
	Prepare(gadgetCtx GadgetContext) error
	Start(gadgetCtx GadgetContext) error
	Stop(gadgetCtx GadgetContext) error
	ExtraParams(gadgetCtx GadgetContext) api.Params
}

type NodeSetter added in v0.16.0

type NodeSetter interface {
	SetNode(string)
}

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(gadgetCtx 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

type PostStop added in v0.27.0

type PostStop interface {
	PostStop(gadgetCtx GadgetContext) error
}

type PreStart added in v0.27.0

type PreStart interface {
	PreStart(gadgetCtx GadgetContext) error
}

Directories

Path Synopsis
Package ebpfoperator provides an operator that is capable of analyzing and running an eBFP based gadget.
Package ebpfoperator provides an operator that is capable of analyzing and running an eBFP based gadget.
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.
Package kubenameresolver provides an operator that enriches events by looking up the pod name and namespace and enriches it with its ip information.
Package kubenameresolver provides an operator that enriches events by looking up the pod name and namespace and enriches it with its ip information.
Package socketenricher creates an eBPF map exposing processes owning each socket.
Package socketenricher creates an eBPF map exposing processes owning each socket.
Package uidgidresolver provides an operator that enriches events by looking up uid and gid resolving them to the corresponding username and groupname.
Package uidgidresolver provides an operator that enriches events by looking up uid and gid resolving them to the corresponding username and groupname.

Jump to

Keyboard shortcuts

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