mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/types/volume: change ListResponse.Volumes to a non-pointer slice
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -30,9 +30,9 @@ func (c *Cluster) GetVolume(nameOrID string) (volumetypes.Volume, error) {
|
||||
return convert.VolumeFromGRPC(volume), nil
|
||||
}
|
||||
|
||||
// GetVolumes returns all of the volumes matching the given options from a swarm cluster.
|
||||
func (c *Cluster) GetVolumes(options volumebackend.ListOptions) ([]*volumetypes.Volume, error) {
|
||||
var volumes []*volumetypes.Volume
|
||||
// GetVolumes returns all volumes matching the given options from a swarm cluster.
|
||||
func (c *Cluster) GetVolumes(options volumebackend.ListOptions) ([]volumetypes.Volume, error) {
|
||||
var volumes []volumetypes.Volume
|
||||
if err := c.lockedManagerAction(context.TODO(), func(ctx context.Context, state nodeState) error {
|
||||
r, err := state.controlClient.ListVolumes(
|
||||
ctx, &swarmapi.ListVolumesRequest{},
|
||||
@@ -42,10 +42,9 @@ func (c *Cluster) GetVolumes(options volumebackend.ListOptions) ([]*volumetypes.
|
||||
return err
|
||||
}
|
||||
|
||||
volumes = make([]*volumetypes.Volume, 0, len(r.Volumes))
|
||||
volumes = make([]volumetypes.Volume, 0, len(r.Volumes))
|
||||
for _, volume := range r.Volumes {
|
||||
v := convert.VolumeFromGRPC(volume)
|
||||
volumes = append(volumes, &v)
|
||||
volumes = append(volumes, convert.VolumeFromGRPC(volume))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -127,7 +127,7 @@ func (daemon *Daemon) localVolumesSize(ctx context.Context, verbose bool) (*back
|
||||
}
|
||||
|
||||
if verbose {
|
||||
du.Items = sliceutil.Deref(volumes)
|
||||
du.Items = volumes
|
||||
}
|
||||
|
||||
return du, nil
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// Backend is the methods that need to be implemented to provide
|
||||
// volume specific functionality
|
||||
type Backend interface {
|
||||
List(ctx context.Context, filter filters.Args) ([]*volume.Volume, []string, error)
|
||||
List(ctx context.Context, filter filters.Args) ([]volume.Volume, []string, error)
|
||||
Get(ctx context.Context, name string, opts ...opts.GetOption) (*volume.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
|
||||
@@ -25,7 +25,7 @@ type Backend interface {
|
||||
// backends here.
|
||||
type ClusterBackend interface {
|
||||
GetVolume(nameOrID string) (volume.Volume, error)
|
||||
GetVolumes(options volumebackend.ListOptions) ([]*volume.Volume, error)
|
||||
GetVolumes(options volumebackend.ListOptions) ([]volume.Volume, error)
|
||||
CreateVolume(volume volume.CreateRequest) (*volume.Volume, error)
|
||||
RemoveVolume(nameOrID string, force bool) error
|
||||
UpdateVolume(nameOrID string, version uint64, volume volumebackend.UpdateOptions) error
|
||||
|
||||
@@ -589,10 +589,10 @@ type fakeVolumeBackend struct {
|
||||
volumes map[string]*volume.Volume
|
||||
}
|
||||
|
||||
func (b *fakeVolumeBackend) List(_ context.Context, _ filters.Args) ([]*volume.Volume, []string, error) {
|
||||
var volumes []*volume.Volume
|
||||
func (b *fakeVolumeBackend) List(_ context.Context, _ filters.Args) ([]volume.Volume, []string, error) {
|
||||
var volumes []volume.Volume
|
||||
for _, v := range b.volumes {
|
||||
volumes = append(volumes, v)
|
||||
volumes = append(volumes, *v)
|
||||
}
|
||||
return volumes, nil, nil
|
||||
}
|
||||
@@ -680,14 +680,14 @@ func (c *fakeClusterBackend) GetVolume(nameOrID string) (volume.Volume, error) {
|
||||
return volume.Volume{}, errdefs.NotFound(fmt.Errorf("volume %s not found", nameOrID))
|
||||
}
|
||||
|
||||
func (c *fakeClusterBackend) GetVolumes(_ volumebackend.ListOptions) ([]*volume.Volume, error) {
|
||||
func (c *fakeClusterBackend) GetVolumes(_ volumebackend.ListOptions) ([]volume.Volume, error) {
|
||||
if err := c.checkSwarm(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var volumes []*volume.Volume
|
||||
var volumes []volume.Volume
|
||||
for _, v := range c.volumes {
|
||||
volumes = append(volumes, v)
|
||||
volumes = append(volumes, *v)
|
||||
}
|
||||
return volumes, nil
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ type pathCacher interface {
|
||||
CachedPath() string
|
||||
}
|
||||
|
||||
func (s *VolumesService) volumesToAPI(ctx context.Context, volumes []volume.Volume, opts ...convertOpt) []*volumetypes.Volume {
|
||||
func (s *VolumesService) volumesToAPI(ctx context.Context, volumes []volume.Volume, opts ...convertOpt) []volumetypes.Volume {
|
||||
var (
|
||||
out = make([]*volumetypes.Volume, 0, len(volumes))
|
||||
out = make([]volumetypes.Volume, 0, len(volumes))
|
||||
getSize bool
|
||||
cachedPath bool
|
||||
)
|
||||
@@ -75,7 +75,7 @@ func (s *VolumesService) volumesToAPI(ctx context.Context, volumes []volume.Volu
|
||||
apiV.UsageData = &volumetypes.UsageData{Size: sz, RefCount: int64(s.vs.CountReferences(v))}
|
||||
}
|
||||
|
||||
out = append(out, &apiV)
|
||||
out = append(out, apiV)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ var acceptedListFilters = map[string]bool{
|
||||
// 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
|
||||
// local driver.
|
||||
func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]*volumetypes.Volume, error) {
|
||||
func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]volumetypes.Volume, error) {
|
||||
ls, _, err := s.vs.Find(ctx, And(ByDriver(volume.DefaultDriverName), CustomFilter(func(v volume.Volume) bool {
|
||||
dv, ok := v.(volume.DetailedVolume)
|
||||
return ok && len(dv.Options()) == 0
|
||||
@@ -262,7 +262,7 @@ func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*volum
|
||||
|
||||
// List gets the list of volumes which match the past in filters
|
||||
// If filters is nil or empty all volumes are returned.
|
||||
func (s *VolumesService) List(ctx context.Context, filter filters.Args) (volumes []*volumetypes.Volume, warnings []string, _ error) {
|
||||
func (s *VolumesService) List(ctx context.Context, filter filters.Args) (volumes []volumetypes.Volume, warnings []string, _ error) {
|
||||
by, err := filtersToBy(filter, acceptedListFilters)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
Reference in New Issue
Block a user