mirror of
https://github.com/distribution/distribution.git
synced 2025-08-31 14:37:56 +00:00
Update registry to use WithName for creating Named values
The registry uses partial Named values which the named parsers no longer support. To allow the registry service to continue to operate without canonicalization, switch to use WithName. In the future, the registry should start using fully canonical values on the backend and WithName should no longer support creating partial values. Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
@@ -100,7 +100,7 @@ func addTestCatalog(route string, content []byte, link string, m *testutil.Reque
|
||||
func TestBlobDelete(t *testing.T) {
|
||||
dgst, _ := newRandomBlob(1024)
|
||||
var m testutil.RequestResponseMap
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo1")
|
||||
repo, _ := reference.WithName("test.example.com/repo1")
|
||||
m = append(m, testutil.RequestResponseMapping{
|
||||
Request: testutil.Request{
|
||||
Method: "DELETE",
|
||||
@@ -139,7 +139,7 @@ func TestBlobFetch(t *testing.T) {
|
||||
defer c()
|
||||
|
||||
ctx := context.Background()
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo1")
|
||||
repo, _ := reference.WithName("test.example.com/repo1")
|
||||
r, err := NewRepository(ctx, repo, e, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -160,7 +160,7 @@ func TestBlobFetch(t *testing.T) {
|
||||
func TestBlobExistsNoContentLength(t *testing.T) {
|
||||
var m testutil.RequestResponseMap
|
||||
|
||||
repo, _ := reference.ParseNamed("biff")
|
||||
repo, _ := reference.WithName("biff")
|
||||
dgst, content := newRandomBlob(1024)
|
||||
m = append(m, testutil.RequestResponseMapping{
|
||||
Request: testutil.Request{
|
||||
@@ -219,7 +219,7 @@ func TestBlobExists(t *testing.T) {
|
||||
defer c()
|
||||
|
||||
ctx := context.Background()
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo1")
|
||||
repo, _ := reference.WithName("test.example.com/repo1")
|
||||
r, err := NewRepository(ctx, repo, e, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -251,7 +251,7 @@ func TestBlobUploadChunked(t *testing.T) {
|
||||
b1[512:513],
|
||||
b1[513:1024],
|
||||
}
|
||||
repo, _ := reference.ParseNamed("test.example.com/uploadrepo")
|
||||
repo, _ := reference.WithName("test.example.com/uploadrepo")
|
||||
uuids := []string{uuid.Generate().String()}
|
||||
m = append(m, testutil.RequestResponseMapping{
|
||||
Request: testutil.Request{
|
||||
@@ -366,7 +366,7 @@ func TestBlobUploadChunked(t *testing.T) {
|
||||
func TestBlobUploadMonolithic(t *testing.T) {
|
||||
dgst, b1 := newRandomBlob(1024)
|
||||
var m testutil.RequestResponseMap
|
||||
repo, _ := reference.ParseNamed("test.example.com/uploadrepo")
|
||||
repo, _ := reference.WithName("test.example.com/uploadrepo")
|
||||
uploadID := uuid.Generate().String()
|
||||
m = append(m, testutil.RequestResponseMapping{
|
||||
Request: testutil.Request{
|
||||
@@ -474,9 +474,9 @@ func TestBlobUploadMonolithic(t *testing.T) {
|
||||
func TestBlobMount(t *testing.T) {
|
||||
dgst, content := newRandomBlob(1024)
|
||||
var m testutil.RequestResponseMap
|
||||
repo, _ := reference.ParseNamed("test.example.com/uploadrepo")
|
||||
repo, _ := reference.WithName("test.example.com/uploadrepo")
|
||||
|
||||
sourceRepo, _ := reference.ParseNamed("test.example.com/sourcerepo")
|
||||
sourceRepo, _ := reference.WithName("test.example.com/sourcerepo")
|
||||
canonicalRef, _ := reference.WithDigest(sourceRepo, dgst)
|
||||
|
||||
m = append(m, testutil.RequestResponseMapping{
|
||||
@@ -678,7 +678,7 @@ func checkEqualManifest(m1, m2 *schema1.SignedManifest) error {
|
||||
|
||||
func TestV1ManifestFetch(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo")
|
||||
repo, _ := reference.WithName("test.example.com/repo")
|
||||
m1, dgst, _ := newRandomSchemaV1Manifest(repo, "latest", 6)
|
||||
var m testutil.RequestResponseMap
|
||||
_, pl, err := m1.Payload()
|
||||
@@ -755,7 +755,7 @@ func TestV1ManifestFetch(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestManifestFetchWithEtag(t *testing.T) {
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo/by/tag")
|
||||
repo, _ := reference.WithName("test.example.com/repo/by/tag")
|
||||
_, d1, p1 := newRandomSchemaV1Manifest(repo, "latest", 6)
|
||||
var m testutil.RequestResponseMap
|
||||
addTestManifestWithEtag(repo, "latest", p1, &m, d1.String())
|
||||
@@ -785,7 +785,7 @@ func TestManifestFetchWithEtag(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestManifestDelete(t *testing.T) {
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo/delete")
|
||||
repo, _ := reference.WithName("test.example.com/repo/delete")
|
||||
_, dgst1, _ := newRandomSchemaV1Manifest(repo, "latest", 6)
|
||||
_, dgst2, _ := newRandomSchemaV1Manifest(repo, "latest", 6)
|
||||
var m testutil.RequestResponseMap
|
||||
@@ -825,7 +825,7 @@ func TestManifestDelete(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestManifestPut(t *testing.T) {
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo/delete")
|
||||
repo, _ := reference.WithName("test.example.com/repo/delete")
|
||||
m1, dgst, _ := newRandomSchemaV1Manifest(repo, "other", 6)
|
||||
|
||||
_, payload, err := m1.Payload()
|
||||
@@ -890,7 +890,7 @@ func TestManifestPut(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestManifestTags(t *testing.T) {
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo/tags/list")
|
||||
repo, _ := reference.WithName("test.example.com/repo/tags/list")
|
||||
tagsList := []byte(strings.TrimSpace(`
|
||||
{
|
||||
"name": "test.example.com/repo/tags/list",
|
||||
@@ -952,7 +952,7 @@ func TestManifestTags(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestObtainsErrorForMissingTag(t *testing.T) {
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo")
|
||||
repo, _ := reference.WithName("test.example.com/repo")
|
||||
|
||||
var m testutil.RequestResponseMap
|
||||
var errors errcode.Errors
|
||||
@@ -998,7 +998,7 @@ func TestManifestTagsPaginated(t *testing.T) {
|
||||
s := httptest.NewServer(http.NotFoundHandler())
|
||||
defer s.Close()
|
||||
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo/tags/list")
|
||||
repo, _ := reference.WithName("test.example.com/repo/tags/list")
|
||||
tagsList := []string{"tag1", "tag2", "funtag"}
|
||||
var m testutil.RequestResponseMap
|
||||
for i := 0; i < 3; i++ {
|
||||
@@ -1067,7 +1067,7 @@ func TestManifestTagsPaginated(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestManifestUnauthorized(t *testing.T) {
|
||||
repo, _ := reference.ParseNamed("test.example.com/repo")
|
||||
repo, _ := reference.WithName("test.example.com/repo")
|
||||
_, dgst, _ := newRandomSchemaV1Manifest(repo, "latest", 6)
|
||||
var m testutil.RequestResponseMap
|
||||
|
||||
|
Reference in New Issue
Block a user