Documentation ¶
Overview ¶
Package plugins provides structures and helper functions to manage Docker plugins.
Docker discovers plugins by looking for them in the plugin directory whenever a user or container tries to use one by name. UNIX domain socket files must be located under /run/docker/plugins, whereas spec files can be located either under /etc/docker/plugins or /usr/lib/docker/plugins. This is handled by the Registry interface, which lets you list all plugins or get a plugin by its name if it exists.
The plugins need to implement an HTTP server and bind this to the UNIX socket or the address specified in the spec files. A handshake is send at /Plugin.Activate, and plugins are expected to return a Manifest with a list of Docker subsystems which this plugin implements.
In order to use a plugins, you can use the `Get` with the name of the plugin and the subsystem it implements.
plugin, err := plugins.Get("example", "VolumeDriver") if err != nil { return fmt.Errorf("Error looking up volume plugin example: %v", err) }
Index ¶
- Constants
- Variables
- func Handle(iface string, fn func(string, *Client))
- func IsNotFound(err error) bool
- func SpecsPaths() []string
- func WithRequestTimeout(t time.Duration) func(*RequestOpts)
- type Client
- func (c *Client) Call(serviceMethod string, args, ret interface{}) error
- func (c *Client) CallWithOptions(serviceMethod string, args interface{}, ret interface{}, ...) error
- func (c *Client) SendFile(serviceMethod string, data io.Reader, ret interface{}) error
- func (c *Client) Stream(serviceMethod string, args interface{}) (io.ReadCloser, error)
- type LocalRegistry
- type Manifest
- type Plugin
- type RequestOpts
Constants ¶
const ProtocolSchemeHTTPV1 = "moby.plugins.http/v1"
ProtocolSchemeHTTPV1 is the name of the protocol used for interacting with plugins using this package.
const VersionMimetype = transport.VersionMimetype
VersionMimetype is the Content-Type the engine sends to plugins.
Variables ¶
var ErrNotFound = errors.New("plugin not found")
ErrNotFound plugin not found
var ErrNotImplements = errors.New("Plugin does not implement the requested driver")
ErrNotImplements is returned if the plugin does not implement the requested driver.
Functions ¶
func IsNotFound ¶ added in v1.10.0
IsNotFound indicates if the passed in error is from an http.StatusNotFound from the plugin
func SpecsPaths ¶
func SpecsPaths() []string
SpecsPaths returns paths in which to look for plugins, in order of priority.
On Windows:
- "%programdata%\docker\plugins"
On Unix in non-rootless mode:
- "/etc/docker/plugins"
- "/usr/lib/docker/plugins"
On Unix in rootless-mode:
- "$XDG_CONFIG_HOME/docker/plugins" (or "/etc/docker/plugins" if $XDG_CONFIG_HOME is not set)
- "$HOME/.local/lib/docker/plugins" (pr "/usr/lib/docker/plugins" if $HOME is set)
func WithRequestTimeout ¶
func WithRequestTimeout(t time.Duration) func(*RequestOpts)
WithRequestTimeout sets a timeout duration for plugin requests
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a plugin client.
func NewClientWithTimeout ¶ added in v1.13.0
func NewClientWithTimeout(addr string, tlsConfig *tlsconfig.Options, timeout time.Duration) (*Client, error)
NewClientWithTimeout creates a new plugin client (http).
func (*Client) Call ¶
Call calls the specified method with the specified arguments for the plugin. It will retry for 30 seconds if a failure occurs when calling.
func (*Client) CallWithOptions ¶
func (c *Client) CallWithOptions(serviceMethod string, args interface{}, ret interface{}, opts ...func(*RequestOpts)) error
CallWithOptions is just like call except it takes options
type LocalRegistry ¶
type LocalRegistry struct {
// contains filtered or unexported fields
}
LocalRegistry defines a registry that is local (using unix socket).
func NewLocalRegistry ¶
func NewLocalRegistry() LocalRegistry
func (*LocalRegistry) GetAll ¶
func (l *LocalRegistry) GetAll(imp string) ([]*Plugin, error)
GetAll returns all the plugins for the specified implementation
func (*LocalRegistry) Plugin ¶
func (l *LocalRegistry) Plugin(name string) (*Plugin, error)
Plugin returns the plugin registered with the given name (or returns an error).
func (*LocalRegistry) Scan ¶
func (l *LocalRegistry) Scan() ([]string, error)
Scan scans all the plugin paths and returns all the names it found
type Manifest ¶
type Manifest struct { // List of subsystem the plugin implements. Implements []string }
Manifest lists what a plugin implements.
type Plugin ¶
type Plugin struct { // Address of the plugin Addr string // TLS configuration of the plugin TLSConfig *tlsconfig.Options // Manifest of the plugin (see above) Manifest *Manifest `json:"-"` // contains filtered or unexported fields }
Plugin is the definition of a docker plugin.
func NewLocalPlugin ¶ added in v1.12.0
NewLocalPlugin creates a new local plugin.
func (*Plugin) Client ¶
Client returns a ready-to-use plugin client that can be used to communicate with the plugin.
func (*Plugin) Protocol ¶
Protocol returns the protocol name/version used for plugins in this package.
func (*Plugin) ScopedPath ¶
ScopedPath returns the path scoped to the plugin's rootfs. For v1 plugins, this always returns the path unchanged as v1 plugins run directly on the host.
type RequestOpts ¶
RequestOpts is the set of options that can be passed into a request