plugin.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package graphdriver
  2. import (
  3. "fmt"
  4. "io"
  5. "path/filepath"
  6. "github.com/docker/docker/pkg/plugingetter"
  7. "github.com/docker/docker/plugin/v2"
  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, pg plugingetter.PluginGetter) (Driver, error) {
  18. pl, err := pg.Get(name, "GraphDriver", plugingetter.LOOKUP)
  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)
  23. }
  24. func newPluginDriver(name, home string, opts []string, pl plugingetter.CompatPlugin) (Driver, error) {
  25. if !pl.IsV1() {
  26. if p, ok := pl.(*v2.Plugin); ok {
  27. if p.PropagatedMount != "" {
  28. home = p.PluginObj.Config.PropagatedMount
  29. }
  30. }
  31. }
  32. proxy := &graphDriverProxy{name, pl}
  33. return proxy, proxy.Init(filepath.Join(home, name), opts)
  34. }