Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions io.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ func (p *pipe) Close() error {
return err
}

// NewPipeIO creates pipe pairs to be used with runc. It is not implemented
// on Windows.
func NewPipeIO(uid, gid int, opts ...IOOpt) (i IO, err error) {
return newPipeIO(uid, gid, opts...)
}

type pipeIO struct {
in *pipe
out *pipe
Expand Down
4 changes: 2 additions & 2 deletions io_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"golang.org/x/sys/unix"
)

// NewPipeIO creates pipe pairs to be used with runc
func NewPipeIO(uid, gid int, opts ...IOOpt) (i IO, err error) {
// newPipeIO creates pipe pairs to be used with runc
func newPipeIO(uid, gid int, opts ...IOOpt) (i IO, err error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if we should instead make whole of io**.go excluded on Windows (mostly concerned if there's code that might refer the types somewhere)

option := defaultIOOption()
for _, o := range opts {
o(option)
Expand Down
45 changes: 4 additions & 41 deletions io_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,8 @@

package runc

// NewPipeIO creates pipe pairs to be used with runc
func NewPipeIO(opts ...IOOpt) (i IO, err error) {
option := defaultIOOption()
for _, o := range opts {
o(option)
}
var (
pipes []*pipe
stdin, stdout, stderr *pipe
)
// cleanup in case of an error
defer func() {
if err != nil {
for _, p := range pipes {
p.Close()
}
}
}()
if option.OpenStdin {
if stdin, err = newPipe(); err != nil {
return nil, err
}
pipes = append(pipes, stdin)
}
if option.OpenStdout {
if stdout, err = newPipe(); err != nil {
return nil, err
}
pipes = append(pipes, stdout)
}
if option.OpenStderr {
if stderr, err = newPipe(); err != nil {
return nil, err
}
pipes = append(pipes, stderr)
}
return &pipeIO{
in: stdin,
out: stdout,
err: stderr,
}, nil
import "errors"

func newPipeIO(uid, gid int, opts ...IOOpt) (i IO, err error) {
return nil, errors.New("not implemented on Windows")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least, I couldn't find code using this on Windows (looks like the only thing used by hcsshim / runhcs is runc.Monitor)

}
18 changes: 18 additions & 0 deletions runc.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"path/filepath"
"strconv"
"strings"
"syscall"
"time"

specs "github.com/opencontainers/runtime-spec/specs-go"
Expand Down Expand Up @@ -56,6 +57,23 @@ const (
DefaultCommand = "runc"
)

// Runc is the client to the runc cli
type Runc struct {
// Command overrides the name of the runc binary. If empty, DefaultCommand
// is used.
Command string
Root string
Debug bool
Log string
LogFormat Format
PdeathSignal syscall.Signal // using syscall.Signal to allow compilation on non-unix (unix.Syscall is an alias for syscall.Signal)
Setpgid bool
Criu string
SystemdCgroup bool
Rootless *bool // nil stands for "auto"
ExtraArgs []string
}

// List returns all containers created inside the provided runc root directory
func (r *Runc) List(context context.Context) ([]*Container, error) {
data, err := cmdOutput(r.command(context, "list", "--format=json"), false, nil)
Expand Down
39 changes: 0 additions & 39 deletions runc_unix.go

This file was deleted.

31 changes: 0 additions & 31 deletions runc_windows.go

This file was deleted.