2017-02-27 12:39:35 -05:00
|
|
|
package volume
|
|
|
|
|
|
|
|
import (
|
2018-05-03 21:02:44 -04:00
|
|
|
"context"
|
|
|
|
|
2017-02-27 12:39:35 -05:00
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/api/types/filters"
|
|
|
|
volumetypes "github.com/docker/docker/api/types/volume"
|
2017-05-08 13:51:30 -04:00
|
|
|
"github.com/docker/docker/client"
|
2017-02-27 12:39:35 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type fakeClient struct {
|
|
|
|
client.Client
|
2018-05-17 11:09:10 -04:00
|
|
|
volumeCreateFunc func(volumetypes.VolumeCreateBody) (types.Volume, error)
|
2017-02-27 12:39:35 -05:00
|
|
|
volumeInspectFunc func(volumeID string) (types.Volume, error)
|
2018-05-17 11:09:10 -04:00
|
|
|
volumeListFunc func(filter filters.Args) (volumetypes.VolumeListOKBody, error)
|
2017-02-27 12:39:35 -05:00
|
|
|
volumeRemoveFunc func(volumeID string, force bool) error
|
|
|
|
volumePruneFunc func(filter filters.Args) (types.VolumesPruneReport, error)
|
|
|
|
}
|
|
|
|
|
2018-05-17 11:09:10 -04:00
|
|
|
func (c *fakeClient) VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error) {
|
2017-02-27 12:39:35 -05:00
|
|
|
if c.volumeCreateFunc != nil {
|
|
|
|
return c.volumeCreateFunc(options)
|
|
|
|
}
|
|
|
|
return types.Volume{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *fakeClient) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) {
|
|
|
|
if c.volumeInspectFunc != nil {
|
|
|
|
return c.volumeInspectFunc(volumeID)
|
|
|
|
}
|
|
|
|
return types.Volume{}, nil
|
|
|
|
}
|
|
|
|
|
2018-05-17 11:09:10 -04:00
|
|
|
func (c *fakeClient) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) {
|
2017-02-27 12:39:35 -05:00
|
|
|
if c.volumeListFunc != nil {
|
|
|
|
return c.volumeListFunc(filter)
|
|
|
|
}
|
2018-05-17 11:09:10 -04:00
|
|
|
return volumetypes.VolumeListOKBody{}, nil
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *fakeClient) VolumesPrune(ctx context.Context, filter filters.Args) (types.VolumesPruneReport, error) {
|
|
|
|
if c.volumePruneFunc != nil {
|
|
|
|
return c.volumePruneFunc(filter)
|
|
|
|
}
|
|
|
|
return types.VolumesPruneReport{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *fakeClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
|
|
|
|
if c.volumeRemoveFunc != nil {
|
|
|
|
return c.volumeRemoveFunc(volumeID, force)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|