Move registry.SearchResult types to api/types/registry.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2015-12-15 11:44:20 -05:00
parent 239cb0f4e9
commit 0a56a1cbd2
4 changed files with 6 additions and 31 deletions

View file

@ -460,10 +460,10 @@ func handlerAuth(w http.ResponseWriter, r *http.Request) {
} }
func handlerSearch(w http.ResponseWriter, r *http.Request) { func handlerSearch(w http.ResponseWriter, r *http.Request) {
result := &SearchResults{ result := &registrytypes.SearchResults{
Query: "fakequery", Query: "fakequery",
NumResults: 1, NumResults: 1,
Results: []SearchResult{{Name: "fakeimage", StarCount: 42}}, Results: []registrytypes.SearchResult{{Name: "fakeimage", StarCount: 42}},
} }
writeResponse(w, result, 200) writeResponse(w, result, 200)
} }

View file

@ -73,7 +73,7 @@ func splitReposSearchTerm(reposName string) (string, string) {
// Search queries the public registry for images matching the specified // Search queries the public registry for images matching the specified
// search terms, and returns the results. // 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 { if err := validateNoSchema(term); err != nil {
return nil, err return nil, err
} }

View file

@ -21,6 +21,7 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/distribution/reference" "github.com/docker/distribution/reference"
"github.com/docker/docker/api/types" "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/httputils"
"github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
@ -718,7 +719,7 @@ func shouldRedirect(response *http.Response) bool {
} }
// SearchRepositories performs a search against the remote repository // 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) logrus.Debugf("Index server: %s", r.indexEndpoint)
u := r.indexEndpoint.VersionString(1) + "search?q=" + url.QueryEscape(term) 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 { if res.StatusCode != 200 {
return nil, httputils.NewHTTPRequestError(fmt.Sprintf("Unexpected status code %d", res.StatusCode), res) 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) return result, json.NewDecoder(res.Body).Decode(result)
} }

View file

@ -5,32 +5,6 @@ import (
registrytypes "github.com/docker/docker/api/types/registry" 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 // RepositoryData tracks the image list, list of endpoints, and list of tokens
// for a repository // for a repository
type RepositoryData struct { type RepositoryData struct {