Documentation ¶
Index ¶
Constants ¶
const DefaultFilename = "plugin.yaml"
DefaultFilename is the filename for the plugin metadata
Variables ¶
var ErrNotAGoPlugin = errors.New("not a Go plugin")
ErrNotAGoPlugin is returned when attempting to load a file that's not a Go plugin
Functions ¶
This section is empty.
Types ¶
type Command ¶
Command is a parsed plugin command
func (*Command) UnmarshalYAML ¶
UnmarshalYAML implements the yaml unmarshaller interface This function deconstructs the command to base command and args
type DefaultHandler ¶
DefaultHandler is the default plugin handler
func (*DefaultHandler) GetPlugins ¶
func (h *DefaultHandler) GetPlugins() ([]*Plugin, error)
GetPlugins returns all installed plugins found in the plugins directory
func (*DefaultHandler) InstallPlugin ¶
func (h *DefaultHandler) InstallPlugin(path string) error
InstallPlugin creates a symlink from the specified directory to the plugins directory
func (*DefaultHandler) LoadGoPlugin ¶
func (h *DefaultHandler) LoadGoPlugin(path string, settings *environment.Settings) (*cobra.Command, error)
LoadGoPlugin loads a cobra.Command from the Go plugin at the given path. The Go plugin must implement a command factory as follows:
func New(settings *environment.Settings) *cobra.Command { return &cobra.Command{...} }
If the file at the given path is not a Go plugin then the error, ErrNotAGoPlugin, is returned. If the Go plugin does not implement the command factory then an error is returned.
func (*DefaultHandler) UninstallPlugin ¶
func (h *DefaultHandler) UninstallPlugin(name string) error
UninstallPlugin removes the symlink from the plugin directory by plugin name
type Handler ¶
type Handler interface { GetPlugins() ([]*Plugin, error) InstallPlugin(path string) error UninstallPlugin(name string) error LoadGoPlugin(path string, settings *environment.Settings) (*cobra.Command, error) }
Handler defines the required actions for managing plugins
type Plugin ¶
type Plugin struct { Name string `yaml:"name"` Usage string `yaml:"usage"` Description string `yaml:"description"` Command *Command `yaml:"command"` Path string `yaml:"-"` }
Plugin is an installed, third-party command Consider using "github.com/mitchellh/mapstructure" when the yaml structure gets more complex