Documentation
¶
Index ¶
- Constants
- Variables
- func RecoverFromPanic(plugin string)
- type Feature
- type LocalManager
- func (m *LocalManager) Get(name string) *Plugin
- func (m *LocalManager) Install(names []string) (chan int, chan string, chan error)
- func (m *LocalManager) IsInstalled(name string) bool
- func (m *LocalManager) List(status ...Status) (list []Plugin, err error)
- func (m *LocalManager) Remove(names []string) (chan int, chan string, chan error)
- type Manager
- type Plugin
- type Status
- type Type
Constants ¶
const ( LibDir = "/usr/local/lib" BinDir = "/usr/local/bin" )
Variables ¶
var Load = sync.OnceValue(loadPlugins)
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 ¶
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 ¶
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.
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
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 ¶
BinaryPaths returns the full paths of the plugin binaries
func (*Plugin) LibraryPaths ¶
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