mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: rename VolumeListResult.List to VolumeListResult.Items
Trying to find a common naming for these fields. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -15,7 +15,7 @@ type VolumeListOptions struct {
|
||||
|
||||
// VolumeListResult holds the result from the [Client.VolumeList] method.
|
||||
type VolumeListResult struct {
|
||||
List volume.ListResponse
|
||||
Items volume.ListResponse
|
||||
}
|
||||
|
||||
// VolumeList returns the volumes configured in the docker host.
|
||||
@@ -29,7 +29,7 @@ func (cli *Client) VolumeList(ctx context.Context, options VolumeListOptions) (V
|
||||
return VolumeListResult{}, err
|
||||
}
|
||||
|
||||
var volumes volume.ListResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&volumes)
|
||||
return VolumeListResult{List: volumes}, err
|
||||
var res VolumeListResult
|
||||
err = json.NewDecoder(resp.Body).Decode(&res.Items)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -74,6 +74,6 @@ func TestVolumeList(t *testing.T) {
|
||||
|
||||
result, err := client.VolumeList(context.Background(), VolumeListOptions{Filters: listCase.filters})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(result.List.Volumes, 1))
|
||||
assert.Check(t, is.Len(result.Items.Volumes, 1))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,11 +50,10 @@ func TestVolumesCreateAndList(t *testing.T) {
|
||||
|
||||
res, err := apiClient.VolumeList(ctx, client.VolumeListOptions{})
|
||||
assert.NilError(t, err)
|
||||
volList := res.List
|
||||
assert.Assert(t, len(volList.Volumes) > 0)
|
||||
assert.Assert(t, len(res.Items.Volumes) > 0)
|
||||
|
||||
volumes := volList.Volumes[:0]
|
||||
for _, v := range volList.Volumes {
|
||||
volumes := res.Items.Volumes[:0]
|
||||
for _, v := range res.Items.Volumes {
|
||||
if v.Name == namedV.Name {
|
||||
volumes = append(volumes, v)
|
||||
}
|
||||
|
||||
@@ -129,9 +129,8 @@ func deleteAllVolumes(ctx context.Context, t testing.TB, c client.VolumeAPIClien
|
||||
t.Helper()
|
||||
res, err := c.VolumeList(ctx, client.VolumeListOptions{})
|
||||
assert.Check(t, err, "failed to list volumes")
|
||||
volumeList := res.List
|
||||
|
||||
for _, v := range volumeList.Volumes {
|
||||
for _, v := range res.Items.Volumes {
|
||||
if _, ok := protectedVolumes[v.Name]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -229,10 +229,9 @@ func getExistingVolumes(ctx context.Context, t testing.TB, testEnv *Execution) [
|
||||
apiClient := testEnv.APIClient()
|
||||
res, err := apiClient.VolumeList(ctx, client.VolumeListOptions{})
|
||||
assert.NilError(t, err, "failed to list volumes")
|
||||
volumeList := res.List
|
||||
|
||||
var volumes []string
|
||||
for _, vol := range volumeList.Volumes {
|
||||
for _, vol := range res.Items.Volumes {
|
||||
volumes = append(volumes, vol.Name)
|
||||
}
|
||||
return volumes
|
||||
|
||||
8
vendor/github.com/moby/moby/client/volume_list.go
generated
vendored
8
vendor/github.com/moby/moby/client/volume_list.go
generated
vendored
@@ -15,7 +15,7 @@ type VolumeListOptions struct {
|
||||
|
||||
// VolumeListResult holds the result from the [Client.VolumeList] method.
|
||||
type VolumeListResult struct {
|
||||
List volume.ListResponse
|
||||
Items volume.ListResponse
|
||||
}
|
||||
|
||||
// VolumeList returns the volumes configured in the docker host.
|
||||
@@ -29,7 +29,7 @@ func (cli *Client) VolumeList(ctx context.Context, options VolumeListOptions) (V
|
||||
return VolumeListResult{}, err
|
||||
}
|
||||
|
||||
var volumes volume.ListResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&volumes)
|
||||
return VolumeListResult{List: volumes}, err
|
||||
var res VolumeListResult
|
||||
err = json.NewDecoder(resp.Body).Decode(&res.Items)
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user