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"
|
2022-04-29 13:26:50 -04:00
|
|
|
"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
|
2022-04-29 13:26:50 -04:00
|
|
|
volumeCreateFunc func(volume.CreateOptions) (volume.Volume, error)
|
|
|
|
volumeInspectFunc func(volumeID string) (volume.Volume, error)
|
|
|
|
volumeListFunc func(filter filters.Args) (volume.ListResponse, error)
|
2017-02-27 12:39:35 -05:00
|
|
|
volumeRemoveFunc func(volumeID string, force bool) error
|
|
|
|
volumePruneFunc func(filter filters.Args) (types.VolumesPruneReport, error)
|
|
|
|
}
|
|
|
|
|
2022-04-29 13:26:50 -04:00
|
|
|
func (c *fakeClient) VolumeCreate(_ context.Context, options volume.CreateOptions) (volume.Volume, error) {
|
2017-02-27 12:39:35 -05:00
|
|
|
if c.volumeCreateFunc != nil {
|
|
|
|
return c.volumeCreateFunc(options)
|
|
|
|
}
|
2022-04-29 13:26:50 -04:00
|
|
|
return volume.Volume{}, nil
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
|
2022-04-29 13:26:50 -04:00
|
|
|
func (c *fakeClient) VolumeInspect(_ context.Context, volumeID string) (volume.Volume, error) {
|
2017-02-27 12:39:35 -05:00
|
|
|
if c.volumeInspectFunc != nil {
|
|
|
|
return c.volumeInspectFunc(volumeID)
|
|
|
|
}
|
2022-04-29 13:26:50 -04:00
|
|
|
return volume.Volume{}, nil
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
|
2022-04-29 13:26:50 -04:00
|
|
|
func (c *fakeClient) VolumeList(_ context.Context, filter filters.Args) (volume.ListResponse, error) {
|
2017-02-27 12:39:35 -05:00
|
|
|
if c.volumeListFunc != nil {
|
|
|
|
return c.volumeListFunc(filter)
|
|
|
|
}
|
2022-04-29 13:26:50 -04:00
|
|
|
return volume.ListResponse{}, nil
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
|
2022-04-29 13:26:50 -04:00
|
|
|
func (c *fakeClient) VolumesPrune(_ context.Context, filter filters.Args) (types.VolumesPruneReport, error) {
|
2017-02-27 12:39:35 -05:00
|
|
|
if c.volumePruneFunc != nil {
|
|
|
|
return c.volumePruneFunc(filter)
|
|
|
|
}
|
|
|
|
return types.VolumesPruneReport{}, nil
|
|
|
|
}
|
|
|
|
|
2022-04-29 13:26:50 -04:00
|
|
|
func (c *fakeClient) VolumeRemove(_ context.Context, volumeID string, force bool) error {
|
2017-02-27 12:39:35 -05:00
|
|
|
if c.volumeRemoveFunc != nil {
|
|
|
|
return c.volumeRemoveFunc(volumeID, force)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|