Skip to content

Commit a6e2e71

Browse files
committed
ensureImage: early return instead of break
1 parent 27bf167 commit a6e2e71

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

integration/integration_test.go

+6-10
Original file line numberDiff line numberDiff line change
@@ -225,21 +225,17 @@ func ensureImage(ctx context.Context, t *testing.T, cli *client.Client, ref stri
225225
t.Logf("ensuring image %q", ref)
226226
images, err := cli.ImageList(ctx, image.ListOptions{})
227227
require.NoError(t, err, "list images")
228-
var found bool
229228
for _, img := range images {
230229
if slices.Contains(img.RepoTags, ref) {
231230
t.Logf("image %q found locally, not pulling", ref)
232-
found = true
233-
break
231+
return
234232
}
235233
}
236-
if !found {
237-
t.Logf("image %s not found locally, attempting to pull", ref)
238-
resp, err := cli.ImagePull(ctx, ref, image.PullOptions{})
239-
require.NoError(t, err)
240-
_, err = io.ReadAll(resp)
241-
require.NoError(t, err)
242-
}
234+
t.Logf("image %s not found locally, attempting to pull", ref)
235+
resp, err := cli.ImagePull(ctx, ref, image.PullOptions{})
236+
require.NoError(t, err)
237+
_, err = io.ReadAll(resp)
238+
require.NoError(t, err)
243239
}
244240

245241
// execContainer executes the given command in the given container and returns

0 commit comments

Comments
 (0)