plugins

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DemoPluginName = "demo-pod-tweaks"

Variables

View Source
var DefaultRegistry = NewRegistry()

Functions

func DecodeJSON

func DecodeJSON(cfg *apiextensionsv1.JSON, out any) error

DecodeJSON decodes a plugin config into the provided out struct. It is a helper for built-in plugins.

Types

type Chain

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

Chain represents an ordered list of plugins built from a ModelServing spec.

func NewChain

func NewChain(registry *Registry, specs []workloadv1alpha1.PluginSpec) (*Chain, error)

NewChain builds a Chain from plugin specs and the registry.

func (*Chain) OnPodCreate

func (c *Chain) OnPodCreate(ctx context.Context, req *HookRequest) error

OnPodCreate executes plugins in order. Mutations are applied to req.Pod.

func (*Chain) OnPodReady

func (c *Chain) OnPodReady(ctx context.Context, req *HookRequest) error

OnPodReady executes plugins' ready hooks in order.

type DemoConfig

type DemoConfig struct {
	RuntimeClassName string            `json:"runtimeClassName,omitempty"`
	Annotations      map[string]string `json:"annotations,omitempty"`
	Env              []corev1.EnvVar   `json:"env,omitempty"`
}

DemoConfig is a simple config used by the demo plugin to mutate pods.

type DemoPlugin

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

DemoPlugin is a sample built-in plugin that tweaks runtimeClass, annotations, and env vars.

func (*DemoPlugin) Name

func (p *DemoPlugin) Name() string

func (*DemoPlugin) OnPodCreate

func (p *DemoPlugin) OnPodCreate(_ context.Context, req *HookRequest) error

OnPodCreate mutates the pod in-place based on the provided config.

func (*DemoPlugin) OnPodReady

func (p *DemoPlugin) OnPodReady(_ context.Context, _ *HookRequest) error

OnPodReady is a no-op for the demo plugin.

type Factory

type Factory func(spec workloadv1alpha1.PluginSpec) (Plugin, error)

Factory constructs a Plugin from a PluginSpec.

type HookRequest

type HookRequest struct {
	ModelServing *workloadv1alpha1.ModelServing
	ServingGroup string
	RoleName     string
	RoleID       string
	IsEntry      bool
	Pod          *corev1.Pod
}

HookRequest carries the context for plugin hook invocations.

type Plugin

type Plugin interface {
	Name() string
	// OnPodCreate is invoked before the controller creates the Pod. Mutations are applied in-place to req.Pod.
	OnPodCreate(ctx context.Context, req *HookRequest) error
	// OnPodReady is invoked when the controller observes the Pod running and ready.
	OnPodReady(ctx context.Context, req *HookRequest) error
}

Plugin defines the lifecycle hooks a plugin may implement.

func NewDemoPlugin

func NewDemoPlugin(spec workloadv1alpha1.PluginSpec) (Plugin, error)

NewDemoPlugin constructs the demo plugin from PluginSpec config.

type Registry

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

Registry keeps a mapping from plugin name to factory.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Register

func (r *Registry) Register(name string, factory Factory)

Jump to

Keyboard shortcuts

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