-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the docker image parser to account for private repos #24926
base: main
Are you sure you want to change the base?
Conversation
3c77d14
to
8475880
Compare
8475880
to
199dfdc
Compare
drivers/docker/utils.go
Outdated
@@ -21,31 +21,41 @@ import ( | |||
"github.com/docker/docker/registry" | |||
) | |||
|
|||
var regexForDockerImages = `^(?:(?P<registry>[^/]+)/)?(?P<repository>[^:@]+)(?::(?P<tag>[^@]+))?(?:@(?P<digest>sha256:[a-fA-F0-9]{64}))?$` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have https://pkg.go.dev/github.com/distribution/reference as a dependency. Maybe we should use that official upstream instead of our own regex (as awesome as this regex is 😁 )? We can probably even ditch the test in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
…ocker package instead
c891c94
to
be91f55
Compare
tag = "latest" | ||
matches := reference.ReferenceRegexp.FindStringSubmatch(image) | ||
if matches == nil { | ||
return "", "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller doesn't expect an empty string value and is going to do some weird stuff in this case like incrementing the image reference count for empty string. (The original version of this function would return something even if it wasn't all that useful.) We should probably adjust the signature of this function to return an error and have the caller handle that properly.
Description
This PR addresses this issue.
There was a little bug in the
parseDockerImage
where we were using/
the determine the tag and if none was found, it would add latest, completely ignoring the cases where there is a sha present.This PR refactors the logic to avoid adding the
latest
tag if a sha is provided.The extra change corresponds to moving the tests to the
utils_test.go
for clarity.Testing & Reproduction steps
Links
Contributor Checklist
changelog entry using the
make cl
command.ensure regressions will be caught.
and job configuration, please update the Nomad website documentation to reflect this. Refer to
the website README for docs guidelines. Please also consider whether the
change requires notes within the upgrade guide.
Reviewer Checklist
backporting document.
in the majority of situations. The main exceptions are long-lived feature branches or merges where
history should be preserved.
within the public repository.