summaryrefslogtreecommitdiff
path: root/api/server
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2022-03-02 16:03:38 +0100
committerSebastiaan van Stijn <github@gone.nl>2022-03-18 09:44:55 +0100
commit64e50ce86a0a764166f9cd160c00a9972b7c8971 (patch)
treeec75fd69184ccc9dc60ec6881abb49231d675538 /api/server
parentbdb878ab2c9f033a416d11f712b411ee4d904f01 (diff)
downloaddocker-64e50ce86a0a764166f9cd160c00a9972b7c8971.tar.gz
search: remove parsing JSON filters out of the backend
All other endpoints handle this in the API; given that the JSON format for filters is part of the API, it makes sense to handle it there, and not have that concept leak into further down the code. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'api/server')
-rw-r--r--api/server/router/image/backend.go2
-rw-r--r--api/server/router/image/image_routes.go7
2 files changed, 7 insertions, 2 deletions
diff --git a/api/server/router/image/backend.go b/api/server/router/image/backend.go
index d54d2c0e6c..c67093950d 100644
--- a/api/server/router/image/backend.go
+++ b/api/server/router/image/backend.go
@@ -37,5 +37,5 @@ type importExportBackend interface {
type registryBackend interface {
PullImage(ctx context.Context, image, tag string, platform *specs.Platform, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error
PushImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error
- SearchRegistryForImages(ctx context.Context, filtersArgs string, term string, limit int, authConfig *types.AuthConfig, metaHeaders map[string][]string) (*registry.SearchResults, error)
+ SearchRegistryForImages(ctx context.Context, searchFilters filters.Args, term string, limit int, authConfig *types.AuthConfig, metaHeaders map[string][]string) (*registry.SearchResults, error)
}
diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go
index 09f812dedf..05a7d6bfbb 100644
--- a/api/server/router/image/image_routes.go
+++ b/api/server/router/image/image_routes.go
@@ -298,7 +298,12 @@ func (s *imageRouter) getImagesSearch(ctx context.Context, w http.ResponseWriter
return errdefs.InvalidParameter(errors.Wrap(err, "invalid limit specified"))
}
}
- query, err := s.backend.SearchRegistryForImages(ctx, r.Form.Get("filters"), r.Form.Get("term"), limit, config, headers)
+ searchFilters, err := filters.FromJSON(r.Form.Get("filters"))
+ if err != nil {
+ return err
+ }
+
+ query, err := s.backend.SearchRegistryForImages(ctx, searchFilters, r.Form.Get("term"), limit, config, headers)
if err != nil {
return err
}