github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/api/server/router/container/backend.go (about)

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