github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/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 ) 10 11 type pluginClient interface { 12 // Call calls the specified method with the specified arguments for the plugin. 13 Call(string, interface{}, interface{}) error 14 // Stream calls the specified method with the specified arguments for the plugin and returns the response IO stream 15 Stream(string, interface{}) (io.ReadCloser, error) 16 // SendFile calls the specified method, and passes through the IO stream 17 SendFile(string, io.Reader, interface{}) error 18 } 19 20 func lookupPlugin(name, home string, opts []string, pg plugingetter.PluginGetter) (Driver, error) { 21 pl, err := pg.Get(name, "GraphDriver", plugingetter.LOOKUP) 22 if err != nil { 23 return nil, fmt.Errorf("Error looking up graphdriver plugin %s: %v", name, err) 24 } 25 return newPluginDriver(name, home, opts, pl.Client()) 26 } 27 28 func newPluginDriver(name, home string, opts []string, c pluginClient) (Driver, error) { 29 proxy := &graphDriverProxy{name, c} 30 return proxy, proxy.Init(filepath.Join(home, name), opts) 31 }