Use correct path for manifest revision path
Unfortunately, the refactor used the incorrect path for manifest links within a repository. While this didn't stop the registry from working, it did break compatibility with 2.0 deployments for manifest fetches. Tests were added to ensure these are locked down to the appropriate paths. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
ed3ecfdccb
commit
5dd78c821a
2 changed files with 39 additions and 1 deletions
|
@ -11,6 +11,10 @@ import (
|
||||||
"github.com/docker/distribution/uuid"
|
"github.com/docker/distribution/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// linkPathFunc describes a function that can resolve a link based on the
|
||||||
|
// repository name and digest.
|
||||||
|
type linkPathFunc func(pm *pathMapper, name string, dgst digest.Digest) (string, error)
|
||||||
|
|
||||||
// linkedBlobStore provides a full BlobService that namespaces the blobs to a
|
// linkedBlobStore provides a full BlobService that namespaces the blobs to a
|
||||||
// given repository. Effectively, it manages the links in a given repository
|
// given repository. Effectively, it manages the links in a given repository
|
||||||
// that grant access to the global blob store.
|
// that grant access to the global blob store.
|
||||||
|
@ -297,5 +301,5 @@ func blobLinkPath(pm *pathMapper, name string, dgst digest.Digest) (string, erro
|
||||||
|
|
||||||
// manifestRevisionLinkPath provides the path to the manifest revision link.
|
// manifestRevisionLinkPath provides the path to the manifest revision link.
|
||||||
func manifestRevisionLinkPath(pm *pathMapper, name string, dgst digest.Digest) (string, error) {
|
func manifestRevisionLinkPath(pm *pathMapper, name string, dgst digest.Digest) (string, error) {
|
||||||
return pm.path(layerLinkPathSpec{name: name, digest: dgst})
|
return pm.path(manifestRevisionLinkPathSpec{name: name, revision: dgst})
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,3 +362,37 @@ func TestManifestStorage(t *testing.T) {
|
||||||
t.Errorf("Unexpected success deleting while disabled")
|
t.Errorf("Unexpected success deleting while disabled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestLinkPathFuncs ensures that the link path functions behavior are locked
|
||||||
|
// down and implemented as expected.
|
||||||
|
func TestLinkPathFuncs(t *testing.T) {
|
||||||
|
for _, testcase := range []struct {
|
||||||
|
repo string
|
||||||
|
digest digest.Digest
|
||||||
|
linkPathFn linkPathFunc
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
repo: "foo/bar",
|
||||||
|
digest: "sha256:deadbeaf",
|
||||||
|
linkPathFn: blobLinkPath,
|
||||||
|
expected: "/docker/registry/v2/repositories/foo/bar/_layers/sha256/deadbeaf/link",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: "foo/bar",
|
||||||
|
digest: "sha256:deadbeaf",
|
||||||
|
linkPathFn: manifestRevisionLinkPath,
|
||||||
|
expected: "/docker/registry/v2/repositories/foo/bar/_manifests/revisions/sha256/deadbeaf/link",
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
p, err := testcase.linkPathFn(defaultPathMapper, testcase.repo, testcase.digest)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error calling linkPathFn(pm, %q, %q): %v", testcase.repo, testcase.digest, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if p != testcase.expected {
|
||||||
|
t.Fatalf("incorrect path returned: %q != %q", p, testcase.expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue