mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #51210 from austinvazquez/refactor-client-volume
client/volume: refactor volume options and responses
This commit is contained in:
@@ -127,14 +127,17 @@ func removeImage(ctx context.Context, t testing.TB, apiclient client.ImageAPICli
|
||||
|
||||
func deleteAllVolumes(ctx context.Context, t testing.TB, c client.VolumeAPIClient, protectedVolumes map[string]struct{}) {
|
||||
t.Helper()
|
||||
volumes, err := c.VolumeList(ctx, client.VolumeListOptions{})
|
||||
res, err := c.VolumeList(ctx, client.VolumeListOptions{})
|
||||
assert.Check(t, err, "failed to list volumes")
|
||||
volumeList := res.List
|
||||
|
||||
for _, v := range volumes.Volumes {
|
||||
for _, v := range volumeList.Volumes {
|
||||
if _, ok := protectedVolumes[v.Name]; ok {
|
||||
continue
|
||||
}
|
||||
err := c.VolumeRemove(ctx, v.Name, true)
|
||||
err := c.VolumeRemove(ctx, v.Name, client.VolumeRemoveOptions{
|
||||
Force: true,
|
||||
})
|
||||
assert.Check(t, err, "failed to remove volume %s", v.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,8 +227,9 @@ func ProtectVolumes(ctx context.Context, t testing.TB, testEnv *Execution) {
|
||||
func getExistingVolumes(ctx context.Context, t testing.TB, testEnv *Execution) []string {
|
||||
t.Helper()
|
||||
apiClient := testEnv.APIClient()
|
||||
volumeList, err := apiClient.VolumeList(ctx, client.VolumeListOptions{})
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user