Merge pull request #45068 from vvoland/deprecate-none

api: Remove <none> in Repo(Tags|Digests) for >= 1.43
This commit is contained in:
Sebastiaan van Stijn 2023-02-28 23:34:32 +01:00 committed by GitHub
commit a48f19157a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View file

@ -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{}
}
}
}

View file

@ -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
}

View file

@ -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

View file

@ -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)
}