2015-08-24 13:57:39 -04:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
|
2015-09-09 14:14:09 -07:00
|
|
|
"github.com/docker/docker/context"
|
2015-08-24 13:57:39 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// getContainersByName inspects containers configuration and serializes it as json.
|
2015-08-31 07:55:51 -07:00
|
|
|
func (s *Server) getContainersByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
2015-08-24 13:57:39 -04:00
|
|
|
if vars == nil {
|
|
|
|
return fmt.Errorf("Missing parameter")
|
|
|
|
}
|
|
|
|
|
|
|
|
var json interface{}
|
|
|
|
var err error
|
|
|
|
|
2015-09-09 14:14:09 -07:00
|
|
|
version := ctx.Version()
|
2015-08-31 07:55:51 -07:00
|
|
|
|
2015-08-24 13:57:39 -04:00
|
|
|
switch {
|
|
|
|
case version.LessThan("1.20"):
|
|
|
|
json, err = s.daemon.ContainerInspectPre120(vars["name"])
|
|
|
|
case version.Equal("1.20"):
|
|
|
|
json, err = s.daemon.ContainerInspect120(vars["name"])
|
|
|
|
default:
|
|
|
|
json, err = s.daemon.ContainerInspect(vars["name"])
|
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return writeJSON(w, http.StatusOK, json)
|
|
|
|
}
|