plugin

package
v1.12.3 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Overview

nolint

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapsuleStep

func CapsuleStep[T any](_ T, req pipeline.CapsuleRequest) (map[string]any, error)

func LoadYAMLConfig

func LoadYAMLConfig(data []byte, out any) error

func MatchFromStep added in v1.8.14

func MatchFromStep(step v1alpha1.Step) v1alpha1.CapsuleMatch

func ParseCapsuleTemplatedConfig added in v1.8.7

func ParseCapsuleTemplatedConfig[T any](data []byte, req pipeline.CapsuleRequest) (T, error)

ParseCapsuleTemplatedConfig parses the given data as a Go template with the capsule as a templating context under '.capsule' It then JSON/YAML decodes the resulting bytes into an instance of T

func ParseCapsuleTemplatedConfigToString added in v1.12.0

func ParseCapsuleTemplatedConfigToString[T any](data []byte, req pipeline.CapsuleRequest) (string, error)

func ParseTemplatedConfig

func ParseTemplatedConfig[T any](data []byte, req pipeline.CapsuleRequest, steps ...ParseStep[T]) (T, error)

Using this, we parse the config at every execution of the plugin. If we get performance issues due to that we can try and optimize that.

func StartPlugin

func StartPlugin(name string, rigPlugin Plugin)

StartPlugin starts the plugin so it can listen for requests to be run on a CapsuleRequest name is the name of the plugin as referenced in the rig-operator configuration.

Types

type CapsuleWatcher added in v1.9.0

type CapsuleWatcher interface {
	// Watch a primary resource, by providing a capsule name and
	// the type of the object to watch for.
	// All objects which type matches `objType` and that belongs to the capsule
	// will be processed.
	WatchPrimary(ctx context.Context, objType client.Object, cb WatchCallback) error
}

type ExecutionContext added in v1.10.0

type ExecutionContext interface {
	Stop()
	Context() context.Context
}

func NewExecutionContext added in v1.10.0

func NewExecutionContext(ctx context.Context) ExecutionContext

type GRPCServer

type GRPCServer struct {
	apiplugin.UnimplementedPluginServiceServer

	Impl Plugin
	// contains filtered or unexported fields
}

func (*GRPCServer) ComputeConfig added in v1.12.2

func (*GRPCServer) Initialize

func (*GRPCServer) RunCapsule

func (*GRPCServer) WatchObjectStatus added in v1.9.0

type Info

type Info struct {
	Name       string
	Image      string
	IsBuiltin  bool
	BinaryPath string
	Args       []string
}

type InitializeRequest added in v1.7.2

type InitializeRequest struct {
	Config []byte
	Tag    string
	// contains filtered or unexported fields
}

InitializeRequest contains information needed to initialize the plugin This data is constant throughout the execution of the rig-operator.

func (InitializeRequest) Scheme added in v1.9.1

func (r InitializeRequest) Scheme() *runtime.Scheme

type Item added in v1.9.0

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

func (*Item) Less added in v1.9.0

func (it *Item) Less(it1 *Item) bool

type Manager

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

func NewManager

func NewManager(restCfg *rest.Config, opts ...ManagerOption) (*Manager, error)

func (*Manager) GetPlugin

func (m *Manager) GetPlugin(name string) (Info, bool)

func (*Manager) GetPlugins

func (m *Manager) GetPlugins() []Info

func (*Manager) NewStep

func (m *Manager) NewStep(
	execCtx ExecutionContext, step v1alpha1.Step, logger logr.Logger, name string,
) (*Step, error)

type ManagerOption added in v1.8.0

type ManagerOption func(m *Manager)

func SetBuiltinBinaryPathOption added in v1.8.0

func SetBuiltinBinaryPathOption(path string) ManagerOption

type Matcher

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

func NewMatcher

func NewMatcher(match v1alpha1.CapsuleMatch) (Matcher, error)

func (Matcher) Match

func (m Matcher) Match(namespace, capsule string, capsuleAnnotations map[string]string) bool

type NoWatchObjectStatus added in v1.9.0

type NoWatchObjectStatus struct{}

func (NoWatchObjectStatus) WatchObjectStatus added in v1.9.0

type ObjectWatcher added in v1.9.0

type ObjectWatcher interface {
	Reschedule(deadline time.Time)
	WatchSecondaryByName(objectName string, objType client.Object, cb WatchCallback)
	WatchSecondaryByLabels(selector labels.Selector, objType client.Object, cb WatchCallback)
}

type ParseStep

type ParseStep[T any] func(config T, req pipeline.CapsuleRequest) (map[string]any, error)

type Plugin

type Plugin interface {
	// Run is executed once per reconciliation and throug the CapsuleRequest, has read access
	// to the Capsule being reconciled and read/write access to all other derived resources
	Run(ctx context.Context, req pipeline.CapsuleRequest, logger hclog.Logger) error
	// Initialize is executed once when the rig-operator starts up and is used to pass the configuration
	// of the plugin from the operator to the plugin itself.
	Initialize(req InitializeRequest) error
	WatchObjectStatus(ctx context.Context, watcher CapsuleWatcher) error
	ComputeConfig(ctx context.Context, req pipeline.CapsuleRequest, logger hclog.Logger) (string, error)
}

Plugin is the interface a rig plugin must implement to be used by the rig-operator

type Step

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

func (*Step) Apply

func (s *Step) Apply(ctx context.Context, req pipeline.CapsuleRequest, opts pipeline.Options) error

func (*Step) ComputeConfig added in v1.12.0

func (*Step) Name added in v1.12.0

func (s *Step) Name() string

func (*Step) PluginIDs added in v1.9.0

func (s *Step) PluginIDs() []uuid.UUID

func (*Step) WatchObjectStatus added in v1.9.0

func (s *Step) WatchObjectStatus(
	ctx context.Context,
	namespace string,
	capsule string,
	callback pipeline.ObjectStatusCallback,
) error

type ThirdPartyConfig added in v1.8.0

type ThirdPartyConfig struct {
	Plugins []ThirdPartyPlugin `json:"plugins"`
}

type ThirdPartyPlugin added in v1.8.0

type ThirdPartyPlugin struct {
	Name string `json:"name"`
}

type WatchCallback added in v1.9.0

type WatchCallback func(
	obj client.Object,
	events []*corev1.Event,
	objectWatcher ObjectWatcher,
) *apipipeline.ObjectStatusInfo

type Watcher added in v1.9.0

type Watcher interface {
	NewCapsuleWatcher(
		ctx context.Context,
		namespace string,
		capsule string,
		c chan<- *apiplugin.ObjectStatusChange) CapsuleWatcher
}

func NewWatcher added in v1.9.0

func NewWatcher(logger hclog.Logger, cc client.WithWatch) Watcher

Jump to

Keyboard shortcuts

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