From afd61ce8f2341785448155a9607ca3b58b9761c5 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Fri, 30 Oct 2015 17:46:25 -0700 Subject: [PATCH] Vendor updated version of docker/distribution This updates the vendored docker/distribution to the current master branch. Note the following changes: - The manifest package was split into manifest/schema1. Most references to the manifest package in the engine needed to be updated to use schema1 instead. - Validation functions in api/v2 were replaced by the distribution/reference package. The engine code has been updated to use the reference package for validation where necessary. A future PR will change the engine to use the types defined in distribution/reference more comprehensively. - The reference package explicitly allows double _ characters in repository names. registry_test.go was updated for this. - TestPullFailsWithAlteredManifest was corrupting the manifest JSON, now that the schema1 package unmarshals the correct payload. The test is being changed to modify the JSON without affecting its length, which allows the pull to succeed to the point where digest validation happens. Signed-off-by: Aaron Lehmann --- docs/config.go | 5 +++-- docs/registry.go | 2 +- docs/registry_test.go | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/config.go b/docs/config.go index b49bd910..e8f2287e 100644 --- a/docs/config.go +++ b/docs/config.go @@ -8,7 +8,7 @@ import ( "net/url" "strings" - "github.com/docker/distribution/registry/api/v2" + "github.com/docker/distribution/reference" "github.com/docker/docker/image" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" @@ -226,7 +226,8 @@ func validateRemoteName(remoteName string) error { } } - return v2.ValidateRepositoryName(remoteName) + _, err := reference.WithName(remoteName) + return err } func validateNoSchema(reposName string) error { diff --git a/docs/registry.go b/docs/registry.go index 389bd959..02f18921 100644 --- a/docs/registry.go +++ b/docs/registry.go @@ -190,7 +190,7 @@ func addRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Reque func shouldV2Fallback(err errcode.Error) bool { logrus.Debugf("v2 error: %T %v", err, err) switch err.Code { - case v2.ErrorCodeUnauthorized, v2.ErrorCodeManifestUnknown: + case errcode.ErrorCodeUnauthorized, v2.ErrorCodeManifestUnknown: return true } return false diff --git a/docs/registry_test.go b/docs/registry_test.go index 5b36210a..7714310d 100644 --- a/docs/registry_test.go +++ b/docs/registry_test.go @@ -776,6 +776,9 @@ func TestValidRemoteName(t *testing.T) { // single character names are now allowed. "d/docker", "jess/t", + + // Consecutive underscores. + "dock__er/docker", } for _, repositoryName := range validRepositoryNames { if err := validateRemoteName(repositoryName); err != nil { @@ -803,8 +806,7 @@ func TestValidRemoteName(t *testing.T) { "_docker/_docker", - // Disallow consecutive underscores and periods. - "dock__er/docker", + // Disallow consecutive periods. "dock..er/docker", "dock_.er/docker", "dock-.er/docker",