gopkg.in/dotcloud/docker.v1@v1.13.1/daemon/graphdriver/plugin.go (about)

     1  package graphdriver
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  	"path/filepath"
     7  
     8  	"github.com/docker/docker/pkg/plugingetter"
     9  	"github.com/docker/docker/plugin/v2"
    10  )
    11  
    12  type pluginClient interface {
    13  	// Call calls the specified method with the specified arguments for the plugin.
    14  	Call(string, interface{}, interface{}) error
    15  	// Stream calls the specified method with the specified arguments for the plugin and returns the response IO stream
    16  	Stream(string, interface{}) (io.ReadCloser, error)
    17  	// SendFile calls the specified method, and passes through the IO stream
    18  	SendFile(string, io.Reader, interface{}) error
    19  }
    20  
    21  func lookupPlugin(name string, pg plugingetter.PluginGetter, config Options) (Driver, error) {
    22  	if !config.ExperimentalEnabled {
    23  		return nil, fmt.Errorf("graphdriver plugins are only supported with experimental mode")
    24  	}
    25  	pl, err := pg.Get(name, "GraphDriver", plugingetter.ACQUIRE)
    26  	if err != nil {
    27  		return nil, fmt.Errorf("Error looking up graphdriver plugin %s: %v", name, err)
    28  	}
    29  	return newPluginDriver(name, pl, config)
    30  }
    31  
    32  func newPluginDriver(name string, pl plugingetter.CompatPlugin, config Options) (Driver, error) {
    33  	home := config.Root
    34  	if !pl.IsV1() {
    35  		if p, ok := pl.(*v2.Plugin); ok {
    36  			if p.PropagatedMount != "" {
    37  				home = p.PluginObj.Config.PropagatedMount
    38  			}
    39  		}
    40  	}
    41  	proxy := &graphDriverProxy{name, pl}
    42  	return proxy, proxy.Init(filepath.Join(home, name), config.DriverOptions, config.UIDMaps, config.GIDMaps)
    43  }