mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-03 20:21:44 +00:00
refactor stats to not use internal data structures
- refactor to make it easier to split the api in the future - addition to check the existing test case and make sure it contains some expected output Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
This commit is contained in:
+1
-11
@@ -59,16 +59,6 @@ func (s *Server) getContainersStats(ctx context.Context, w http.ResponseWriter,
|
||||
}
|
||||
|
||||
stream := boolValueOrDefault(r, "stream", true)
|
||||
|
||||
// If the container is not running and requires no stream, return an empty stats.
|
||||
container, err := s.daemon.Get(vars["name"])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !container.IsRunning() && !stream {
|
||||
return writeJSON(w, http.StatusOK, &types.Stats{})
|
||||
}
|
||||
|
||||
var out io.Writer
|
||||
if !stream {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -90,7 +80,7 @@ func (s *Server) getContainersStats(ctx context.Context, w http.ResponseWriter,
|
||||
Version: version,
|
||||
}
|
||||
|
||||
return s.daemon.ContainerStats(container, config)
|
||||
return s.daemon.ContainerStats(vars["name"], config)
|
||||
}
|
||||
|
||||
func (s *Server) getContainersLogs(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||
|
||||
Reference in New Issue
Block a user