api/types: replace uses of deprecated types.Volume with volume.Volume

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-03-18 16:33:43 +01:00
parent 54386f0c8f
commit 176f66df9c
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
16 changed files with 74 additions and 70 deletions

View File

@ -7,14 +7,15 @@ import (
// TODO return types need to be refactored into pkg // TODO return types need to be refactored into pkg
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
) )
// Backend is the methods that need to be implemented to provide // Backend is the methods that need to be implemented to provide
// volume specific functionality // volume specific functionality
type Backend interface { type Backend interface {
List(ctx context.Context, filter filters.Args) ([]*types.Volume, []string, error) List(ctx context.Context, filter filters.Args) ([]*volume.Volume, []string, error)
Get(ctx context.Context, name string, opts ...opts.GetOption) (*types.Volume, error) Get(ctx context.Context, name string, opts ...opts.GetOption) (*volume.Volume, error)
Create(ctx context.Context, name, driverName string, opts ...opts.CreateOption) (*types.Volume, error) Create(ctx context.Context, name, driverName string, opts ...opts.CreateOption) (*volume.Volume, error)
Remove(ctx context.Context, name string, opts ...opts.RemoveOption) error Remove(ctx context.Context, name string, opts ...opts.RemoveOption) error
Prune(ctx context.Context, pruneFilters filters.Args) (*types.VolumesPruneReport, error) Prune(ctx context.Context, pruneFilters filters.Args) (*types.VolumesPruneReport, error)
} }

View File

@ -14,6 +14,7 @@ import (
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/volume"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
) )
@ -686,7 +687,7 @@ type DiskUsage struct {
LayersSize int64 LayersSize int64
Images []*ImageSummary Images []*ImageSummary
Containers []*Container Containers []*Container
Volumes []*Volume Volumes []*volume.Volume
BuildCache []*BuildCache BuildCache []*BuildCache
BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
} }

View File

@ -173,9 +173,9 @@ type SystemAPIClient interface {
// VolumeAPIClient defines API client methods for the volumes // VolumeAPIClient defines API client methods for the volumes
type VolumeAPIClient interface { type VolumeAPIClient interface {
VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (types.Volume, error) VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (volume.Volume, error)
VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)
VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error) VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error)
VolumeRemove(ctx context.Context, volumeID string, force bool) error VolumeRemove(ctx context.Context, volumeID string, force bool) error
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error) VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)

View File

@ -4,18 +4,17 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/volume"
volumetypes "github.com/docker/docker/api/types/volume"
) )
// VolumeCreate creates a volume in the docker host. // VolumeCreate creates a volume in the docker host.
func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error) { func (cli *Client) VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (volume.Volume, error) {
var volume types.Volume var vol volume.Volume
resp, err := cli.post(ctx, "/volumes/create", nil, options, nil) resp, err := cli.post(ctx, "/volumes/create", nil, options, nil)
defer ensureReaderClosed(resp) defer ensureReaderClosed(resp)
if err != nil { if err != nil {
return volume, err return vol, err
} }
err = json.NewDecoder(resp.body).Decode(&volume) err = json.NewDecoder(resp.body).Decode(&vol)
return volume, err return vol, err
} }

View File

@ -10,8 +10,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/volume"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
) )
@ -20,7 +19,7 @@ func TestVolumeCreateError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{}) _, err := client.VolumeCreate(context.Background(), volume.VolumeCreateBody{})
if !errdefs.IsSystem(err) { if !errdefs.IsSystem(err) {
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err) t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
} }
@ -39,7 +38,7 @@ func TestVolumeCreate(t *testing.T) {
return nil, fmt.Errorf("expected POST method, got %s", req.Method) return nil, fmt.Errorf("expected POST method, got %s", req.Method)
} }
content, err := json.Marshal(types.Volume{ content, err := json.Marshal(volume.Volume{
Name: "volume", Name: "volume",
Driver: "local", Driver: "local",
Mountpoint: "mountpoint", Mountpoint: "mountpoint",
@ -54,7 +53,7 @@ func TestVolumeCreate(t *testing.T) {
}), }),
} }
volume, err := client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{ vol, err := client.VolumeCreate(context.Background(), volume.VolumeCreateBody{
Name: "myvolume", Name: "myvolume",
Driver: "mydriver", Driver: "mydriver",
DriverOpts: map[string]string{ DriverOpts: map[string]string{
@ -64,13 +63,13 @@ func TestVolumeCreate(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if volume.Name != "volume" { if vol.Name != "volume" {
t.Fatalf("expected volume.Name to be 'volume', got %s", volume.Name) t.Fatalf("expected volume.Name to be 'volume', got %s", vol.Name)
} }
if volume.Driver != "local" { if vol.Driver != "local" {
t.Fatalf("expected volume.Driver to be 'local', got %s", volume.Driver) t.Fatalf("expected volume.Driver to be 'local', got %s", vol.Driver)
} }
if volume.Mountpoint != "mountpoint" { if vol.Mountpoint != "mountpoint" {
t.Fatalf("expected volume.Mountpoint to be 'mountpoint', got %s", volume.Mountpoint) t.Fatalf("expected volume.Mountpoint to be 'mountpoint', got %s", vol.Mountpoint)
} }
} }

View File

@ -6,33 +6,33 @@ import (
"encoding/json" "encoding/json"
"io" "io"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/volume"
) )
// VolumeInspect returns the information about a specific volume in the docker host. // VolumeInspect returns the information about a specific volume in the docker host.
func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) { func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) {
volume, _, err := cli.VolumeInspectWithRaw(ctx, volumeID) vol, _, err := cli.VolumeInspectWithRaw(ctx, volumeID)
return volume, err return vol, err
} }
// VolumeInspectWithRaw returns the information about a specific volume in the docker host and its raw representation // VolumeInspectWithRaw returns the information about a specific volume in the docker host and its raw representation
func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) { func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) {
if volumeID == "" { if volumeID == "" {
return types.Volume{}, nil, objectNotFoundError{object: "volume", id: volumeID} return volume.Volume{}, nil, objectNotFoundError{object: "volume", id: volumeID}
} }
var volume types.Volume var vol volume.Volume
resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil) resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil)
defer ensureReaderClosed(resp) defer ensureReaderClosed(resp)
if err != nil { if err != nil {
return volume, nil, err return vol, nil, err
} }
body, err := io.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return volume, nil, err return vol, nil, err
} }
rdr := bytes.NewReader(body) rdr := bytes.NewReader(body)
err = json.NewDecoder(rdr).Decode(&volume) err = json.NewDecoder(rdr).Decode(&vol)
return volume, body, err return vol, body, err
} }

View File

@ -10,7 +10,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
@ -51,7 +51,7 @@ func TestVolumeInspectWithEmptyID(t *testing.T) {
func TestVolumeInspect(t *testing.T) { func TestVolumeInspect(t *testing.T) {
expectedURL := "/volumes/volume_id" expectedURL := "/volumes/volume_id"
expected := types.Volume{ expected := volume.Volume{
Name: "name", Name: "name",
Driver: "driver", Driver: "driver",
Mountpoint: "mountpoint", Mountpoint: "mountpoint",

View File

@ -10,9 +10,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
) )
@ -70,8 +69,8 @@ func TestVolumeList(t *testing.T) {
if actualFilters != listCase.expectedFilters { if actualFilters != listCase.expectedFilters {
return nil, fmt.Errorf("filters not set in URL query properly. Expected '%s', got %s", listCase.expectedFilters, actualFilters) return nil, fmt.Errorf("filters not set in URL query properly. Expected '%s', got %s", listCase.expectedFilters, actualFilters)
} }
content, err := json.Marshal(volumetypes.VolumeListOKBody{ content, err := json.Marshal(volume.VolumeListOKBody{
Volumes: []*types.Volume{ Volumes: []*volume.Volume{
{ {
Name: "volume", Name: "volume",
Driver: "local", Driver: "local",

View File

@ -14,6 +14,7 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
swarmtypes "github.com/docker/docker/api/types/swarm" swarmtypes "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/volume"
containerpkg "github.com/docker/docker/container" containerpkg "github.com/docker/docker/container"
clustertypes "github.com/docker/docker/daemon/cluster/provider" clustertypes "github.com/docker/docker/daemon/cluster/provider"
networkSettings "github.com/docker/docker/daemon/network" networkSettings "github.com/docker/docker/daemon/network"
@ -66,7 +67,7 @@ type Backend interface {
// VolumeBackend is used by an executor to perform volume operations // VolumeBackend is used by an executor to perform volume operations
type VolumeBackend interface { type VolumeBackend interface {
Create(ctx context.Context, name, driverName string, opts ...volumeopts.CreateOption) (*types.Volume, error) Create(ctx context.Context, name, driverName string, opts ...volumeopts.CreateOption) (*volume.Volume, error)
} }
// ImageBackend is used by an executor to perform image operations // ImageBackend is used by an executor to perform image operations

View File

@ -6,6 +6,7 @@ import (
"github.com/docker/docker/api/server/router/system" "github.com/docker/docker/api/server/router/system"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/volume"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
) )
@ -64,7 +65,7 @@ func (daemon *Daemon) SystemDiskUsage(ctx context.Context, opts system.DiskUsage
}) })
} }
var volumes []*types.Volume var volumes []*volume.Volume
if opts.Volumes { if opts.Volumes {
eg.Go(func() error { eg.Go(func() error {
var err error var err error

View File

@ -8,10 +8,10 @@ import (
"strings" "strings"
"time" "time"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/mount"
mounttypes "github.com/docker/docker/api/types/mount" mounttypes "github.com/docker/docker/api/types/mount"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/container" "github.com/docker/docker/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/docker/docker/volume" "github.com/docker/docker/volume"
@ -186,7 +186,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo
} }
if mp.Type == mounttypes.TypeVolume { if mp.Type == mounttypes.TypeVolume {
var v *types.Volume var v *volumetypes.Volume
if cfg.VolumeOptions != nil { if cfg.VolumeOptions != nil {
var driverOpts map[string]string var driverOpts map[string]string
if cfg.VolumeOptions.DriverConfig != nil { if cfg.VolumeOptions.DriverConfig != nil {
@ -384,12 +384,12 @@ func (daemon *Daemon) VolumesService() *service.VolumesService {
} }
type volumeMounter interface { type volumeMounter interface {
Mount(ctx context.Context, v *types.Volume, ref string) (string, error) Mount(ctx context.Context, v *volumetypes.Volume, ref string) (string, error)
Unmount(ctx context.Context, v *types.Volume, ref string) error Unmount(ctx context.Context, v *volumetypes.Volume, ref string) error
} }
type volumeWrapper struct { type volumeWrapper struct {
v *types.Volume v *volumetypes.Volume
s volumeMounter s volumeMounter
} }

View File

@ -14,6 +14,7 @@ import (
"time" "time"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/daemon"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
testdaemon "github.com/docker/docker/testutil/daemon" testdaemon "github.com/docker/docker/testutil/daemon"
@ -565,7 +566,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *t
out, err = s.d.Cmd("volume", "inspect", "test") out, err = s.d.Cmd("volume", "inspect", "test")
assert.NilError(c, err, out) assert.NilError(c, err, out)
var vs []types.Volume var vs []volumetypes.Volume
err = json.Unmarshal([]byte(out), &vs) err = json.Unmarshal([]byte(out), &vs)
assert.NilError(c, err) assert.NilError(c, err)
assert.Equal(c, len(vs), 1) assert.Equal(c, len(vs), 1)

View File

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/testutil/daemon" "github.com/docker/docker/testutil/daemon"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
@ -37,7 +38,7 @@ func TestDiskUsage(t *testing.T) {
assert.DeepEqual(t, du, types.DiskUsage{ assert.DeepEqual(t, du, types.DiskUsage{
Images: []*types.ImageSummary{}, Images: []*types.ImageSummary{},
Containers: []*types.Container{}, Containers: []*types.Container{},
Volumes: []*types.Volume{}, Volumes: []*volume.Volume{},
BuildCache: []*types.BuildCache{}, BuildCache: []*types.BuildCache{},
}) })
return du return du
@ -64,7 +65,7 @@ func TestDiskUsage(t *testing.T) {
}, },
}, },
Containers: []*types.Container{}, Containers: []*types.Container{},
Volumes: []*types.Volume{}, Volumes: []*volume.Volume{},
BuildCache: []*types.BuildCache{}, BuildCache: []*types.BuildCache{},
}) })
return du return du
@ -107,7 +108,7 @@ func TestDiskUsage(t *testing.T) {
Mounts: du.Containers[0].Mounts, // not relevant for the test Mounts: du.Containers[0].Mounts, // not relevant for the test
}, },
}, },
Volumes: []*types.Volume{}, Volumes: []*volume.Volume{},
BuildCache: []*types.BuildCache{}, BuildCache: []*types.BuildCache{},
}) })
return du return du

View File

@ -10,7 +10,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/testutil/request" "github.com/docker/docker/testutil/request"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
@ -28,12 +28,12 @@ func TestVolumesCreateAndList(t *testing.T) {
if testEnv.OSType == "windows" { if testEnv.OSType == "windows" {
name = strings.ToLower(name) name = strings.ToLower(name)
} }
vol, err := client.VolumeCreate(ctx, volumetypes.VolumeCreateBody{ vol, err := client.VolumeCreate(ctx, volume.VolumeCreateBody{
Name: name, Name: name,
}) })
assert.NilError(t, err) assert.NilError(t, err)
expected := types.Volume{ expected := volume.Volume{
// Ignore timestamp of CreatedAt // Ignore timestamp of CreatedAt
CreatedAt: vol.CreatedAt, CreatedAt: vol.CreatedAt,
Driver: "local", Driver: "local",
@ -90,7 +90,7 @@ func TestVolumesInspect(t *testing.T) {
ctx := context.Background() ctx := context.Background()
now := time.Now() now := time.Now()
vol, err := client.VolumeCreate(ctx, volumetypes.VolumeCreateBody{}) vol, err := client.VolumeCreate(ctx, volume.VolumeCreateBody{})
assert.NilError(t, err) assert.NilError(t, err)
inspected, err := client.VolumeInspect(ctx, vol.Name) inspected, err := client.VolumeInspect(ctx, vol.Name)

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"time" "time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/pkg/directory" "github.com/docker/docker/pkg/directory"
"github.com/docker/docker/volume" "github.com/docker/docker/volume"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -28,9 +28,9 @@ type pathCacher interface {
CachedPath() string CachedPath() string
} }
func (s *VolumesService) volumesToAPI(ctx context.Context, volumes []volume.Volume, opts ...convertOpt) []*types.Volume { func (s *VolumesService) volumesToAPI(ctx context.Context, volumes []volume.Volume, opts ...convertOpt) []*volumetypes.Volume {
var ( var (
out = make([]*types.Volume, 0, len(volumes)) out = make([]*volumetypes.Volume, 0, len(volumes))
getSize bool getSize bool
cachedPath bool cachedPath bool
) )
@ -69,7 +69,7 @@ func (s *VolumesService) volumesToAPI(ctx context.Context, volumes []volume.Volu
logrus.WithError(err).WithField("volume", v.Name()).Warnf("Failed to determine size of volume") logrus.WithError(err).WithField("volume", v.Name()).Warnf("Failed to determine size of volume")
sz = -1 sz = -1
} }
apiV.UsageData = &types.VolumeUsageData{Size: sz, RefCount: int64(s.vs.CountReferences(v))} apiV.UsageData = &volumetypes.VolumeUsageData{Size: sz, RefCount: int64(s.vs.CountReferences(v))}
} }
out = append(out, &apiV) out = append(out, &apiV)
@ -77,9 +77,9 @@ func (s *VolumesService) volumesToAPI(ctx context.Context, volumes []volume.Volu
return out return out
} }
func volumeToAPIType(v volume.Volume) types.Volume { func volumeToAPIType(v volume.Volume) volumetypes.Volume {
createdAt, _ := v.CreatedAt() createdAt, _ := v.CreatedAt()
tv := types.Volume{ tv := volumetypes.Volume{
Name: v.Name(), Name: v.Name(),
Driver: v.DriverName(), Driver: v.DriverName(),
CreatedAt: createdAt.Format(time.RFC3339), CreatedAt: createdAt.Format(time.RFC3339),

View File

@ -7,6 +7,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/docker/docker/pkg/directory" "github.com/docker/docker/pkg/directory"
"github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/idtools"
@ -66,7 +67,7 @@ func (s *VolumesService) GetDriverList() []string {
// //
// A good example for a reference ID is a container's ID. // A good example for a reference ID is a container's ID.
// When whatever is going to reference this volume is removed the caller should defeference the volume by calling `Release`. // When whatever is going to reference this volume is removed the caller should defeference the volume by calling `Release`.
func (s *VolumesService) Create(ctx context.Context, name, driverName string, opts ...opts.CreateOption) (*types.Volume, error) { func (s *VolumesService) Create(ctx context.Context, name, driverName string, opts ...opts.CreateOption) (*volumetypes.Volume, error) {
if name == "" { if name == "" {
name = stringid.GenerateRandomID() name = stringid.GenerateRandomID()
} }
@ -80,7 +81,7 @@ func (s *VolumesService) Create(ctx context.Context, name, driverName string, op
} }
// Get returns details about a volume // Get returns details about a volume
func (s *VolumesService) Get(ctx context.Context, name string, getOpts ...opts.GetOption) (*types.Volume, error) { func (s *VolumesService) Get(ctx context.Context, name string, getOpts ...opts.GetOption) (*volumetypes.Volume, error) {
v, err := s.vs.Get(ctx, name, getOpts...) v, err := s.vs.Get(ctx, name, getOpts...)
if err != nil { if err != nil {
return nil, err return nil, err
@ -107,7 +108,7 @@ func (s *VolumesService) Get(ctx context.Context, name string, getOpts ...opts.G
// s.Mount(ctx, vol, mountID) // s.Mount(ctx, vol, mountID)
// s.Unmount(ctx, vol, mountID) // s.Unmount(ctx, vol, mountID)
// ``` // ```
func (s *VolumesService) Mount(ctx context.Context, vol *types.Volume, ref string) (string, error) { func (s *VolumesService) Mount(ctx context.Context, vol *volumetypes.Volume, ref string) (string, error) {
v, err := s.vs.Get(ctx, vol.Name, opts.WithGetDriver(vol.Driver)) v, err := s.vs.Get(ctx, vol.Name, opts.WithGetDriver(vol.Driver))
if err != nil { if err != nil {
if IsNotExist(err) { if IsNotExist(err) {
@ -124,7 +125,7 @@ func (s *VolumesService) Mount(ctx context.Context, vol *types.Volume, ref strin
// The reference specified here should be the same reference specified during `Mount` and should be // The reference specified here should be the same reference specified during `Mount` and should be
// unique for each mount/unmount pair. // unique for each mount/unmount pair.
// See `Mount` documentation for an example. // See `Mount` documentation for an example.
func (s *VolumesService) Unmount(ctx context.Context, vol *types.Volume, ref string) error { func (s *VolumesService) Unmount(ctx context.Context, vol *volumetypes.Volume, ref string) error {
v, err := s.vs.Get(ctx, vol.Name, opts.WithGetDriver(vol.Driver)) v, err := s.vs.Get(ctx, vol.Name, opts.WithGetDriver(vol.Driver))
if err != nil { if err != nil {
if IsNotExist(err) { if IsNotExist(err) {
@ -183,7 +184,7 @@ var acceptedListFilters = map[string]bool{
// Note that this intentionally skips volumes which have mount options. Typically // Note that this intentionally skips volumes which have mount options. Typically
// volumes with mount options are not really local even if they are using the // volumes with mount options are not really local even if they are using the
// local driver. // local driver.
func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]*types.Volume, error) { func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]*volumetypes.Volume, error) {
ch := s.usage.DoChan("LocalVolumesSize", func() (interface{}, error) { ch := s.usage.DoChan("LocalVolumesSize", func() (interface{}, error) {
ls, _, err := s.vs.Find(ctx, And(ByDriver(volume.DefaultDriverName), CustomFilter(func(v volume.Volume) bool { ls, _, err := s.vs.Find(ctx, And(ByDriver(volume.DefaultDriverName), CustomFilter(func(v volume.Volume) bool {
dv, ok := v.(volume.DetailedVolume) dv, ok := v.(volume.DetailedVolume)
@ -201,7 +202,7 @@ func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]*types.Volume,
if res.Err != nil { if res.Err != nil {
return nil, res.Err return nil, res.Err
} }
return res.Val.([]*types.Volume), nil return res.Val.([]*volumetypes.Volume), nil
} }
} }
@ -257,7 +258,7 @@ func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*types
// List gets the list of volumes which match the past in filters // List gets the list of volumes which match the past in filters
// If filters is nil or empty all volumes are returned. // If filters is nil or empty all volumes are returned.
func (s *VolumesService) List(ctx context.Context, filter filters.Args) (volumesOut []*types.Volume, warnings []string, err error) { func (s *VolumesService) List(ctx context.Context, filter filters.Args) (volumesOut []*volumetypes.Volume, warnings []string, err error) {
by, err := filtersToBy(filter, acceptedListFilters) by, err := filtersToBy(filter, acceptedListFilters)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err