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/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
|
2024-06-09 07:54:37 -04:00
|
|
|
volumePruneFunc func(filter filters.Args) (volume.PruneReport, error)
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-02-07 10:52:18 -05:00
|
|
|
func (c *fakeClient) VolumeList(_ context.Context, options volume.ListOptions) (volume.ListResponse, error) {
|
2017-02-27 12:39:35 -05:00
|
|
|
if c.volumeListFunc != nil {
|
2023-02-07 10:52:18 -05:00
|
|
|
return c.volumeListFunc(options.Filters)
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
2022-04-29 13:26:50 -04:00
|
|
|
return volume.ListResponse{}, nil
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
|
2024-06-09 07:54:37 -04:00
|
|
|
func (c *fakeClient) VolumesPrune(_ context.Context, filter filters.Args) (volume.PruneReport, error) {
|
2017-02-27 12:39:35 -05:00
|
|
|
if c.volumePruneFunc != nil {
|
|
|
|
return c.volumePruneFunc(filter)
|
|
|
|
}
|
2024-06-09 07:54:37 -04:00
|
|
|
return volume.PruneReport{}, nil
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|