mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
fixed issue with viz
This commit is contained in:
parent
93dc2c331e
commit
c423a790d6
3 changed files with 26 additions and 28 deletions
24
api.go
24
api.go
|
@ -110,19 +110,10 @@ func getContainersExport(srv *Server, w http.ResponseWriter, r *http.Request) ([
|
||||||
}
|
}
|
||||||
|
|
||||||
func getImages(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func getImages(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
vars := mux.Vars(r)
|
|
||||||
format := vars["format"]
|
|
||||||
|
|
||||||
if err := parseForm(r); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if format == "viz" {
|
|
||||||
if err := srv.ImagesViz(w); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return nil, nil
|
|
||||||
} else if format == "" || format == "json" {
|
|
||||||
all := r.Form.Get("all") == "1"
|
all := r.Form.Get("all") == "1"
|
||||||
filter := r.Form.Get("filter")
|
filter := r.Form.Get("filter")
|
||||||
only_ids := r.Form.Get("only_ids") == "1"
|
only_ids := r.Form.Get("only_ids") == "1"
|
||||||
|
@ -137,7 +128,12 @@ func getImages(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, err
|
||||||
}
|
}
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("No such format: %s", format)
|
|
||||||
|
func getImagesViz(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
|
if err := srv.ImagesViz(w); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getInfo(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func getInfo(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
|
@ -508,7 +504,7 @@ func getImagesByName(srv *Server, w http.ResponseWriter, r *http.Request) ([]byt
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListenAndServe(addr string, srv *Server) error {
|
func ListenAndServe(addr string, srv *Server, logging bool) error {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
log.Printf("Listening for HTTP on %s\n", addr)
|
log.Printf("Listening for HTTP on %s\n", addr)
|
||||||
|
|
||||||
|
@ -518,7 +514,8 @@ func ListenAndServe(addr string, srv *Server) error {
|
||||||
"/version": getVersion,
|
"/version": getVersion,
|
||||||
"/containers/{name:.*}/export": getContainersExport,
|
"/containers/{name:.*}/export": getContainersExport,
|
||||||
"/images": getImages,
|
"/images": getImages,
|
||||||
"/images/{format}": getImages,
|
"/images/json": getImages,
|
||||||
|
"/images/viz": getImagesViz,
|
||||||
"/info": getInfo,
|
"/info": getInfo,
|
||||||
"/images/search": getImagesSearch,
|
"/images/search": getImagesSearch,
|
||||||
"/images/{name:.*}/history": getImagesHistory,
|
"/images/{name:.*}/history": getImagesHistory,
|
||||||
|
@ -558,8 +555,9 @@ func ListenAndServe(addr string, srv *Server) error {
|
||||||
localFct := fct
|
localFct := fct
|
||||||
r.Path(localRoute).Methods(localMethod).HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
r.Path(localRoute).Methods(localMethod).HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
Debugf("Calling %s %s", localMethod, localRoute)
|
Debugf("Calling %s %s", localMethod, localRoute)
|
||||||
|
if logging {
|
||||||
log.Println(r.Method, r.RequestURI)
|
log.Println(r.Method, r.RequestURI)
|
||||||
|
}
|
||||||
if strings.Contains(r.Header.Get("User-Agent"), "Docker-Client/") {
|
if strings.Contains(r.Header.Get("User-Agent"), "Docker-Client/") {
|
||||||
userAgent := strings.Split(r.Header.Get("User-Agent"), "/")
|
userAgent := strings.Split(r.Header.Get("User-Agent"), "/")
|
||||||
if len(userAgent) == 2 && userAgent[1] != VERSION {
|
if len(userAgent) == 2 && userAgent[1] != VERSION {
|
||||||
|
|
|
@ -17,7 +17,7 @@ func init() {
|
||||||
srv := &Server{
|
srv := &Server{
|
||||||
runtime: runtime,
|
runtime: runtime,
|
||||||
}
|
}
|
||||||
go ListenAndServe("0.0.0.0:4243", srv)
|
go ListenAndServe("0.0.0.0:4243", srv, false)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,5 +102,5 @@ func daemon(pidfile string, autoRestart bool) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return docker.ListenAndServe("0.0.0.0:4243", server)
|
return docker.ListenAndServe("0.0.0.0:4243", server, true)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue