plugin.go 1003 B

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