engine.Sender and engine.Receiver support stdin

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
Upstream-commit: b63b98ee2766321e2ca6f3b159c2bfb303870105
Component: engine
This commit is contained in:
Solomon Hykes
2014-04-25 16:47:03 -07:00
parent 2e9c0c6ca2
commit bceccfa5cf

View File

@ -46,6 +46,12 @@ func (s *Sender) Handle(job *Job) Status {
tasks.Done()
return nil
})
r.NewRoute().KeyStartsWith("cmd", "log", "stdin").HasAttachment().Handler(func(p []byte, stdin *os.File) error {
tasks.Add(1)
io.Copy(stdin, job.Stdin)
tasks.Done()
return nil
})
var status int
r.NewRoute().KeyStartsWith("cmd", "status").Handler(func(p []byte, f *os.File) error {
cmd := data.Message(p).Get("cmd")
@ -96,6 +102,11 @@ func (rcv *Receiver) Run() error {
return err
}
job.Stderr.Add(stderr)
stdin, err := beam.SendPipe(peer, data.Empty().Set("cmd", "log", "stdin").Bytes())
if err != nil {
return err
}
job.Stdin.Add(stdin)
// ignore error because we pass the raw status
job.Run()
err = peer.Send(data.Empty().Set("cmd", "status", fmt.Sprintf("%d", job.status)).Bytes(), nil)