mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
fix run no parameter
This commit is contained in:
parent
59a6316f5e
commit
4079411375
4 changed files with 30 additions and 34 deletions
18
api.go
18
api.go
|
@ -368,9 +368,9 @@ func ListenAndServe(addr string, srv *Server) error {
|
||||||
r.Path("/images/search").Methods("GET").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
r.Path("/images/search").Methods("GET").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Println(r.Method, r.RequestURI)
|
log.Println(r.Method, r.RequestURI)
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := r.ParseForm(); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
term := r.Form.Get("term")
|
term := r.Form.Get("term")
|
||||||
outs, err := srv.ImagesSearch(term)
|
outs, err := srv.ImagesSearch(term)
|
||||||
|
@ -379,12 +379,12 @@ func ListenAndServe(addr string, srv *Server) error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(outs)
|
b, err := json.Marshal(outs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
} else {
|
} else {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Write(b)
|
w.Write(b)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
r.Path("/images/{name:*.}/insert").Methods("POST").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
r.Path("/images/{name:*.}/insert").Methods("POST").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ type ApiContainers struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiSearch struct {
|
type ApiSearch struct {
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
26
commands.go
26
commands.go
|
@ -53,7 +53,7 @@ func ParseCommands(args ...string) error {
|
||||||
|
|
||||||
cmds := map[string]func(args ...string) error{
|
cmds := map[string]func(args ...string) error{
|
||||||
"attach": CmdAttach,
|
"attach": CmdAttach,
|
||||||
"build": CmdBuild,
|
"build": CmdBuild,
|
||||||
"commit": CmdCommit,
|
"commit": CmdCommit,
|
||||||
"diff": CmdDiff,
|
"diff": CmdDiff,
|
||||||
"export": CmdExport,
|
"export": CmdExport,
|
||||||
|
@ -75,7 +75,7 @@ func ParseCommands(args ...string) error {
|
||||||
"rmi": CmdRmi,
|
"rmi": CmdRmi,
|
||||||
"run": CmdRun,
|
"run": CmdRun,
|
||||||
"tag": CmdTag,
|
"tag": CmdTag,
|
||||||
"search": CmdSearch,
|
"search": CmdSearch,
|
||||||
"start": CmdStart,
|
"start": CmdStart,
|
||||||
"stop": CmdStop,
|
"stop": CmdStop,
|
||||||
"version": CmdVersion,
|
"version": CmdVersion,
|
||||||
|
@ -962,17 +962,17 @@ func CmdSearch(args ...string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
v.Set("term", cmd.Arg(0))
|
v.Set("term", cmd.Arg(0))
|
||||||
body, _, err := call("GET", "/images/search?"+v.Encode(), nil)
|
body, _, err := call("GET", "/images/search?"+v.Encode(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var outs []ApiSearch
|
var outs []ApiSearch
|
||||||
err = json.Unmarshal(body, &outs)
|
err = json.Unmarshal(body, &outs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Printf("Found %d results matching your query (\"%s\")\n", len(outs), cmd.Arg(0))
|
fmt.Printf("Found %d results matching your query (\"%s\")\n", len(outs), cmd.Arg(0))
|
||||||
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
|
||||||
fmt.Fprintf(w, "NAME\tDESCRIPTION\n")
|
fmt.Fprintf(w, "NAME\tDESCRIPTION\n")
|
||||||
|
@ -1080,10 +1080,6 @@ func CmdRun(args ...string) error {
|
||||||
cmd.Usage()
|
cmd.Usage()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(config.Cmd) == 0 {
|
|
||||||
cmd.Usage()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//create the container
|
//create the container
|
||||||
body, statusCode, err := call("POST", "/containers", *config)
|
body, statusCode, err := call("POST", "/containers", *config)
|
||||||
|
|
10
server.go
10
server.go
|
@ -46,16 +46,16 @@ func (srv *Server) ContainerExport(name string, file *os.File) error {
|
||||||
func (srv *Server) ImagesSearch(term string) ([]ApiSearch, error) {
|
func (srv *Server) ImagesSearch(term string) ([]ApiSearch, error) {
|
||||||
results, err := srv.runtime.graph.SearchRepositories(nil, term)
|
results, err := srv.runtime.graph.SearchRepositories(nil, term)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var outs []ApiSearch
|
var outs []ApiSearch
|
||||||
for _, repo := range results.Results {
|
for _, repo := range results.Results {
|
||||||
var out ApiSearch
|
var out ApiSearch
|
||||||
out.Description = repo["description"]
|
out.Description = repo["description"]
|
||||||
if len(out.Description) > 45 {
|
if len(out.Description) > 45 {
|
||||||
out.Description = Trunc(out.Description, 42) + "..."
|
out.Description = Trunc(out.Description, 42) + "..."
|
||||||
}
|
}
|
||||||
out.Name = repo["name"]
|
out.Name = repo["name"]
|
||||||
outs = append(outs, out)
|
outs = append(outs, out)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue