| ... | ... |
@@ -1420,19 +1420,19 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
|
| 1420 | 1420 |
return err |
| 1421 | 1421 |
} |
| 1422 | 1422 |
|
| 1423 |
- outs := []APISearch{}
|
|
| 1423 |
+ outs := []registry.SearchResult{}
|
|
| 1424 | 1424 |
err = json.Unmarshal(body, &outs) |
| 1425 | 1425 |
if err != nil {
|
| 1426 | 1426 |
return err |
| 1427 | 1427 |
} |
| 1428 | 1428 |
fmt.Fprintf(cli.out, "Found %d results matching your query (\"%s\")\n", len(outs), cmd.Arg(0)) |
| 1429 |
- w := tabwriter.NewWriter(cli.out, 33, 1, 3, ' ', 0) |
|
| 1430 |
- fmt.Fprintf(w, "NAME\tDESCRIPTION\n") |
|
| 1429 |
+ w := tabwriter.NewWriter(cli.out, 10, 1, 3, ' ', 0) |
|
| 1430 |
+ fmt.Fprintf(w, "NAME\tDESCRIPTION\tSTARS\tOFFICIAL\tTRUSTED\n") |
|
| 1431 | 1431 |
_, width := cli.getTtySize() |
| 1432 | 1432 |
if width == 0 {
|
| 1433 | 1433 |
width = 45 |
| 1434 | 1434 |
} else {
|
| 1435 |
- width = width - 33 //remote the first column |
|
| 1435 |
+ width = width - 10 - 54 //remote the first column |
|
| 1436 | 1436 |
} |
| 1437 | 1437 |
for _, out := range outs {
|
| 1438 | 1438 |
desc := strings.Replace(out.Description, "\n", " ", -1) |
| ... | ... |
@@ -1440,7 +1440,16 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
|
| 1440 | 1440 |
if !*noTrunc && len(desc) > width {
|
| 1441 | 1441 |
desc = utils.Trunc(desc, width-3) + "..." |
| 1442 | 1442 |
} |
| 1443 |
- fmt.Fprintf(w, "%s\t%s\n", out.Name, desc) |
|
| 1443 |
+ fmt.Fprintf(w, "%s\t%s\t%d\t", out.Name, desc, out.StarCount) |
|
| 1444 |
+ if out.IsOfficial {
|
|
| 1445 |
+ fmt.Fprint(w, "[OK]") |
|
| 1446 |
+ |
|
| 1447 |
+ } |
|
| 1448 |
+ fmt.Fprint(w, "\t") |
|
| 1449 |
+ if out.IsTrusted {
|
|
| 1450 |
+ fmt.Fprint(w, "[OK]") |
|
| 1451 |
+ } |
|
| 1452 |
+ fmt.Fprint(w, "\n") |
|
| 1444 | 1453 |
} |
| 1445 | 1454 |
w.Flush() |
| 1446 | 1455 |
return nil |
| ... | ... |
@@ -615,10 +615,18 @@ func (r *Registry) GetAuthConfig(withPasswd bool) *auth.AuthConfig {
|
| 615 | 615 |
} |
| 616 | 616 |
} |
| 617 | 617 |
|
| 618 |
+type SearchResult struct {
|
|
| 619 |
+ StarCount int `json:"star_count"` |
|
| 620 |
+ IsOfficial bool `json:"is_official"` |
|
| 621 |
+ Name string `json:"name"` |
|
| 622 |
+ IsTrusted bool `json:"is_trusted"` |
|
| 623 |
+ Description string `json:"description"` |
|
| 624 |
+} |
|
| 625 |
+ |
|
| 618 | 626 |
type SearchResults struct {
|
| 619 |
- Query string `json:"query"` |
|
| 620 |
- NumResults int `json:"num_results"` |
|
| 621 |
- Results []map[string]string `json:"results"` |
|
| 627 |
+ Query string `json:"query"` |
|
| 628 |
+ NumResults int `json:"num_results"` |
|
| 629 |
+ Results []SearchResult `json:"results"` |
|
| 622 | 630 |
} |
| 623 | 631 |
|
| 624 | 632 |
type RepositoryData struct {
|
| ... | ... |
@@ -183,7 +183,7 @@ func (srv *Server) ContainerExport(name string, out io.Writer) error {
|
| 183 | 183 |
return fmt.Errorf("No such container: %s", name)
|
| 184 | 184 |
} |
| 185 | 185 |
|
| 186 |
-func (srv *Server) ImagesSearch(term string) ([]APISearch, error) {
|
|
| 186 |
+func (srv *Server) ImagesSearch(term string) ([]registry.SearchResult, error) {
|
|
| 187 | 187 |
r, err := registry.NewRegistry(srv.runtime.config.Root, nil, srv.HTTPRequestFactory(nil)) |
| 188 | 188 |
if err != nil {
|
| 189 | 189 |
return nil, err |
| ... | ... |
@@ -192,15 +192,7 @@ func (srv *Server) ImagesSearch(term string) ([]APISearch, error) {
|
| 192 | 192 |
if err != nil {
|
| 193 | 193 |
return nil, err |
| 194 | 194 |
} |
| 195 |
- |
|
| 196 |
- var outs []APISearch |
|
| 197 |
- for _, repo := range results.Results {
|
|
| 198 |
- var out APISearch |
|
| 199 |
- out.Description = repo["description"] |
|
| 200 |
- out.Name = repo["name"] |
|
| 201 |
- outs = append(outs, out) |
|
| 202 |
- } |
|
| 203 |
- return outs, nil |
|
| 195 |
+ return results.Results, nil |
|
| 204 | 196 |
} |
| 205 | 197 |
|
| 206 | 198 |
func (srv *Server) ImageInsert(name, url, path string, out io.Writer, sf *utils.StreamFormatter) (string, error) {
|