forked from TrueCloudLab/distribution
Merge pull request #5202 from vieux/allow_dot_repo
Allow dot in repo name
This commit is contained in:
commit
79de96ec37
2 changed files with 9 additions and 7 deletions
|
@ -101,17 +101,12 @@ func ResolveRepositoryName(reposName string) (string, string, error) {
|
||||||
return "", "", ErrInvalidRepositoryName
|
return "", "", ErrInvalidRepositoryName
|
||||||
}
|
}
|
||||||
nameParts := strings.SplitN(reposName, "/", 2)
|
nameParts := strings.SplitN(reposName, "/", 2)
|
||||||
if !strings.Contains(nameParts[0], ".") && !strings.Contains(nameParts[0], ":") &&
|
if len(nameParts) == 1 || (!strings.Contains(nameParts[0], ".") && !strings.Contains(nameParts[0], ":") &&
|
||||||
nameParts[0] != "localhost" {
|
nameParts[0] != "localhost") {
|
||||||
// This is a Docker Index repos (ex: samalba/hipache or ubuntu)
|
// This is a Docker Index repos (ex: samalba/hipache or ubuntu)
|
||||||
err := validateRepositoryName(reposName)
|
err := validateRepositoryName(reposName)
|
||||||
return IndexServerAddress(), reposName, err
|
return IndexServerAddress(), reposName, err
|
||||||
}
|
}
|
||||||
if len(nameParts) < 2 {
|
|
||||||
// There is a dot in repos name (and no registry address)
|
|
||||||
// Is it a Registry address without repos name?
|
|
||||||
return "", "", ErrInvalidRepositoryName
|
|
||||||
}
|
|
||||||
hostname := nameParts[0]
|
hostname := nameParts[0]
|
||||||
reposName = nameParts[1]
|
reposName = nameParts[1]
|
||||||
if strings.Contains(hostname, "index.docker.io") {
|
if strings.Contains(hostname, "index.docker.io") {
|
||||||
|
|
|
@ -146,6 +146,13 @@ func TestResolveRepositoryName(t *testing.T) {
|
||||||
}
|
}
|
||||||
assertEqual(t, ep, u, "Expected endpoint to be "+u)
|
assertEqual(t, ep, u, "Expected endpoint to be "+u)
|
||||||
assertEqual(t, repo, "private/moonbase", "Expected endpoint to be private/moonbase")
|
assertEqual(t, repo, "private/moonbase", "Expected endpoint to be private/moonbase")
|
||||||
|
|
||||||
|
ep, repo, err = ResolveRepositoryName("ubuntu-12.04-base")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
assertEqual(t, ep, IndexServerAddress(), "Expected endpoint to be "+IndexServerAddress())
|
||||||
|
assertEqual(t, repo, "ubuntu-12.04-base", "Expected endpoint to be ubuntu-12.04-base")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPushRegistryTag(t *testing.T) {
|
func TestPushRegistryTag(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue