Skip to content

Commit f941185

Browse files
committed
validate that the binary extraction was successful via existence check
1 parent 81a60d6 commit f941185

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pkg/test/extensions/provider.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,19 @@ func (provider *ExternalBinaryProvider) ExtractBinaryFromReleaseImage(tag, binar
146146

147147
extractedBinary := filepath.Join(provider.binPath, filepath.Base(binary))
148148

149+
// Verify that the extracted binary exists; "oc extract image" doesn't error when the path doesn't exist,
150+
// so we check that the extraction was successful via its existence
151+
_, err := os.Stat(extractedBinary)
152+
if err != nil {
153+
if os.IsNotExist(err) {
154+
return nil, fmt.Errorf("extracted binary at path %q does not exist. the src path %q doesn't exist in image %q. note the version of origin needs to match the version of the cluster under test",
155+
extractedBinary, binary, image)
156+
}
157+
return nil, fmt.Errorf("failed to stat external binary to check for existence %q: %w", binary, err)
158+
}
159+
149160
// Support gzipped external binaries (handle decompression).
150-
extractedBinary, err := ungzipFile(extractedBinary)
161+
extractedBinary, err = ungzipFile(extractedBinary)
151162
if err != nil {
152163
return nil, fmt.Errorf("failed to decompress external binary %q: %w", binary, err)
153164
}

0 commit comments

Comments
 (0)