Browse Source

Merge pull request #45068 from vvoland/deprecate-none

api: Remove <none> in Repo(Tags|Digests) for >= 1.43
Sebastiaan van Stijn 2 years ago
parent
commit
a48f19157a

+ 12 - 3
api/server/router/image/image_routes.go

@@ -338,9 +338,18 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
 	}
 	}
 
 
 	for _, img := range images {
 	for _, img := range images {
-		if len(img.RepoTags) == 0 && len(img.RepoDigests) == 0 {
-			img.RepoTags = append(img.RepoTags, "<none>:<none>")
-			img.RepoDigests = append(img.RepoDigests, "<none>@<none>")
+		if versions.LessThan(version, "1.43") {
+			if len(img.RepoTags) == 0 && len(img.RepoDigests) == 0 {
+				img.RepoTags = append(img.RepoTags, "<none>:<none>")
+				img.RepoDigests = append(img.RepoDigests, "<none>@<none>")
+			}
+		} else {
+			if img.RepoTags == nil {
+				img.RepoTags = []string{}
+			}
+			if img.RepoDigests == nil {
+				img.RepoDigests = []string{}
+			}
 		}
 		}
 	}
 	}
 
 

+ 1 - 1
daemon/images/image_prune.go

@@ -109,7 +109,7 @@ deleteImagesLoop:
 					}
 					}
 				}
 				}
 
 
-				// Only delete if it's untagged (i.e. repo:<none>)
+				// Only delete if it has no references which is a valid NamedTagged.
 				shouldDelete = !hasTag
 				shouldDelete = !hasTag
 			}
 			}
 
 

+ 3 - 0
docs/api/version-history.md

@@ -20,6 +20,9 @@ keywords: "API, Docker, rcli, REST, documentation"
 * `POST /containers/create` now accepts `Annotations` as part of `HostConfig`.
 * `POST /containers/create` now accepts `Annotations` as part of `HostConfig`.
   Can be used to attach arbitrary metadata to the container, which will also be
   Can be used to attach arbitrary metadata to the container, which will also be
   passed to the runtime when the container is started.
   passed to the runtime when the container is started.
+* `GET /images/json` no longer includes hardcoded `<none>:<none>` and
+  `<none>@<none>` in `RepoTags` and`RepoDigests` for untagged images.
+  In such cases, empty arrays will be produced instead.
 
 
 ## v1.42 API changes
 ## v1.42 API changes
 
 

+ 3 - 0
testutil/environment/protect.go

@@ -118,6 +118,9 @@ func getExistingImages(t testing.TB, testEnv *Execution) []string {
 func tagsFromImageSummary(image types.ImageSummary) []string {
 func tagsFromImageSummary(image types.ImageSummary) []string {
 	var result []string
 	var result []string
 	for _, tag := range image.RepoTags {
 	for _, tag := range image.RepoTags {
+		// Starting from API 1.43 no longer outputs the hardcoded <none>
+		// strings. But since the tests might be ran against a remote
+		// daemon/pre 1.43 CLI we must still be able to handle it.
 		if tag != "<none>:<none>" {
 		if tag != "<none>:<none>" {
 			result = append(result, tag)
 			result = append(result, tag)
 		}
 		}