Skip to content

Commit 8abafe4

Browse files
authored
Merge pull request #29228 from ashley-cui/is-automated
Docker compat v1.45 : deprecate is-automated field
2 parents 1f8970d + 59af9c8 commit 8abafe4

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

pkg/api/handlers/compat/images_search.go

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"go.podman.io/image/v5/types"
1111
"go.podman.io/podman/v6/libpod"
1212
"go.podman.io/podman/v6/pkg/api/handlers/utils"
13+
"go.podman.io/podman/v6/pkg/api/handlers/utils/apiutil"
1314
api "go.podman.io/podman/v6/pkg/api/types"
1415
"go.podman.io/podman/v6/pkg/auth"
1516
"go.podman.io/podman/v6/pkg/domain/entities"
@@ -49,6 +50,22 @@ func SearchImages(w http.ResponseWriter, r *http.Request) {
4950
password = authconf.Password
5051
idToken = authconf.IdentityToken
5152
}
53+
// compat v1.45 deprecation: searching for is-automated=true will yield no results, while is-automated=false will be a no-op.
54+
isAutomatedDeprecated := false
55+
if _, err := apiutil.SupportedVersion(r, ">=1.45.0"); err == nil {
56+
if !utils.IsLibpodRequest(r) {
57+
isAutomatedDeprecated = true
58+
if vals, ok := query.Filters["is-automated"]; ok {
59+
switch vals[0] {
60+
case "true":
61+
utils.WriteResponse(w, http.StatusOK, []registry.SearchResult{})
62+
return
63+
case "false":
64+
delete(query.Filters, "is-automated")
65+
}
66+
}
67+
}
68+
}
5269

5370
filters := []string{}
5471
for key, val := range query.Filters {
@@ -79,14 +96,19 @@ func SearchImages(w http.ResponseWriter, r *http.Request) {
7996
return
8097
}
8198
compatResults := make([]registry.SearchResult, len(reports))
82-
for i, r := range reports {
83-
compatResults[i] = registry.SearchResult{
84-
Name: r.Name,
85-
Description: r.Description,
86-
StarCount: r.Stars,
87-
IsOfficial: toBool(r.Official),
88-
IsAutomated: toBool(r.Automated),
99+
for i, report := range reports {
100+
result := registry.SearchResult{
101+
Name: report.Name,
102+
Description: report.Description,
103+
StarCount: report.Stars,
104+
IsOfficial: toBool(report.Official),
105+
IsAutomated: toBool(report.Automated),
106+
}
107+
if isAutomatedDeprecated {
108+
//nolint:staticcheck
109+
result.IsAutomated = false
89110
}
111+
compatResults[i] = result
90112
}
91113
utils.WriteResponse(w, http.StatusOK, compatResults)
92114
return

0 commit comments

Comments
 (0)