Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Return both failures when failed to retrive an image with a scheme #1801

Merged
merged 1 commit into from
May 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions syft/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,27 @@ func getImageWithRetryStrategy(in Input, registryOptions *image.RegistryOptions)
// We need to determine the image source again, such that this determination
// doesn't take scheme parsing into account.
in.ImageSource = image.DetermineDefaultImagePullSource(in.UserInput)
img, err = stereoscope.GetImageFromSource(ctx, in.UserInput, in.ImageSource, opts...)
img, userInputErr := stereoscope.GetImageFromSource(ctx, in.UserInput, in.ImageSource, opts...)
cleanup = func() {
if err := img.Cleanup(); err != nil {
log.Warnf("unable to cleanup image=%q: %w", in.UserInput, err)
}
}
return img, cleanup, err
if userInputErr != nil {
// Image retrieval failed on both tries, we will want to return both errors.
return nil, nil, fmt.Errorf(
"scheme %q specified; "+
"image retrieval using scheme parsing (%s) was unsuccessful: %v; "+
"image retrieval without scheme parsing (%s) was unsuccessful: %v",
scheme,
in.Location,
err,
in.UserInput,
userInputErr,
)
}

return img, cleanup, nil
}

func generateDirectorySource(fs afero.Fs, in Input) (*Source, func(), error) {
Expand Down