2016-03-18 14:50:19 -04:00
|
|
|
package libcontainerd
|
|
|
|
|
2016-07-15 17:12:07 -04:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2016-09-27 13:26:59 -04:00
|
|
|
"github.com/opencontainers/runtime-spec/specs-go"
|
2016-07-15 17:12:07 -04:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
2016-03-18 14:50:19 -04:00
|
|
|
|
|
|
|
// State constants used in state change reporting.
|
|
|
|
const (
|
|
|
|
StateStart = "start-container"
|
|
|
|
StatePause = "pause"
|
|
|
|
StateResume = "resume"
|
|
|
|
StateExit = "exit"
|
|
|
|
StateRestart = "restart"
|
|
|
|
StateRestore = "restore"
|
|
|
|
StateStartProcess = "start-process"
|
|
|
|
StateExitProcess = "exit-process"
|
|
|
|
StateOOM = "oom" // fake state
|
|
|
|
stateLive = "live"
|
|
|
|
)
|
|
|
|
|
2016-04-01 20:02:38 -04:00
|
|
|
// CommonStateInfo contains the state info common to all platforms.
|
|
|
|
type CommonStateInfo struct { // FIXME: event?
|
2016-03-18 14:50:19 -04:00
|
|
|
State string
|
|
|
|
Pid uint32
|
|
|
|
ExitCode uint32
|
|
|
|
ProcessID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Backend defines callbacks that the client of the library needs to implement.
|
|
|
|
type Backend interface {
|
|
|
|
StateChanged(containerID string, state StateInfo) error
|
|
|
|
AttachStreams(processFriendlyName string, io IOPipe) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Client provides access to containerd features.
|
|
|
|
type Client interface {
|
2016-09-27 13:26:59 -04:00
|
|
|
Create(containerID string, checkpoint string, checkpointDir string, spec specs.Spec, options ...CreateOption) error
|
2016-03-18 14:50:19 -04:00
|
|
|
Signal(containerID string, sig int) error
|
2016-04-18 05:48:13 -04:00
|
|
|
SignalProcess(containerID string, processFriendlyName string, sig int) error
|
2016-07-15 17:12:07 -04:00
|
|
|
AddProcess(ctx context.Context, containerID, processFriendlyName string, process Process) error
|
2016-03-18 14:50:19 -04:00
|
|
|
Resize(containerID, processFriendlyName string, width, height int) error
|
|
|
|
Pause(containerID string) error
|
|
|
|
Resume(containerID string) error
|
|
|
|
Restore(containerID string, options ...CreateOption) error
|
|
|
|
Stats(containerID string) (*Stats, error)
|
|
|
|
GetPidsForContainer(containerID string) ([]int, error)
|
2016-03-20 18:58:23 -04:00
|
|
|
Summary(containerID string) ([]Summary, error)
|
2016-03-18 14:50:19 -04:00
|
|
|
UpdateResources(containerID string, resources Resources) error
|
2016-05-12 10:52:00 -04:00
|
|
|
CreateCheckpoint(containerID string, checkpointID string, checkpointDir string, exit bool) error
|
|
|
|
DeleteCheckpoint(containerID string, checkpointID string, checkpointDir string) error
|
|
|
|
ListCheckpoints(containerID string, checkpointDir string) (*Checkpoints, error)
|
2016-03-18 14:50:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateOption allows to configure parameters of container creation.
|
|
|
|
type CreateOption interface {
|
|
|
|
Apply(interface{}) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// IOPipe contains the stdio streams.
|
|
|
|
type IOPipe struct {
|
|
|
|
Stdin io.WriteCloser
|
|
|
|
Stdout io.Reader
|
|
|
|
Stderr io.Reader
|
|
|
|
Terminal bool // Whether stderr is connected on Windows
|
|
|
|
}
|