package plugins
import "github.com/docker/cli/components/engine/pkg/plugins"
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 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 ¶
- Variables
- func Handle(iface string, fn func(string, *Client))
- func IsNotFound(err error) bool
- func Scan() ([]string, error)
- type Client
- func NewClient(addr string, tlsConfig *tlsconfig.Options) (*Client, error)
- func NewClientWithTimeout(addr string, tlsConfig *tlsconfig.Options, timeout time.Duration) (*Client, error)
- func (c *Client) Call(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 Manifest
- type Plugin
Variables ¶
var ( // ErrNotImplements is returned if the plugin does not implement the requested driver. ErrNotImplements = errors.New("Plugin does not implement the requested driver") )
Functions ¶
func Handle ¶
Handle adds the specified function to the extpointHandlers.
func IsNotFound ¶
IsNotFound indicates if the passed in error is from an http.StatusNotFound from the plugin
func Scan ¶
Scan scans all the plugin paths and returns all the names it found
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a plugin client.
func NewClient ¶
NewClient creates a new plugin client (http).
func NewClientWithTimeout ¶
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) SendFile ¶
SendFile calls the specified method, and passes through the IO stream
func (*Client) Stream ¶
func (c *Client) Stream(serviceMethod string, args interface{}) (io.ReadCloser, error)
Stream calls the specified method with the specified arguments for the plugin and returns the response body
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 Get ¶
Get returns the plugin given the specified name and requested implementation.
func GetAll ¶
GetAll returns all the plugins for the specified implementation
func NewLocalPlugin ¶
NewLocalPlugin creates a new local plugin.
func (*Plugin) BasePath ¶
BasePath returns the path to which all paths returned by the plugin are relative to. For v1 plugins, this always returns the host's root directory.
func (*Plugin) Client ¶
Client returns a ready-to-use plugin client that can be used to communicate with the plugin.
func (*Plugin) IsV1 ¶
IsV1 returns true for V1 plugins and false otherwise.
func (*Plugin) Name ¶
Name returns the name of the plugin.
Source Files ¶
client.go discovery.go discovery_unix.go errors.go plugins.go plugins_unix.go
Directories ¶
- Version
- v17.10.0-ce-rc1+incompatible
- Published
- Oct 4, 2017
- Platform
- darwin/amd64
- Imports
- 17 packages
- Last checked
- 2 seconds ago –
Tools for package owners.