Browse code

Set canonical name correctly

Currently canonical name gets set to the local name and displayed in the errors.
Canonical name should be the unique and canonical name for an image.
Use docker.io as the canonical domain for images on the public registry.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)

Derek McGowan authored on 2015/07/15 09:45:49
Showing 3 changed files
... ...
@@ -352,9 +352,9 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo *
352 352
 		}
353 353
 	}
354 354
 
355
-	requestedTag := repoInfo.CanonicalName
355
+	requestedTag := repoInfo.LocalName
356 356
 	if len(askedTag) > 0 {
357
-		requestedTag = utils.ImageReference(repoInfo.CanonicalName, askedTag)
357
+		requestedTag = utils.ImageReference(repoInfo.LocalName, askedTag)
358 358
 	}
359 359
 	WriteStatus(requestedTag, out, sf, layersDownloaded)
360 360
 	return nil
... ...
@@ -508,9 +508,9 @@ func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo
508 508
 		}
509 509
 	}
510 510
 
511
-	requestedTag := repoInfo.CanonicalName
511
+	requestedTag := repoInfo.LocalName
512 512
 	if len(tag) > 0 {
513
-		requestedTag = utils.ImageReference(repoInfo.CanonicalName, tag)
513
+		requestedTag = utils.ImageReference(repoInfo.LocalName, tag)
514 514
 	}
515 515
 	WriteStatus(requestedTag, out, sf, layersDownloaded)
516 516
 	return nil
... ...
@@ -324,10 +324,8 @@ func (config *ServiceConfig) NewRepositoryInfo(reposName string) (*RepositoryInf
324 324
 			repoInfo.RemoteName = "library/" + normalizedName
325 325
 		}
326 326
 
327
-		// *TODO: Prefix this with 'docker.io/'.
328
-		repoInfo.CanonicalName = repoInfo.LocalName
327
+		repoInfo.CanonicalName = "docker.io/" + repoInfo.RemoteName
329 328
 	} else {
330
-		// *TODO: Decouple index name from hostname (via registry configuration?)
331 329
 		repoInfo.LocalName = repoInfo.Index.Name + "/" + repoInfo.RemoteName
332 330
 		repoInfo.CanonicalName = repoInfo.LocalName
333 331
 
... ...
@@ -337,7 +337,7 @@ func TestParseRepositoryInfo(t *testing.T) {
337 337
 			},
338 338
 			RemoteName:    "fooo/bar",
339 339
 			LocalName:     "fooo/bar",
340
-			CanonicalName: "fooo/bar",
340
+			CanonicalName: "docker.io/fooo/bar",
341 341
 			Official:      false,
342 342
 		},
343 343
 		"library/ubuntu": {
... ...
@@ -347,7 +347,7 @@ func TestParseRepositoryInfo(t *testing.T) {
347 347
 			},
348 348
 			RemoteName:    "library/ubuntu",
349 349
 			LocalName:     "ubuntu",
350
-			CanonicalName: "ubuntu",
350
+			CanonicalName: "docker.io/library/ubuntu",
351 351
 			Official:      true,
352 352
 		},
353 353
 		"nonlibrary/ubuntu": {
... ...
@@ -357,7 +357,7 @@ func TestParseRepositoryInfo(t *testing.T) {
357 357
 			},
358 358
 			RemoteName:    "nonlibrary/ubuntu",
359 359
 			LocalName:     "nonlibrary/ubuntu",
360
-			CanonicalName: "nonlibrary/ubuntu",
360
+			CanonicalName: "docker.io/nonlibrary/ubuntu",
361 361
 			Official:      false,
362 362
 		},
363 363
 		"ubuntu": {
... ...
@@ -367,7 +367,7 @@ func TestParseRepositoryInfo(t *testing.T) {
367 367
 			},
368 368
 			RemoteName:    "library/ubuntu",
369 369
 			LocalName:     "ubuntu",
370
-			CanonicalName: "ubuntu",
370
+			CanonicalName: "docker.io/library/ubuntu",
371 371
 			Official:      true,
372 372
 		},
373 373
 		"other/library": {
... ...
@@ -377,7 +377,7 @@ func TestParseRepositoryInfo(t *testing.T) {
377 377
 			},
378 378
 			RemoteName:    "other/library",
379 379
 			LocalName:     "other/library",
380
-			CanonicalName: "other/library",
380
+			CanonicalName: "docker.io/other/library",
381 381
 			Official:      false,
382 382
 		},
383 383
 		"127.0.0.1:8000/private/moonbase": {
... ...
@@ -487,7 +487,7 @@ func TestParseRepositoryInfo(t *testing.T) {
487 487
 			},
488 488
 			RemoteName:    "public/moonbase",
489 489
 			LocalName:     "public/moonbase",
490
-			CanonicalName: "public/moonbase",
490
+			CanonicalName: "docker.io/public/moonbase",
491 491
 			Official:      false,
492 492
 		},
493 493
 		"index." + IndexServerName() + "/public/moonbase": {
... ...
@@ -497,7 +497,7 @@ func TestParseRepositoryInfo(t *testing.T) {
497 497
 			},
498 498
 			RemoteName:    "public/moonbase",
499 499
 			LocalName:     "public/moonbase",
500
-			CanonicalName: "public/moonbase",
500
+			CanonicalName: "docker.io/public/moonbase",
501 501
 			Official:      false,
502 502
 		},
503 503
 		IndexServerName() + "/public/moonbase": {
... ...
@@ -507,7 +507,7 @@ func TestParseRepositoryInfo(t *testing.T) {
507 507
 			},
508 508
 			RemoteName:    "public/moonbase",
509 509
 			LocalName:     "public/moonbase",
510
-			CanonicalName: "public/moonbase",
510
+			CanonicalName: "docker.io/public/moonbase",
511 511
 			Official:      false,
512 512
 		},
513 513
 		"ubuntu-12.04-base": {
... ...
@@ -517,7 +517,7 @@ func TestParseRepositoryInfo(t *testing.T) {
517 517
 			},
518 518
 			RemoteName:    "library/ubuntu-12.04-base",
519 519
 			LocalName:     "ubuntu-12.04-base",
520
-			CanonicalName: "ubuntu-12.04-base",
520
+			CanonicalName: "docker.io/library/ubuntu-12.04-base",
521 521
 			Official:      true,
522 522
 		},
523 523
 		IndexServerName() + "/ubuntu-12.04-base": {
... ...
@@ -527,7 +527,7 @@ func TestParseRepositoryInfo(t *testing.T) {
527 527
 			},
528 528
 			RemoteName:    "library/ubuntu-12.04-base",
529 529
 			LocalName:     "ubuntu-12.04-base",
530
-			CanonicalName: "ubuntu-12.04-base",
530
+			CanonicalName: "docker.io/library/ubuntu-12.04-base",
531 531
 			Official:      true,
532 532
 		},
533 533
 		IndexServerName() + "/ubuntu-12.04-base": {
... ...
@@ -537,7 +537,7 @@ func TestParseRepositoryInfo(t *testing.T) {
537 537
 			},
538 538
 			RemoteName:    "library/ubuntu-12.04-base",
539 539
 			LocalName:     "ubuntu-12.04-base",
540
-			CanonicalName: "ubuntu-12.04-base",
540
+			CanonicalName: "docker.io/library/ubuntu-12.04-base",
541 541
 			Official:      true,
542 542
 		},
543 543
 		"index." + IndexServerName() + "/ubuntu-12.04-base": {
... ...
@@ -547,7 +547,7 @@ func TestParseRepositoryInfo(t *testing.T) {
547 547
 			},
548 548
 			RemoteName:    "library/ubuntu-12.04-base",
549 549
 			LocalName:     "ubuntu-12.04-base",
550
-			CanonicalName: "ubuntu-12.04-base",
550
+			CanonicalName: "docker.io/library/ubuntu-12.04-base",
551 551
 			Official:      true,
552 552
 		},
553 553
 	}