summaryrefslogtreecommitdiff
path: root/libcontainerd/types.go
diff options
context:
space:
mode:
authorhwajeong.son <hwajeong.son@samsung.com>2018-08-20 13:30:55 +0900
committerhwajeong.son <hwajeong.son@samsung.com>2018-08-20 13:30:55 +0900
commit0b51891e5977b87f986f4db2cbbe09295cfdbedc (patch)
treec35ac732cb1dffccee5a32131431f753481077c2 /libcontainerd/types.go
parenteea0e89806b2cf59af3dccabc67014bd19b91b82 (diff)
downloaddocker-engine-master.tar.gz
docker-engine-master.tar.bz2
docker-engine-master.zip
Signed-off-by: hwajeong.son <hwajeong.son@samsung.com>
Diffstat (limited to 'libcontainerd/types.go')
-rw-r--r--libcontainerd/types.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/libcontainerd/types.go b/libcontainerd/types.go
new file mode 100644
index 0000000..c7ade6b
--- /dev/null
+++ b/libcontainerd/types.go
@@ -0,0 +1,75 @@
+package libcontainerd
+
+import (
+ "io"
+
+ containerd "github.com/containerd/containerd/api/grpc/types"
+ "github.com/opencontainers/runtime-spec/specs-go"
+ "golang.org/x/net/context"
+)
+
+// State constants used in state change reporting.
+const (
+ StateStart = "start-container"
+ StatePause = "pause"
+ StateResume = "resume"
+ StateExit = "exit"
+ StateRestore = "restore"
+ StateExitProcess = "exit-process"
+ StateOOM = "oom" // fake state
+)
+
+// CommonStateInfo contains the state info common to all platforms.
+type CommonStateInfo struct { // FIXME: event?
+ 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
+}
+
+// Client provides access to containerd features.
+type Client interface {
+ GetServerVersion(ctx context.Context) (*ServerVersion, error)
+ Create(containerID string, checkpoint string, checkpointDir string, spec specs.Spec, attachStdio StdioCallback, options ...CreateOption) error
+ Signal(containerID string, sig int) error
+ SignalProcess(containerID string, processFriendlyName string, sig int) error
+ AddProcess(ctx context.Context, containerID, processFriendlyName string, process Process, attachStdio StdioCallback) (int, error)
+ Resize(containerID, processFriendlyName string, width, height int) error
+ Pause(containerID string) error
+ Resume(containerID string) error
+ Restore(containerID string, attachStdio StdioCallback, options ...CreateOption) error
+ Stats(containerID string) (*Stats, error)
+ GetPidsForContainer(containerID string) ([]int, error)
+ Summary(containerID string) ([]Summary, error)
+ UpdateResources(containerID string, resources Resources) error
+ 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)
+}
+
+// CreateOption allows to configure parameters of container creation.
+type CreateOption interface {
+ Apply(interface{}) error
+}
+
+// StdioCallback is called to connect a container or process stdio.
+type StdioCallback func(IOPipe) error
+
+// IOPipe contains the stdio streams.
+type IOPipe struct {
+ Stdin io.WriteCloser
+ Stdout io.ReadCloser
+ Stderr io.ReadCloser
+ Terminal bool // Whether stderr is connected on Windows
+}
+
+// ServerVersion contains version information as retrieved from the
+// server
+type ServerVersion struct {
+ containerd.GetServerVersionResponse
+}