plugins

package
v0.9.237-test Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LibDir = "/usr/local/lib"
	BinDir = "/usr/local/bin"
)

Variables

View Source
var Load = sync.OnceValue(loadPlugins)
View Source
var Registry = []Plugin{

	{
		Name:     "criu",
		Type:     External,
		Binaries: []string{"criu"},
	},

	{
		Name:      "runc",
		Type:      Supported,
		Libraries: []string{"libcedana-runc.so"},
	},
	{
		Name:         "containerd",
		Type:         Supported,
		Libraries:    []string{"libcedana-containerd.so"},
		Dependencies: []string{"runc"},
	},
	{
		Name:         "crio",
		Type:         Supported,
		Libraries:    []string{"libcedana-crio.so"},
		Dependencies: []string{"runc"},
	},
	{
		Name:      "kata",
		Libraries: []string{"libcedana-kata.so"},
	},

	{
		Name: "inspector",

		Libraries: []string{"libcedana-inspector.so"},
	},

	{
		Name:      "gpu",
		Type:      External,
		Libraries: []string{"libcedana-gpu.so"},
		Binaries:  []string{"cedana-gpu-controller"},
	},
	{
		Name:      "streamer",
		Type:      External,
		Libraries: []string{"libcedana-streamer.so"},
		Binaries:  []string{"cedana-image-streamer"},
	},
	{
		Name:      "k8s",
		Type:      Supported,
		Libraries: []string{"libcedana-k8s.so"},
		Binaries:  []string{},
	},
}

Local registry of plugins that are supported by Cedana XXX: This list is needed locally so when all plugins are loaded, we only want to attempt to load the ones that are 'Supported'. GPU plugin, for example, is not 'External' and thus cannot be loaded by Go, so we shouldn't try, as it's undefined behavior.

Functions

func RecoverFromPanic

func RecoverFromPanic(plugin string)

RecoverFromPanic is a helper function to recover from panics in plugins and log the error. It should only be used with defer.

Types

type Feature

type Feature[T any] struct {
	Symbol      string
	Description string
}

Feature is a typed symbol that a plugin can export with a description of what it does/used for.

func (Feature[T]) IfAvailable

func (feature Feature[T]) IfAvailable(
	do func(pluginName string, sym T) error,
	filter ...string,
) error

IfAvailable checks if a feature is available in any of the plugins, and if it is, it calls the provided function with the plugin name and the feature. Always goes through all plugins, even if one of them fails. Later, the errors are returned together, if any. If no filter is provided, all plugins are checked.

func (Feature[T]) IsAvailable

func (feature Feature[T]) IsAvailable(filter ...string) (bool, error)

IsAvailable checks if a feature is available in any of the plugins. If no filter is provided, all plugins are checked. Also returns an error if the symbol is present but incompatible.

func (Feature[T]) String

func (feature Feature[T]) String() string

type LocalManager

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

func NewLocalManager

func NewLocalManager() *LocalManager

func (*LocalManager) Get

func (m *LocalManager) Get(name string) *Plugin

func (*LocalManager) Install

func (m *LocalManager) Install(names []string) (chan int, chan string, chan error)

func (*LocalManager) IsInstalled

func (m *LocalManager) IsInstalled(name string) bool

func (*LocalManager) List

func (m *LocalManager) List(status ...Status) (list []Plugin, err error)

List returns a list of plugins that are available. If statuses are provided, only plugins with those statuses are returned.

func (*LocalManager) Remove

func (m *LocalManager) Remove(names []string) (chan int, chan string, chan error)

type Manager

type Manager interface {
	// List all plugins
	List(...Status) ([]Plugin, error)

	// Install a list of plugins
	Install(names []string) (installed chan int, msgs chan string, errs chan error)

	// Remove a list of plugins
	Remove(names []string) (removed chan int, msgs chan string, errs chan error)

	// Get a plugin by name
	Get(name string) *Plugin

	// Check if a plugin is installed
	IsInstalled(name string) bool
}

type Plugin

type Plugin struct {
	Name          string
	Type          Type
	Status        Status
	Version       string
	LatestVersion string
	Libraries     []string
	Binaries      []string
	Size          int64 // in bytes
	Dependencies  []string
}

Represents plugin information

func (*Plugin) BinaryPaths

func (p *Plugin) BinaryPaths() []string

BinaryPaths returns the full paths of the plugin binaries

func (*Plugin) LibraryPaths

func (p *Plugin) LibraryPaths() []string

LibraryPaths returns the full paths of the plugin libraries

func (*Plugin) SyncInstalled

func (p *Plugin) SyncInstalled()

Syncs plugin information with local info, whether it is installed or not. Also fetches the local installed version.

func (*Plugin) SyncVersion

func (p *Plugin) SyncVersion()

SyncVersion fetches the version of the locally installed plugin

type Status

type Status int
const (
	Unknown Status = iota
	Available
	Installed
)

func (Status) String

func (s Status) String() string

type Type

type Type int
const (
	Unimplemented Type = iota // Go plugin that is not yet implemented
	Deprecated                // Go plugin that is no longer maintained
	Experimental              // Go plugin that is not yet stable
	External                  // Not a Go plugin
	Supported                 // Go plugin that is supported by Cedana
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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