Conversation
… to reduce code duplication - fix previous copy-paste errors
majst01
requested changes
Jan 29, 2026
Contributor
|
test would be nice |
This was referenced Feb 19, 2026
vknabel
reviewed
Apr 2, 2026
| if res.StatusCode >= 400 { | ||
| return fmt.Errorf("image:%s is not accessible under:%s status:%s", id, url, res.Status) | ||
| func checkImageURL(id, inputURL string, ociCredentials authn.Authenticator) error { | ||
| parsedURL := strings.Split(inputURL, "://") |
Contributor
There was a problem hiding this comment.
I think we should use url.Parse here.
| return fmt.Errorf("image:%s is not accessible under:%s error:%w", id, inputURL, err) | ||
| } | ||
| default: | ||
| return fmt.Errorf("image:%s with url:%s has unkown protocol", id, inputURL) |
Contributor
There was a problem hiding this comment.
Suggested change
| return fmt.Errorf("image:%s with url:%s has unkown protocol", id, inputURL) | |
| return fmt.Errorf("image: %q with url: %s has unknown protocol", id, inputURL) |
Comment on lines
414
to
445
Contributor
There was a problem hiding this comment.
If I understand this correctly, updateImage is impossible with oci images that require any kind of auth. Is this intended?
|
|
||
| _, err = remote.Image(ref, remote.WithAuth(ociCredentials)) | ||
| if err != nil { | ||
| return fmt.Errorf("image:%s is not accessible under:%s error:%w", id, inputURL, err) |
Contributor
There was a problem hiding this comment.
Suggested change
| return fmt.Errorf("image:%s is not accessible under:%s error:%w", id, inputURL, err) | |
| return fmt.Errorf("image: %q is not accessible under: %s, error: %w", id, inputURL, err) |
| case "oci": | ||
| ref, err := name.ParseReference(parsedURL[1]) | ||
| if err != nil { | ||
| return fmt.Errorf("image reference:%s could not be parsed. error:%w", inputURL, err) |
Contributor
There was a problem hiding this comment.
Suggested change
| return fmt.Errorf("image reference:%s could not be parsed. error:%w", inputURL, err) | |
| return fmt.Errorf("image reference: %q could not be parsed, error: %w", inputURL, err) |
| case "http", "https": | ||
| _, err := url.ParseRequestURI(inputURL) | ||
| if err != nil { | ||
| return fmt.Errorf("image:%s could not be parsed. error:%w", inputURL, err) |
Contributor
There was a problem hiding this comment.
Suggested change
| return fmt.Errorf("image:%s could not be parsed. error:%w", inputURL, err) | |
| return fmt.Errorf("image: %q could not be parsed, error: %w", inputURL, err) |
|
|
||
| res, err := http.Head(inputURL) | ||
| if err != nil { | ||
| return fmt.Errorf("image:%s is not accessible under:%s error:%w", id, inputURL, err) |
Contributor
There was a problem hiding this comment.
Suggested change
| return fmt.Errorf("image:%s is not accessible under:%s error:%w", id, inputURL, err) | |
| return fmt.Errorf("image: %q is not accessible under: %s, error: %w", id, inputURL, err) |
| return fmt.Errorf("image:%s is not accessible under:%s error:%w", id, inputURL, err) | ||
| } | ||
| if res.StatusCode >= 400 { | ||
| return fmt.Errorf("image:%s is not accessible under:%s status:%s", id, inputURL, res.Status) |
Contributor
There was a problem hiding this comment.
Suggested change
| return fmt.Errorf("image:%s is not accessible under:%s status:%s", id, inputURL, res.Status) | |
| return fmt.Errorf("image: %q is not accessible under: %s, status: %s", id, inputURL, res.Status) |
| } | ||
|
|
||
| err = checkImageURL("image", imageURL) | ||
| err = checkImageURL("image", imageURL, nil) |
Contributor
There was a problem hiding this comment.
Same here and within that file: is nil intentional?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
References