From 99401d7290fee5aff529eedb8974ee0b68db092e Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Wed, 28 Jan 2015 14:44:09 -0800 Subject: [PATCH] Allow single name component repository names Private registries should support having images pushed with only a single name component (e.g. localhost:5000/myapp). The public registry currently requires two name components, but this is already enforced in the registry code. Signed-off-by: Derek McGowan (github: dmcgowan) --- docs/v2/regexp.go | 4 ++-- docs/v2/routes_test.go | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/v2/regexp.go b/docs/v2/regexp.go index b7e95b9f..e1e923b9 100644 --- a/docs/v2/regexp.go +++ b/docs/v2/regexp.go @@ -11,9 +11,9 @@ import "regexp" // separated by one period, dash or underscore. var RepositoryNameComponentRegexp = regexp.MustCompile(`[a-z0-9]+(?:[._-][a-z0-9]+)*`) -// RepositoryNameRegexp builds on RepositoryNameComponentRegexp to allow 2 to +// RepositoryNameRegexp builds on RepositoryNameComponentRegexp to allow 1 to // 5 path components, separated by a forward slash. -var RepositoryNameRegexp = regexp.MustCompile(`(?:` + RepositoryNameComponentRegexp.String() + `/){1,4}` + RepositoryNameComponentRegexp.String()) +var RepositoryNameRegexp = regexp.MustCompile(`(?:` + RepositoryNameComponentRegexp.String() + `/){0,4}` + RepositoryNameComponentRegexp.String()) // TagNameRegexp matches valid tag names. From docker/docker:graph/tags.go. var TagNameRegexp = regexp.MustCompile(`[\w][\w.-]{0,127}`) diff --git a/docs/v2/routes_test.go b/docs/v2/routes_test.go index 9969ebcc..7682792e 100644 --- a/docs/v2/routes_test.go +++ b/docs/v2/routes_test.go @@ -51,6 +51,14 @@ func TestRouter(t *testing.T) { RequestURI: "/v2/", Vars: map[string]string{}, }, + { + RouteName: RouteNameManifest, + RequestURI: "/v2/foo/manifests/bar", + Vars: map[string]string{ + "name": "foo", + "tag": "bar", + }, + }, { RouteName: RouteNameManifest, RequestURI: "/v2/foo/bar/manifests/tag",