summaryrefslogtreecommitdiff
path: root/pkg/bindings/search.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/bindings/search.go')
-rw-r--r--pkg/bindings/search.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/pkg/bindings/search.go b/pkg/bindings/search.go
new file mode 100644
index 000000000..0f462357c
--- /dev/null
+++ b/pkg/bindings/search.go
@@ -0,0 +1,39 @@
+package bindings
+
+import (
+ "net/http"
+ "strconv"
+
+ "github.com/containers/libpod/libpod/image"
+)
+
+type ImageSearchFilters struct {
+ Automated bool `json:"automated"`
+ Official bool `json:"official"`
+ Stars int `json:"stars"`
+}
+
+// TODO This method can be concluded when we determine how we want the filters to work on the
+// API end
+func (i *ImageSearchFilters) ToMapJSON() string {
+ return ""
+}
+
+func (c Connection) SearchImages(term string, limit int, filters *ImageSearchFilters) ([]image.SearchResult, error) {
+ var (
+ searchResults []image.SearchResult
+ )
+ params := make(map[string]string)
+ params["term"] = term
+ if limit > 0 {
+ params["limit"] = strconv.Itoa(limit)
+ }
+ if filters != nil {
+ params["filters"] = filters.ToMapJSON()
+ }
+ response, err := c.newRequest(http.MethodGet, "/images/search", nil, params)
+ if err != nil {
+ return searchResults, nil
+ }
+ return searchResults, response.Process(&searchResults)
+}