2015-11-04 20:38:05 -05:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"time"
|
|
|
|
|
2016-03-25 14:33:54 -04:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
|
2016-01-27 17:09:42 -05:00
|
|
|
"github.com/docker/docker/api/types/backend"
|
2015-11-04 20:38:05 -05:00
|
|
|
"github.com/docker/docker/pkg/archive"
|
2016-01-04 19:05:26 -05:00
|
|
|
"github.com/docker/engine-api/types"
|
|
|
|
"github.com/docker/engine-api/types/container"
|
2015-11-04 20:38:05 -05:00
|
|
|
)
|
|
|
|
|
2015-11-24 13:35:02 -05:00
|
|
|
// execBackend includes functions to implement to provide exec functionality.
|
|
|
|
type execBackend interface {
|
2016-04-13 04:33:46 -04:00
|
|
|
ContainerExecCreate(name string, config *types.ExecConfig) (string, error)
|
2016-02-10 15:16:59 -05:00
|
|
|
ContainerExecInspect(id string) (*backend.ExecInspect, error)
|
2015-11-04 20:38:05 -05:00
|
|
|
ContainerExecResize(name string, height, width int) error
|
2016-04-18 05:48:13 -04:00
|
|
|
ContainerExecStart(ctx context.Context, name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error
|
2015-11-24 13:35:02 -05:00
|
|
|
ExecExists(name string) (bool, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// copyBackend includes functions to implement to provide container copy functionality.
|
|
|
|
type copyBackend interface {
|
|
|
|
ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error)
|
|
|
|
ContainerCopy(name string, res string) (io.ReadCloser, error)
|
2015-11-04 20:38:05 -05:00
|
|
|
ContainerExport(name string, out io.Writer) error
|
|
|
|
ContainerExtractToDir(name, path string, noOverwriteDirNonDir bool, content io.Reader) error
|
2015-11-24 13:35:02 -05:00
|
|
|
ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// stateBackend includes functions to implement to provide container state lifecycle functionality.
|
|
|
|
type stateBackend interface {
|
2015-12-16 11:56:49 -05:00
|
|
|
ContainerCreate(types.ContainerCreateConfig) (types.ContainerCreateResponse, error)
|
2015-11-04 20:38:05 -05:00
|
|
|
ContainerKill(name string, sig uint64) error
|
|
|
|
ContainerPause(name string) error
|
|
|
|
ContainerRename(oldName, newName string) error
|
|
|
|
ContainerResize(name string, height, width int) error
|
|
|
|
ContainerRestart(name string, seconds int) error
|
2015-12-04 15:34:43 -05:00
|
|
|
ContainerRm(name string, config *types.ContainerRmConfig) error
|
2015-12-18 13:36:17 -05:00
|
|
|
ContainerStart(name string, hostConfig *container.HostConfig) error
|
2015-11-04 20:38:05 -05:00
|
|
|
ContainerStop(name string, seconds int) error
|
|
|
|
ContainerUnpause(name string) error
|
2015-12-28 06:19:26 -05:00
|
|
|
ContainerUpdate(name string, hostConfig *container.HostConfig) ([]string, error)
|
2015-11-04 20:38:05 -05:00
|
|
|
ContainerWait(name string, timeout time.Duration) (int, error)
|
|
|
|
}
|
2015-11-24 13:35:02 -05:00
|
|
|
|
|
|
|
// monitorBackend includes functions to implement to provide containers monitoring functionality.
|
|
|
|
type monitorBackend interface {
|
|
|
|
ContainerChanges(name string) ([]archive.Change, error)
|
2016-04-19 10:56:54 -04:00
|
|
|
ContainerInspect(name string, size bool, version string) (interface{}, error)
|
2016-03-25 14:33:54 -04:00
|
|
|
ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
|
|
|
|
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
|
2015-11-24 13:35:02 -05:00
|
|
|
ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error)
|
|
|
|
|
2016-01-27 17:09:42 -05:00
|
|
|
Containers(config *types.ContainerListOptions) ([]*types.Container, error)
|
2015-11-24 13:35:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// attachBackend includes function to implement to provide container attaching functionality.
|
|
|
|
type attachBackend interface {
|
2016-01-05 16:23:24 -05:00
|
|
|
ContainerAttach(name string, c *backend.ContainerAttachConfig) error
|
2015-11-24 13:35:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Backend is all the methods that need to be implemented to provide container specific functionality.
|
|
|
|
type Backend interface {
|
|
|
|
execBackend
|
|
|
|
copyBackend
|
|
|
|
stateBackend
|
|
|
|
monitorBackend
|
|
|
|
attachBackend
|
|
|
|
}
|