Documentation ¶
Overview ¶
Package plugin implements functions and types for maintaining and running stash plugins.
Stash plugins are configured using yml files in the configured plugins directory. These yml files must follow the Config structure format.
The main entry into the plugin sub-system is via the Cache type.
Index ¶
Constants ¶
const ( // InterfaceEnumRPC indicates that the plugin uses the RPCRunner interface // declared in common/rpc.go. InterfaceEnumRPC interfaceEnum = "rpc" // InterfaceEnumRaw interfaces will have the common.PluginInput encoded as // json (but may be ignored), and output will be decoded as // common.PluginOutput. If this decoding fails, then the raw output will be // treated as the output. InterfaceEnumRaw interfaceEnum = "raw" )
Valid interfaceEnum values
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores plugin details.
func NewCache ¶
NewCache returns a new Cache loading plugin configurations from the provided plugin path. It returns an new instance and an error if the plugin directory could not be loaded.
Plugins configurations are loaded from yml files in the provided plugin directory and any subdirectories.
func (Cache) CreateTask ¶
func (c Cache) CreateTask(pluginID string, operationName string, serverConnection common.StashServerConnection, args []*models.PluginArgInput, progress chan float64) (Task, error)
CreateTask runs the plugin operation for the pluginID and operation name provided. Returns an error if the plugin or the operation could not be resolved.
func (Cache) ListPluginTasks ¶
func (c Cache) ListPluginTasks() []*models.PluginTask
ListPluginTasks returns all runnable plugin tasks in all loaded plugins.
func (Cache) ListPlugins ¶
ListPlugins returns plugin details for all of the loaded plugins.
func (*Cache) ReloadPlugins ¶
ReloadPlugins clears the plugin cache and reloads from the plugin path. In the event of an error during loading, the cache will be left empty.
type Config ¶
type Config struct { // The name of the plugin. This will be displayed in the UI. Name string `yaml:"name"` // An optional description of what the plugin does. Description *string `yaml:"description"` // An optional URL for the plugin. URL *string `yaml:"url"` // An optional version string. Version *string `yaml:"version"` // The communication interface used when communicating with the spawned // plugin process. Defaults to 'raw' if not provided. Interface interfaceEnum `yaml:"interface"` // The command to execute for the operations in this plugin. The first // element should be the program name, and subsequent elements are passed // as arguments. // // Note: the execution process will search the path for the program, // then will attempt to find the program in the plugins // directory. The exe extension is not necessary on Windows platforms. // The current working directory is set to that of the stash process. Exec []string `yaml:"exec,flow"` // The default log level to output the plugin process's stderr stream. // Only used if the plugin does not encode its output using log level // control characters. // See package common/log for valid values. // If left unset, defaults to log.ErrorLevel. PluginErrLogLevel string `yaml:"errLog"` // The task configurations for tasks provided by this plugin. Tasks []*OperationConfig `yaml:"tasks"` // contains filtered or unexported fields }
Config describes the configuration for a single plugin.
type OperationConfig ¶
type OperationConfig struct { // Used to identify the operation. Must be unique within a plugin // configuration. This name is shown in the button for the operation // in the UI. Name string `yaml:"name"` // A short description of the operation. This description is shown below // the button in the UI. Description string `yaml:"description"` // A list of arguments that will be appended to the plugin's Exec arguments // when executing this operation. ExecArgs []string `yaml:"execArgs"` // A map of argument keys to their default values. The default value is // used if the applicable argument is not provided during the operation // call. DefaultArgs map[string]string `yaml:"defaultArgs"` }
OperationConfig describes the configuration for a single plugin operation provided by a plugin.
type Task ¶
type Task interface { // Start starts the plugin task. Returns an error if task could not be // started or the task has already been started. Start() error // Stop instructs a running plugin task to stop and returns immediately. // Use Wait to subsequently wait for the task to stop. Stop() error // Wait blocks until the plugin task is complete. Returns immediately if // task has not been started. Wait() // GetResult returns the output of the plugin task. Returns nil if the task // has not completed. GetResult() *common.PluginOutput }
Task is the interface that handles management of a single plugin task.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package common encapulates data structures and functions that will be used by plugin executables and the plugin subsystem in the stash server.
|
Package common encapulates data structures and functions that will be used by plugin executables and the plugin subsystem in the stash server. |
log
Package log provides a number of logging utility functions for encoding and decoding log messages between a stash server and a plugin instance.
|
Package log provides a number of logging utility functions for encoding and decoding log messages between a stash server and a plugin instance. |
Package util implements utility and convenience methods for plugins.
|
Package util implements utility and convenience methods for plugins. |