Documentation
¶
Index ¶
Constants ¶
const BinaryPrefix = "orca-plugin-"
BinaryPrefix is the filename prefix every plugin executable must have.
Variables ¶
var ErrKilled = errors.New("plugin manager has been killed")
ErrKilled is returned when trying to load a plugin after Kill has been called.
Functions ¶
func BuildCommands ¶
func BuildCommands(provider plugin.CommandProvider, specs []plugin.CommandSpec) []*cobra.Command
BuildCommands converts a plugin's command specs into cobra commands that call back into the plugin when run.
Types ¶
type CachedPlugin ¶ added in v0.20.0
type CachedPlugin struct {
Name string
Commands []plugin.CommandSpec
}
CachedPlugin is a plugin's commands, as stored in the CommandCache.
type CommandCache ¶ added in v0.20.0
type CommandCache struct {
// contains filtered or unexported fields
}
CommandCache stores the commands each plugin provides, so that shell completion can offer them without starting any plugins, which would be far too slow. It's only a cache: orca rewrites it whenever it runs a command, so it's always safe to delete.
func NewCommandCache ¶ added in v0.20.0
func NewCommandCache(fs afero.Fs, path string) *CommandCache
func (*CommandCache) Read ¶ added in v0.20.0
func (c *CommandCache) Read() ([]CachedPlugin, error)
Read returns the cached plugins. There's no cache until orca has run a command, in which case there are none.
func (*CommandCache) Write ¶ added in v0.20.0
func (c *CommandCache) Write(loaded []LoadedPlugin) error
Write replaces the cache with the commands of the given plugins, so a plugin that's no longer loaded is removed from it.
type ExitError ¶
ExitError is returned when a plugin command fails, so orca can exit with the plugin's exit code.
type LoadedPlugin ¶
type LoadedPlugin struct {
Name string
Path string
Provider plugin.CommandProvider
Commands []plugin.CommandSpec
}
LoadedPlugin is a running plugin process, along with the commands it provides.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) Kill ¶
func (m *Manager) Kill()
Kill stops all plugin processes, and prevents any more from being started. It must be called before orca exits, and is safe to call multiple times or concurrently.
func (*Manager) Load ¶
func (m *Manager) Load(paths []string) []LoadedPlugin
Load starts each plugin binary and fetches its commands. A plugin that fails to start is logged and skipped, so a broken plugin never stops orca from running.
func (*Manager) Loaded ¶
func (m *Manager) Loaded() []LoadedPlugin