Skip to content

bz1373281 allow >2 slashes in docker URI - #594

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
jim-minter:bz1373281
Sep 29, 2016
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
jim-minter:bz1373281

Conversation

@jim-minter

Copy link
Copy Markdown

@bparees ptal

Comment thread pkg/docker/util.go Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

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

Comment thread pkg/docker/util.go Outdated
if strings.ContainsAny(nameParts[0], ":.") || nameParts[0] == "localhost" {
// registry/name, we suppose
ref.Registry = nameParts[0]
ref.Name = "library/" + nameParts[1]

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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"?

Comment thread pkg/docker/util.go Outdated
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
Copy Markdown
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
Copy Markdown
Author

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

Comment thread pkg/build/strategies/layered/layered.go Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

bparees commented Sep 29, 2016

Copy link
Copy Markdown
Contributor

squash and lgtm
[test]

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

Copy link
Copy Markdown
Author

Squashed!

@bparees

bparees commented Sep 29, 2016

Copy link
Copy Markdown
Contributor

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for source to image test up to 6f064a8

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for source to image merge up to 6f064a8

@openshift-bot

openshift-bot commented Sep 29, 2016 •

Copy link
Copy Markdown
Contributor

@openshift-bot

Copy link
Copy Markdown
Contributor

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