From 0a56a1cbd2821f0be8790b5d4a08ccc1b58fec99 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 15 Dec 2015 11:44:20 -0500 Subject: [PATCH] Move registry.SearchResult types to api/types/registry. Signed-off-by: Daniel Nephin --- docs/registry_mock_test.go | 4 ++-- docs/service.go | 2 +- docs/session.go | 5 +++-- docs/types.go | 26 -------------------------- 4 files changed, 6 insertions(+), 31 deletions(-) diff --git a/docs/registry_mock_test.go b/docs/registry_mock_test.go index 89059e8e..f45de5c8 100644 --- a/docs/registry_mock_test.go +++ b/docs/registry_mock_test.go @@ -460,10 +460,10 @@ func handlerAuth(w http.ResponseWriter, r *http.Request) { } func handlerSearch(w http.ResponseWriter, r *http.Request) { - result := &SearchResults{ + result := ®istrytypes.SearchResults{ Query: "fakequery", NumResults: 1, - Results: []SearchResult{{Name: "fakeimage", StarCount: 42}}, + Results: []registrytypes.SearchResult{{Name: "fakeimage", StarCount: 42}}, } writeResponse(w, result, 200) } diff --git a/docs/service.go b/docs/service.go index b04fd00c..b826f117 100644 --- a/docs/service.go +++ b/docs/service.go @@ -73,7 +73,7 @@ func splitReposSearchTerm(reposName string) (string, string) { // Search queries the public registry for images matching the specified // search terms, and returns the results. -func (s *Service) Search(term string, authConfig *types.AuthConfig, headers map[string][]string) (*SearchResults, error) { +func (s *Service) Search(term string, authConfig *types.AuthConfig, headers map[string][]string) (*registrytypes.SearchResults, error) { if err := validateNoSchema(term); err != nil { return nil, err } diff --git a/docs/session.go b/docs/session.go index 4be9b7af..d09babd4 100644 --- a/docs/session.go +++ b/docs/session.go @@ -21,6 +21,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" + registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/stringid" @@ -718,7 +719,7 @@ func shouldRedirect(response *http.Response) bool { } // SearchRepositories performs a search against the remote repository -func (r *Session) SearchRepositories(term string) (*SearchResults, error) { +func (r *Session) SearchRepositories(term string) (*registrytypes.SearchResults, error) { logrus.Debugf("Index server: %s", r.indexEndpoint) u := r.indexEndpoint.VersionString(1) + "search?q=" + url.QueryEscape(term) @@ -736,7 +737,7 @@ func (r *Session) SearchRepositories(term string) (*SearchResults, error) { if res.StatusCode != 200 { return nil, httputils.NewHTTPRequestError(fmt.Sprintf("Unexpected status code %d", res.StatusCode), res) } - result := new(SearchResults) + result := new(registrytypes.SearchResults) return result, json.NewDecoder(res.Body).Decode(result) } diff --git a/docs/types.go b/docs/types.go index 5068e00b..03657820 100644 --- a/docs/types.go +++ b/docs/types.go @@ -5,32 +5,6 @@ import ( registrytypes "github.com/docker/docker/api/types/registry" ) -// SearchResult describes a search result returned from a registry -type SearchResult struct { - // StarCount indicates the number of stars this repository has - StarCount int `json:"star_count"` - // IsOfficial indicates whether the result is an official repository or not - IsOfficial bool `json:"is_official"` - // Name is the name of the repository - Name string `json:"name"` - // IsOfficial indicates whether the result is trusted - IsTrusted bool `json:"is_trusted"` - // IsAutomated indicates whether the result is automated - IsAutomated bool `json:"is_automated"` - // Description is a textual description of the repository - Description string `json:"description"` -} - -// SearchResults lists a collection search results returned from a registry -type SearchResults struct { - // Query contains the query string that generated the search results - Query string `json:"query"` - // NumResults indicates the number of results the query returned - NumResults int `json:"num_results"` - // Results is a slice containing the actual results for the search - Results []SearchResult `json:"results"` -} - // RepositoryData tracks the image list, list of endpoints, and list of tokens // for a repository type RepositoryData struct {