github.com/olljanat/moby@v1.13.1/api/server/router/container/backend.go (about)

     1  package container
     2  
     3  import (
     4  	"io"
     5  	"time"
     6  
     7  	"golang.org/x/net/context"
     8  
     9  	"github.com/docker/docker/api/types"
    10  	"github.com/docker/docker/api/types/backend"
    11  	"github.com/docker/docker/api/types/container"
    12  	"github.com/docker/docker/api/types/filters"
    13  	"github.com/docker/docker/pkg/archive"
    14  )
    15  
    16  // execBackend includes functions to implement to provide exec functionality.
    17  type execBackend interface {
    18  	ContainerExecCreate(name string, config *types.ExecConfig) (string, error)
    19  	ContainerExecInspect(id string) (*backend.ExecInspect, error)
    20  	ContainerExecResize(name string, height, width int) error
    21  	ContainerExecStart(ctx context.Context, name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error
    22  	ExecExists(name string) (bool, error)
    23  }
    24  
    25  // copyBackend includes functions to implement to provide container copy functionality.
    26  type copyBackend interface {
    27  	ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error)
    28  	ContainerCopy(name string, res string) (io.ReadCloser, error)
    29  	ContainerExport(name string, out io.Writer) error
    30  	ContainerExtractToDir(name, path string, noOverwriteDirNonDir bool, content io.Reader) error
    31  	ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error)
    32  }
    33  
    34  // stateBackend includes functions to implement to provide container state lifecycle functionality.
    35  type stateBackend interface {
    36  	ContainerCreate(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
    37  	ContainerKill(name string, sig uint64) error
    38  	ContainerPause(name string) error
    39  	ContainerRename(oldName, newName string) error
    40  	ContainerResize(name string, height, width int) error
    41  	ContainerRestart(name string, seconds *int) error
    42  	ContainerRm(name string, config *types.ContainerRmConfig) error
    43  	ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
    44  	ContainerStop(name string, seconds *int) error
    45  	ContainerUnpause(name string) error
    46  	ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error)
    47  	ContainerWait(name string, timeout time.Duration) (int, error)
    48  }
    49  
    50  // monitorBackend includes functions to implement to provide containers monitoring functionality.
    51  type monitorBackend interface {
    52  	ContainerChanges(name string) ([]archive.Change, error)
    53  	ContainerInspect(name string, size bool, version string) (interface{}, error)
    54  	ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
    55  	ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
    56  	ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error)
    57  
    58  	Containers(config *types.ContainerListOptions) ([]*types.Container, error)
    59  }
    60  
    61  // attachBackend includes function to implement to provide container attaching functionality.
    62  type attachBackend interface {
    63  	ContainerAttach(name string, c *backend.ContainerAttachConfig) error
    64  }
    65  
    66  // systemBackend includes functions to implement to provide system wide containers functionality
    67  type systemBackend interface {
    68  	ContainersPrune(pruneFilters filters.Args) (*types.ContainersPruneReport, error)
    69  }
    70  
    71  // Backend is all the methods that need to be implemented to provide container specific functionality.
    72  type Backend interface {
    73  	execBackend
    74  	copyBackend
    75  	stateBackend
    76  	monitorBackend
    77  	attachBackend
    78  	systemBackend
    79  }