Skip to content

bz1373281 allow >2 slashes in docker URI #594

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

Merged
merged 1 commit into from
Sep 29, 2016

Conversation

jim-minter
Copy link
Contributor

@bparees ptal

default:
return ref, fmt.Errorf("the docker pull spec %q must be two or three segments separated by slashes", spec)
// registry(/dir)+/name, we suppose
ref.Registry = nameParts[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we safely make this assumption? should we check it for : and . like above?
(are : or . valid characters in a docker image path segment?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to make the assumption more safe. ":" is not a valid character in a docker image path segment but is used for hostnames and tags. Unfortunately "." is a valid character in a docker image path segment; nevertheless this heuristic is used today in the openshift code and it seemed plausible to copy it.

There is an element of guesswork to this. The previous version of the code made the same assumption here as this version does.

Technically, I still think there's an argument to using "github.com/docker/distribution/reference" as the canonical parser so we match docker behaviour - principle of least surprise

@jim-minter
Copy link
Contributor Author

@bparees I've ended up testing the registry in the 2x'/' case as you suggested above - ptal

if strings.ContainsAny(nameParts[0], ":.") || nameParts[0] == "localhost" {
// registry/name, we suppose
ref.Registry = nameParts[0]
ref.Name = "library/" + nameParts[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the else case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, i see, ref.name will stay as it came out of parseRepoTag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but don't we still need to add "library" in the case where "ref.Name" is something like "mysql"?

if strings.ContainsAny(nameParts[0], ":.") || nameParts[0] == "localhost" {
// registry(/dir)+/name, we suppose
ref.Registry = nameParts[0]
ref.Name = strings.Join(nameParts[1:], "/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a 1 segment name that's just a registry can't be valid, can it?

@jim-minter
Copy link
Contributor Author

@bparees ok, here's a different attempt, which is actually to remove the ParseImageReference function entirely and use the docker registry functions...

newBuilderImage = fmt.Sprintf("%s%s/", newBuilderImage, dockerImageReference.Namespace)
}
newBuilderImage = fmt.Sprintf("%s%s:s2i-layered-%d", newBuilderImage, dockerImageReference.Name, time.Now().UnixNano())
newBuilderImage = fmt.Sprintf("%s-%d", builder.config.BuilderImage, time.Now().UnixNano())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you see a reason not to include "s2i-layered" in the name here like we do in the other path?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a good reason not to just use namedReference.Name() as the base of the new image name in all cases, regardless of whether it's a "digest" or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so - updated.

@bparees
Copy link
Contributor

bparees commented Sep 29, 2016

squash and lgtm
[test]

…function and use %s:s2i-layered-%d for layered images
@jim-minter
Copy link
Contributor Author

Squashed!

@bparees
Copy link
Contributor

bparees commented Sep 29, 2016

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for source to image test up to 6f064a8

@openshift-bot
Copy link
Contributor

Evaluated for source to image merge up to 6f064a8

@openshift-bot
Copy link
Contributor

openshift-bot commented Sep 29, 2016

Source To Image Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_sti/238/)

@openshift-bot
Copy link
Contributor

Source To Image Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_sti/237/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants