Merge pull request #1733 from thaJeztah/18.09_backport_dial_stdio_npipe_on_windows

[18.09 backport] dial-stdio: handle connections which lack CloseRead method
This commit is contained in:
Tibor Vass
2019-03-21 14:35:47 -07:00
committed by GitHub

View File

@ -34,10 +34,18 @@ func runDialStdio(dockerCli command.Cli) error {
if err != nil {
return errors.Wrap(err, "failed to open the raw stream connection")
}
connHalfCloser, ok := conn.(halfCloser)
if !ok {
defer conn.Close()
var connHalfCloser halfCloser
switch t := conn.(type) {
case halfCloser:
connHalfCloser = t
case halfReadWriteCloser:
connHalfCloser = &nopCloseReader{t}
default:
return errors.New("the raw stream connection does not implement halfCloser")
}
stdin2conn := make(chan error)
conn2stdout := make(chan error)
go func() {
@ -90,6 +98,19 @@ type halfCloser interface {
halfWriteCloser
}
type halfReadWriteCloser interface {
io.Reader
halfWriteCloser
}
type nopCloseReader struct {
halfReadWriteCloser
}
func (x *nopCloseReader) CloseRead() error {
return nil
}
type halfReadCloserWrapper struct {
io.ReadCloser
}