Browse code

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

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2015/12/16 01:44:20
Showing 9 changed files
... ...
@@ -9,8 +9,8 @@ import (
9 9
 
10 10
 	"github.com/docker/docker/api/client/lib"
11 11
 	"github.com/docker/docker/api/types"
12
+	"github.com/docker/docker/api/types/registry"
12 13
 	"github.com/docker/docker/pkg/parsers/filters"
13
-	"github.com/docker/docker/registry"
14 14
 	"github.com/docker/docker/runconfig"
15 15
 )
16 16
 
... ...
@@ -6,7 +6,7 @@ import (
6 6
 	"net/url"
7 7
 
8 8
 	"github.com/docker/docker/api/types"
9
-	"github.com/docker/docker/registry"
9
+	"github.com/docker/docker/api/types/registry"
10 10
 )
11 11
 
12 12
 // ImageSearch makes the docker host to search by a term in a remote registry.
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"text/tabwriter"
9 9
 
10 10
 	"github.com/docker/docker/api/types"
11
+	registrytypes "github.com/docker/docker/api/types/registry"
11 12
 	Cli "github.com/docker/docker/cli"
12 13
 	flag "github.com/docker/docker/pkg/mflag"
13 14
 	"github.com/docker/docker/pkg/stringutils"
... ...
@@ -83,7 +84,7 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
83 83
 }
84 84
 
85 85
 // SearchResultsByStars sorts search results in descending order by number of stars.
86
-type searchResultsByStars []registry.SearchResult
86
+type searchResultsByStars []registrytypes.SearchResult
87 87
 
88 88
 func (r searchResultsByStars) Len() int           { return len(r) }
89 89
 func (r searchResultsByStars) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
... ...
@@ -73,3 +73,29 @@ type IndexInfo struct {
73 73
 	// Official indicates whether this is an official registry
74 74
 	Official bool
75 75
 }
76
+
77
+// SearchResult describes a search result returned from a registry
78
+type SearchResult struct {
79
+	// StarCount indicates the number of stars this repository has
80
+	StarCount int `json:"star_count"`
81
+	// IsOfficial indicates whether the result is an official repository or not
82
+	IsOfficial bool `json:"is_official"`
83
+	// Name is the name of the repository
84
+	Name string `json:"name"`
85
+	// IsOfficial indicates whether the result is trusted
86
+	IsTrusted bool `json:"is_trusted"`
87
+	// IsAutomated indicates whether the result is automated
88
+	IsAutomated bool `json:"is_automated"`
89
+	// Description is a textual description of the repository
90
+	Description string `json:"description"`
91
+}
92
+
93
+// SearchResults lists a collection search results returned from a registry
94
+type SearchResults struct {
95
+	// Query contains the query string that generated the search results
96
+	Query string `json:"query"`
97
+	// NumResults indicates the number of results the query returned
98
+	NumResults int `json:"num_results"`
99
+	// Results is a slice containing the actual results for the search
100
+	Results []SearchResult `json:"results"`
101
+}
... ...
@@ -22,6 +22,7 @@ import (
22 22
 	"github.com/docker/distribution/reference"
23 23
 	"github.com/docker/docker/api"
24 24
 	"github.com/docker/docker/api/types"
25
+	registrytypes "github.com/docker/docker/api/types/registry"
25 26
 	"github.com/docker/docker/container"
26 27
 	"github.com/docker/docker/daemon/events"
27 28
 	"github.com/docker/docker/daemon/exec"
... ...
@@ -1508,7 +1509,7 @@ func (daemon *Daemon) AuthenticateToRegistry(authConfig *types.AuthConfig) (stri
1508 1508
 // term. authConfig is used to login.
1509 1509
 func (daemon *Daemon) SearchRegistryForImages(term string,
1510 1510
 	authConfig *types.AuthConfig,
1511
-	headers map[string][]string) (*registry.SearchResults, error) {
1511
+	headers map[string][]string) (*registrytypes.SearchResults, error) {
1512 1512
 	return daemon.RegistryService.Search(term, authConfig, headers)
1513 1513
 }
1514 1514
 
... ...
@@ -460,10 +460,10 @@ func handlerAuth(w http.ResponseWriter, r *http.Request) {
460 460
 }
461 461
 
462 462
 func handlerSearch(w http.ResponseWriter, r *http.Request) {
463
-	result := &SearchResults{
463
+	result := &registrytypes.SearchResults{
464 464
 		Query:      "fakequery",
465 465
 		NumResults: 1,
466
-		Results:    []SearchResult{{Name: "fakeimage", StarCount: 42}},
466
+		Results:    []registrytypes.SearchResult{{Name: "fakeimage", StarCount: 42}},
467 467
 	}
468 468
 	writeResponse(w, result, 200)
469 469
 }
... ...
@@ -73,7 +73,7 @@ func splitReposSearchTerm(reposName string) (string, string) {
73 73
 
74 74
 // Search queries the public registry for images matching the specified
75 75
 // search terms, and returns the results.
76
-func (s *Service) Search(term string, authConfig *types.AuthConfig, headers map[string][]string) (*SearchResults, error) {
76
+func (s *Service) Search(term string, authConfig *types.AuthConfig, headers map[string][]string) (*registrytypes.SearchResults, error) {
77 77
 	if err := validateNoSchema(term); err != nil {
78 78
 		return nil, err
79 79
 	}
... ...
@@ -21,6 +21,7 @@ import (
21 21
 	"github.com/Sirupsen/logrus"
22 22
 	"github.com/docker/distribution/reference"
23 23
 	"github.com/docker/docker/api/types"
24
+	registrytypes "github.com/docker/docker/api/types/registry"
24 25
 	"github.com/docker/docker/pkg/httputils"
25 26
 	"github.com/docker/docker/pkg/ioutils"
26 27
 	"github.com/docker/docker/pkg/stringid"
... ...
@@ -718,7 +719,7 @@ func shouldRedirect(response *http.Response) bool {
718 718
 }
719 719
 
720 720
 // SearchRepositories performs a search against the remote repository
721
-func (r *Session) SearchRepositories(term string) (*SearchResults, error) {
721
+func (r *Session) SearchRepositories(term string) (*registrytypes.SearchResults, error) {
722 722
 	logrus.Debugf("Index server: %s", r.indexEndpoint)
723 723
 	u := r.indexEndpoint.VersionString(1) + "search?q=" + url.QueryEscape(term)
724 724
 
... ...
@@ -736,7 +737,7 @@ func (r *Session) SearchRepositories(term string) (*SearchResults, error) {
736 736
 	if res.StatusCode != 200 {
737 737
 		return nil, httputils.NewHTTPRequestError(fmt.Sprintf("Unexpected status code %d", res.StatusCode), res)
738 738
 	}
739
-	result := new(SearchResults)
739
+	result := new(registrytypes.SearchResults)
740 740
 	return result, json.NewDecoder(res.Body).Decode(result)
741 741
 }
742 742
 
... ...
@@ -5,32 +5,6 @@ import (
5 5
 	registrytypes "github.com/docker/docker/api/types/registry"
6 6
 )
7 7
 
8
-// SearchResult describes a search result returned from a registry
9
-type SearchResult struct {
10
-	// StarCount indicates the number of stars this repository has
11
-	StarCount int `json:"star_count"`
12
-	// IsOfficial indicates whether the result is an official repository or not
13
-	IsOfficial bool `json:"is_official"`
14
-	// Name is the name of the repository
15
-	Name string `json:"name"`
16
-	// IsOfficial indicates whether the result is trusted
17
-	IsTrusted bool `json:"is_trusted"`
18
-	// IsAutomated indicates whether the result is automated
19
-	IsAutomated bool `json:"is_automated"`
20
-	// Description is a textual description of the repository
21
-	Description string `json:"description"`
22
-}
23
-
24
-// SearchResults lists a collection search results returned from a registry
25
-type SearchResults struct {
26
-	// Query contains the query string that generated the search results
27
-	Query string `json:"query"`
28
-	// NumResults indicates the number of results the query returned
29
-	NumResults int `json:"num_results"`
30
-	// Results is a slice containing the actual results for the search
31
-	Results []SearchResult `json:"results"`
32
-}
33
-
34 8
 // RepositoryData tracks the image list, list of endpoints, and list of tokens
35 9
 // for a repository
36 10
 type RepositoryData struct {