From 4bc3522500d5c3f22e00e7c97f6e844c2bd5bb21 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 14 Apr 2014 23:15:38 +0000 Subject: [PATCH] allow dot in repo name Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) --- docs/registry.go | 9 ++------- docs/registry_test.go | 7 +++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/registry.go b/docs/registry.go index 817c08afa..451f30f67 100644 --- a/docs/registry.go +++ b/docs/registry.go @@ -101,17 +101,12 @@ func ResolveRepositoryName(reposName string) (string, string, error) { return "", "", ErrInvalidRepositoryName } nameParts := strings.SplitN(reposName, "/", 2) - if !strings.Contains(nameParts[0], ".") && !strings.Contains(nameParts[0], ":") && - nameParts[0] != "localhost" { + if len(nameParts) == 1 || (!strings.Contains(nameParts[0], ".") && !strings.Contains(nameParts[0], ":") && + nameParts[0] != "localhost") { // This is a Docker Index repos (ex: samalba/hipache or ubuntu) err := validateRepositoryName(reposName) 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] reposName = nameParts[1] if strings.Contains(hostname, "index.docker.io") { diff --git a/docs/registry_test.go b/docs/registry_test.go index c072da41c..cb56502fc 100644 --- a/docs/registry_test.go +++ b/docs/registry_test.go @@ -146,6 +146,13 @@ func TestResolveRepositoryName(t *testing.T) { } assertEqual(t, ep, u, "Expected endpoint to be "+u) 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) {