From d88884c51c6427708617ce46cefc500ee29d943b Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Mon, 5 Jan 2015 16:44:03 -0800 Subject: [PATCH] Move names regular expressions to api/v2 packages Because the repository name definitions are part of the v2 specification, they have been moved out of the common package. This is part of the effort to break up the common package into more sensible components. Signed-off-by: Stephen J Day --- api/v2/descriptors.go | 15 +++++++-------- {common => api/v2}/names.go | 2 +- {common => api/v2}/names_test.go | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) rename {common => api/v2}/names.go (99%) rename {common => api/v2}/names_test.go (99%) diff --git a/api/v2/descriptors.go b/api/v2/descriptors.go index dfbbc6f9..e97dd37c 100644 --- a/api/v2/descriptors.go +++ b/api/v2/descriptors.go @@ -4,7 +4,6 @@ import ( "net/http" "regexp" - "github.com/docker/distribution/common" "github.com/docker/distribution/digest" ) @@ -12,7 +11,7 @@ var ( nameParameterDescriptor = ParameterDescriptor{ Name: "name", Type: "string", - Format: common.RepositoryNameRegexp.String(), + Format: RepositoryNameRegexp.String(), Required: true, Description: `Name of the target repository.`, } @@ -20,7 +19,7 @@ var ( tagParameterDescriptor = ParameterDescriptor{ Name: "tag", Type: "string", - Format: common.TagNameRegexp.String(), + Format: TagNameRegexp.String(), Required: true, Description: `Tag of the target manifiest.`, } @@ -307,7 +306,7 @@ var routeDescriptors = []RouteDescriptor{ }, { Name: RouteNameTags, - Path: "/v2/{name:" + common.RepositoryNameRegexp.String() + "}/tags/list", + Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/tags/list", Entity: "Tags", Description: "Retrieve information about tags.", Methods: []MethodDescriptor{ @@ -352,7 +351,7 @@ var routeDescriptors = []RouteDescriptor{ }, { Name: RouteNameManifest, - Path: "/v2/{name:" + common.RepositoryNameRegexp.String() + "}/manifests/{tag:" + common.TagNameRegexp.String() + "}", + Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/manifests/{tag:" + TagNameRegexp.String() + "}", Entity: "Manifest", Description: "Create, update and retrieve manifests.", Methods: []MethodDescriptor{ @@ -514,7 +513,7 @@ var routeDescriptors = []RouteDescriptor{ { Name: RouteNameBlob, - Path: "/v2/{name:" + common.RepositoryNameRegexp.String() + "}/blobs/{digest:" + digest.DigestRegexp.String() + "}", + Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/blobs/{digest:" + digest.DigestRegexp.String() + "}", Entity: "Blob", Description: "Fetch the blob identified by `name` and `digest`. Used to fetch layers by tarsum digest.", Methods: []MethodDescriptor{ @@ -592,7 +591,7 @@ var routeDescriptors = []RouteDescriptor{ { Name: RouteNameBlobUpload, - Path: "/v2/{name:" + common.RepositoryNameRegexp.String() + "}/blobs/uploads/", + Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/blobs/uploads/", Entity: "Intiate Blob Upload", Description: "Initiate a blob upload. This endpoint can be used to create resumable uploads or monolithic uploads.", Methods: []MethodDescriptor{ @@ -700,7 +699,7 @@ var routeDescriptors = []RouteDescriptor{ { Name: RouteNameBlobUploadChunk, - Path: "/v2/{name:" + common.RepositoryNameRegexp.String() + "}/blobs/uploads/{uuid}", + Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/blobs/uploads/{uuid}", Entity: "Blob Upload", Description: "Interact with blob uploads. Clients should never assemble URLs for this endpoint and should only take it through the `Location` header on related API requests.", Methods: []MethodDescriptor{ diff --git a/common/names.go b/api/v2/names.go similarity index 99% rename from common/names.go rename to api/v2/names.go index 0172c480..e0c05d48 100644 --- a/common/names.go +++ b/api/v2/names.go @@ -1,4 +1,4 @@ -package common +package v2 import ( "fmt" diff --git a/common/names_test.go b/api/v2/names_test.go similarity index 99% rename from common/names_test.go rename to api/v2/names_test.go index e88257bd..038386e4 100644 --- a/common/names_test.go +++ b/api/v2/names_test.go @@ -1,4 +1,4 @@ -package common +package v2 import ( "testing"