Update go-runc to f36917a18b3d962aee066063cba0bcff44e338ca
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
d619954a2b
commit
462bdd7669
3 changed files with 64 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
# go-runc client for runc; master as of 01/20/2017
|
||||
github.com/crosbymichael/go-runc 7b66c5da30493c5eb9c655cab67ba88071891ac5
|
||||
github.com/crosbymichael/go-runc f36917a18b3d962aee066063cba0bcff44e338ca
|
||||
# go-metrics client to prometheus; master as of 12/16/2016
|
||||
github.com/docker/go-metrics 0f35294225552d968a13f9c5bc71a3fa44b2eb87
|
||||
# prometheus client; latest release as of 12/16/2016
|
||||
|
|
47
vendor/github.com/crosbymichael/go-runc/io.go
generated
vendored
47
vendor/github.com/crosbymichael/go-runc/io.go
generated
vendored
|
@ -15,6 +15,10 @@ type IO interface {
|
|||
Set(*exec.Cmd)
|
||||
}
|
||||
|
||||
type StartCloser interface {
|
||||
CloseAfterStart() error
|
||||
}
|
||||
|
||||
// NewPipeIO creates pipe pairs to be used with runc
|
||||
func NewPipeIO(uid, gid int) (i IO, err error) {
|
||||
var pipes []*pipe
|
||||
|
@ -92,11 +96,11 @@ func (i *pipeIO) Stdin() io.WriteCloser {
|
|||
}
|
||||
|
||||
func (i *pipeIO) Stdout() io.ReadCloser {
|
||||
return i.in.r
|
||||
return i.out.r
|
||||
}
|
||||
|
||||
func (i *pipeIO) Stderr() io.ReadCloser {
|
||||
return i.in.r
|
||||
return i.err.r
|
||||
}
|
||||
|
||||
func (i *pipeIO) Close() error {
|
||||
|
@ -113,9 +117,48 @@ func (i *pipeIO) Close() error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (i *pipeIO) CloseAfterStart() error {
|
||||
for _, f := range []*os.File{
|
||||
i.out.w,
|
||||
i.err.w,
|
||||
} {
|
||||
f.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Set sets the io to the exec.Cmd
|
||||
func (i *pipeIO) Set(cmd *exec.Cmd) {
|
||||
cmd.Stdin = i.in.r
|
||||
cmd.Stdout = i.out.w
|
||||
cmd.Stderr = i.err.w
|
||||
}
|
||||
|
||||
func NewSTDIO() (IO, error) {
|
||||
return &stdio{}, nil
|
||||
}
|
||||
|
||||
type stdio struct {
|
||||
}
|
||||
|
||||
func (s *stdio) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *stdio) Set(cmd *exec.Cmd) {
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
}
|
||||
|
||||
func (s *stdio) Stdin() io.WriteCloser {
|
||||
return os.Stdin
|
||||
}
|
||||
|
||||
func (s *stdio) Stdout() io.ReadCloser {
|
||||
return os.Stdout
|
||||
}
|
||||
|
||||
func (s *stdio) Stderr() io.ReadCloser {
|
||||
return os.Stderr
|
||||
}
|
||||
|
|
19
vendor/github.com/crosbymichael/go-runc/runc.go
generated
vendored
19
vendor/github.com/crosbymichael/go-runc/runc.go
generated
vendored
|
@ -102,7 +102,24 @@ func (r *Runc) Create(context context.Context, id, bundle string, opts *CreateOp
|
|||
if opts != nil {
|
||||
opts.Set(cmd)
|
||||
}
|
||||
return runOrError(cmd)
|
||||
if cmd.Stdout == nil && cmd.Stderr == nil {
|
||||
data, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %s", err, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := cmd.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
if opts != nil && opts.IO != nil {
|
||||
if c, ok := opts.IO.(StartCloser); ok {
|
||||
if err := c.CloseAfterStart(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return cmd.Wait()
|
||||
}
|
||||
|
||||
// Start will start an already created container
|
||||
|
|
Loading…
Reference in a new issue