summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Gronowski <pawel.gronowski@docker.com>2023-02-23 15:40:26 +0100
committerPaweł Gronowski <pawel.gronowski@docker.com>2023-02-27 19:44:43 +0100
commit248745004a81dcb32458c8b1b83333f2e1683edc (patch)
tree9d5afb4ca7d418233355bca67cedec9cfbddfb18
parent0021339b9299c5f1596bdf772a42ce346f16f060 (diff)
downloaddocker-248745004a81dcb32458c8b1b83333f2e1683edc.tar.gz
api: Remove <none> in Repo(Tags|Digests) for >= 1.43
Deprecate `<none>:<none>` and `<none>@<none>` magic strings included in `RepoTags` and `RepoDigests`. Produce an empty arrays instead and leave the presentation of untagged/dangling images up to the client. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
-rw-r--r--api/server/router/image/image_routes.go15
-rw-r--r--daemon/images/image_prune.go2
-rw-r--r--docs/api/version-history.md3
-rw-r--r--testutil/environment/protect.go3
4 files changed, 19 insertions, 4 deletions
diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go
index 3a4322371b..5e0cbac315 100644
--- a/api/server/router/image/image_routes.go
+++ b/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 {
- 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{}
+ }
}
}
diff --git a/daemon/images/image_prune.go b/daemon/images/image_prune.go
index 6c461231eb..4aefd201e6 100644
--- a/daemon/images/image_prune.go
+++ b/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
}
diff --git a/docs/api/version-history.md b/docs/api/version-history.md
index 6eeaee8e67..70553c27c1 100644
--- a/docs/api/version-history.md
+++ b/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`.
Can be used to attach arbitrary metadata to the container, which will also be
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
diff --git a/testutil/environment/protect.go b/testutil/environment/protect.go
index 8ef75a1848..58adc2fdd0 100644
--- a/testutil/environment/protect.go
+++ b/testutil/environment/protect.go
@@ -118,6 +118,9 @@ func getExistingImages(t testing.TB, testEnv *Execution) []string {
func tagsFromImageSummary(image types.ImageSummary) []string {
var result []string
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>" {
result = append(result, tag)
}