mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
update attach to use the new job
Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
This commit is contained in:
parent
134435a79c
commit
a7e9baaf89
2 changed files with 15 additions and 8 deletions
17
api.go
17
api.go
|
@ -751,8 +751,17 @@ func postContainersAttach(srv *Server, version float64, w http.ResponseWriter, r
|
|||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
|
||||
c, err := srv.ContainerInspect(vars["name"])
|
||||
if err != nil {
|
||||
var (
|
||||
job = srv.Eng.Job("inspect_container", vars["name"])
|
||||
buffer = bytes.NewBuffer(nil)
|
||||
c Container
|
||||
)
|
||||
job.Stdout.Add(buffer)
|
||||
if err := job.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(buffer.Bytes(), &c); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -786,7 +795,7 @@ func postContainersAttach(srv *Server, version float64, w http.ResponseWriter, r
|
|||
errStream = outStream
|
||||
}
|
||||
|
||||
job := srv.Eng.Job("attach", vars["name"])
|
||||
job = srv.Eng.Job("attach", vars["name"])
|
||||
job.Setenv("logs", r.Form.Get("logs"))
|
||||
job.Setenv("stream", r.Form.Get("stream"))
|
||||
job.Setenv("stdin", r.Form.Get("stdin"))
|
||||
|
@ -810,7 +819,7 @@ func wsContainersAttach(srv *Server, version float64, w http.ResponseWriter, r *
|
|||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
|
||||
if _, err := srv.ContainerInspect(vars["name"]); err != nil {
|
||||
if err := srv.Eng.Job("inspect_container", vars["name"]).Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -2322,12 +2322,10 @@ func (srv *Server) JobContainerInspect(job *engine.Job) engine.Status {
|
|||
return engine.StatusErr
|
||||
}
|
||||
|
||||
type HostConfigPacker struct {
|
||||
b, err := json.Marshal(&struct {
|
||||
*Container
|
||||
HostConfig *HostConfig
|
||||
}
|
||||
|
||||
b, err := json.Marshal(&HostConfigPacker{container, container.hostConfig})
|
||||
}{container, container.hostConfig})
|
||||
if err != nil {
|
||||
job.Error(err)
|
||||
return engine.StatusErr
|
||||
|
|
Loading…
Reference in a new issue