Fix bug in parsing domain from repository reference

Signed-off-by: Aviral Takkar <aviral26@users.noreply.github.com>
This commit is contained in:
Aviral Takkar 2019-08-14 15:27:59 -07:00
parent 1fb7fffdb2
commit a19e1847a3
No known key found for this signature in database
GPG key ID: F859083AD7D59233
2 changed files with 17 additions and 1 deletions

View file

@ -90,7 +90,7 @@ func ParseDockerRef(ref string) (Named, error) {
// needs to be already validated before.
func splitDockerDomain(name string) (domain, remainder string) {
i := strings.IndexRune(name, '/')
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") {
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost" && strings.ToLower(name[:i]) == name[:i]) {
domain, remainder = defaultDomain, name
} else {
domain, remainder = name[:i], name[i+1:]

View file

@ -28,6 +28,8 @@ func TestValidateReferenceName(t *testing.T) {
// when specified with a hostname, it removes the ambiguity from about
// whether the value is an identifier or repository name
"docker.io/1a3f5e7d9c1b3a5f7e9d1c3b5a7f9e1d3c5b7a9f1e3d5d7c9b1a3f5e7d9c1b3a",
"Docker/docker",
"DOCKER/docker",
}
invalidRepoNames := []string{
"https://github.com/docker/docker",
@ -229,6 +231,20 @@ func TestParseRepositoryInfo(t *testing.T) {
AmbiguousName: "",
Domain: "docker.io",
},
{
RemoteName: "bar",
FamiliarName: "Foo/bar",
FullName: "Foo/bar",
AmbiguousName: "",
Domain: "Foo",
},
{
RemoteName: "bar",
FamiliarName: "FOO/bar",
FullName: "FOO/bar",
AmbiguousName: "",
Domain: "FOO",
},
}
for _, tcase := range tcases {