Skip to content

Commit 4be780b

Browse files
committed
test: resolve a flaky test of TestLoadStdinFromPipe
Signed-off-by: Hayato Kiwata <dev@haytok.jp>
1 parent b8fae3b commit 4be780b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/imgutil/load/load.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func FromArchive(ctx context.Context, client *containerd.Client, options types.I
8686

8787
var loadedImages []images.Image
8888
pf, done := transferutil.ProgressHandler(ctx, options.Stdout)
89-
defer done()
9089

9190
err = client.Transfer(ctx,
9291
tarchive.NewImageImportStream(options.Stdin, ""),
@@ -96,16 +95,21 @@ func FromArchive(ctx context.Context, client *containerd.Client, options types.I
9695
if img, err := imageService.Get(ctx, p.Name); err == nil {
9796
if !beforeSet[img.Name] {
9897
loadedImages = append(loadedImages, img)
99-
if !options.Quiet {
100-
fmt.Fprintf(options.Stdout, "Loaded image: %s\n", img.Name)
101-
}
10298
}
10399
}
104100
}
105101
pf(p)
106102
}),
107103
)
108104

105+
done()
106+
107+
if !options.Quiet {
108+
for _, img := range loadedImages {
109+
fmt.Fprintf(options.Stdout, "Loaded image: %s\n", img.Name)
110+
}
111+
}
112+
109113
return loadedImages, err
110114
}
111115

0 commit comments

Comments
 (0)