Merge pull request #11789 from parknicker/PostContainerWaitFix

Changes response of postContainersWait to use a struct
This commit is contained in:
Alexander Morozov 2015-03-26 08:40:00 -07:00
commit d4fca8047c
2 changed files with 13 additions and 4 deletions

View file

@ -878,7 +878,6 @@ func postContainersWait(eng *engine.Engine, version version.Version, w http.Resp
return fmt.Errorf("Missing parameter")
}
var (
env engine.Env
stdoutBuffer = bytes.NewBuffer(nil)
job = eng.Job("wait", vars["name"])
)
@ -886,9 +885,13 @@ func postContainersWait(eng *engine.Engine, version version.Version, w http.Resp
if err := job.Run(); err != nil {
return err
}
env.Set("StatusCode", engine.Tail(stdoutBuffer, 1))
return writeJSONEnv(w, http.StatusOK, env)
statusCode, err := strconv.Atoi(engine.Tail(stdoutBuffer, 1))
if err != nil {
return err
}
return writeJSON(w, http.StatusOK, &types.ContainerWaitResponse{
StatusCode: statusCode,
})
}
func postContainersResize(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {

View file

@ -24,3 +24,9 @@ type AuthResponse struct {
// Status is the authentication status
Status string `json:"Status"`
}
// POST "/containers/"+containerID+"/wait"
type ContainerWaitResponse struct {
// StatusCode is the status code of the wait job
StatusCode int `json:"StatusCode"`
}