backend.go 3.4 KB

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