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:
Sebastiaan van Stijn
2025-10-21 18:07:50 +02:00
parent ac9838ffd1
commit 5a04a9718d
6 changed files with 14 additions and 17 deletions

View File

@@ -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
}

View File

@@ -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))
}
}

View File

@@ -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)
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -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
}