plugin.go 1018 B

123456789101112131415161718192021222324252627282930313233
  1. // +build experimental
  2. // +build daemon
  3. package graphdriver
  4. import (
  5. "fmt"
  6. "io"
  7. "github.com/docker/docker/pkg/plugins"
  8. )
  9. type pluginClient interface {
  10. // Call calls the specified method with the specified arguments for the plugin.
  11. Call(string, interface{}, interface{}) error
  12. // Stream calls the specified method with the specified arguments for the plugin and returns the response IO stream
  13. Stream(string, interface{}) (io.ReadCloser, error)
  14. // SendFile calls the specified method, and passes through the IO stream
  15. SendFile(string, io.Reader, interface{}) error
  16. }
  17. func lookupPlugin(name, home string, opts []string) (Driver, error) {
  18. pl, err := plugins.Get(name, "GraphDriver")
  19. if err != nil {
  20. return nil, fmt.Errorf("Error looking up graphdriver plugin %s: %v", name, err)
  21. }
  22. return newPluginDriver(name, home, opts, pl.Client)
  23. }
  24. func newPluginDriver(name, home string, opts []string, c pluginClient) (Driver, error) {
  25. proxy := &graphDriverProxy{name, c}
  26. return proxy, proxy.Init(home, opts)
  27. }