2018-02-13 05:38:14 -05:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
import (
|
2018-05-03 21:02:44 -04:00
|
|
|
"context"
|
2018-02-13 05:38:14 -05:00
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
2018-06-28 16:51:54 -04:00
|
|
|
"github.com/docker/docker/api/types/filters"
|
2018-02-13 05:38:14 -05:00
|
|
|
"github.com/docker/docker/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
type fakeClient struct {
|
|
|
|
client.Client
|
|
|
|
pluginCreateFunc func(createContext io.Reader, createOptions types.PluginCreateOptions) error
|
|
|
|
pluginDisableFunc func(name string, disableOptions types.PluginDisableOptions) error
|
|
|
|
pluginEnableFunc func(name string, options types.PluginEnableOptions) error
|
|
|
|
pluginRemoveFunc func(name string, options types.PluginRemoveOptions) error
|
2018-06-23 10:21:17 -04:00
|
|
|
pluginInstallFunc func(name string, options types.PluginInstallOptions) (io.ReadCloser, error)
|
2018-06-28 16:51:54 -04:00
|
|
|
pluginListFunc func(filter filters.Args) (types.PluginsListResponse, error)
|
2018-02-13 05:38:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *fakeClient) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
|
|
|
|
if c.pluginCreateFunc != nil {
|
|
|
|
return c.pluginCreateFunc(createContext, createOptions)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *fakeClient) PluginEnable(ctx context.Context, name string, enableOptions types.PluginEnableOptions) error {
|
|
|
|
if c.pluginEnableFunc != nil {
|
|
|
|
return c.pluginEnableFunc(name, enableOptions)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *fakeClient) PluginDisable(context context.Context, name string, disableOptions types.PluginDisableOptions) error {
|
|
|
|
if c.pluginDisableFunc != nil {
|
|
|
|
return c.pluginDisableFunc(name, disableOptions)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *fakeClient) PluginRemove(context context.Context, name string, removeOptions types.PluginRemoveOptions) error {
|
|
|
|
if c.pluginRemoveFunc != nil {
|
|
|
|
return c.pluginRemoveFunc(name, removeOptions)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2018-06-23 10:21:17 -04:00
|
|
|
|
|
|
|
func (c *fakeClient) PluginInstall(context context.Context, name string, installOptions types.PluginInstallOptions) (io.ReadCloser, error) {
|
|
|
|
if c.pluginInstallFunc != nil {
|
|
|
|
return c.pluginInstallFunc(name, installOptions)
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
2018-06-28 16:51:54 -04:00
|
|
|
|
|
|
|
func (c *fakeClient) PluginList(context context.Context, filter filters.Args) (types.PluginsListResponse, error) {
|
|
|
|
if c.pluginListFunc != nil {
|
|
|
|
return c.pluginListFunc(filter)
|
|
|
|
}
|
|
|
|
|
|
|
|
return types.PluginsListResponse{}, nil
|
|
|
|
}
|