backend.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package container
  2. import (
  3. "io"
  4. "time"
  5. "github.com/docker/docker/daemon"
  6. "github.com/docker/docker/daemon/exec"
  7. "github.com/docker/docker/pkg/archive"
  8. "github.com/docker/docker/pkg/version"
  9. "github.com/docker/engine-api/types"
  10. "github.com/docker/engine-api/types/container"
  11. )
  12. // execBackend includes functions to implement to provide exec functionality.
  13. type execBackend interface {
  14. ContainerExecCreate(config *types.ExecConfig) (string, error)
  15. ContainerExecInspect(id string) (*exec.Config, error)
  16. ContainerExecResize(name string, height, width int) error
  17. ContainerExecStart(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(types.ContainerCreateConfig) (types.ContainerCreateResponse, 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) error
  38. ContainerStop(name string, seconds int) error
  39. ContainerUnpause(name string) error
  40. ContainerUpdate(name string, hostConfig *container.HostConfig) ([]string, error)
  41. ContainerWait(name string, timeout time.Duration) (int, error)
  42. Exists(id string) bool
  43. }
  44. // monitorBackend includes functions to implement to provide containers monitoring functionality.
  45. type monitorBackend interface {
  46. ContainerChanges(name string) ([]archive.Change, error)
  47. ContainerInspect(name string, size bool, version version.Version) (interface{}, error)
  48. ContainerLogs(name string, config *daemon.ContainerLogsConfig) error
  49. ContainerStats(name string, config *daemon.ContainerStatsConfig) error
  50. ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error)
  51. Containers(config *daemon.ContainersConfig) ([]*types.Container, error)
  52. }
  53. // attachBackend includes function to implement to provide container attaching functionality.
  54. type attachBackend interface {
  55. ContainerAttachWithLogs(name string, c *daemon.ContainerAttachWithLogsConfig) error
  56. ContainerWsAttachWithLogs(name string, c *daemon.ContainerWsAttachWithLogsConfig) error
  57. }
  58. // Backend is all the methods that need to be implemented to provide container specific functionality.
  59. type Backend interface {
  60. execBackend
  61. copyBackend
  62. stateBackend
  63. monitorBackend
  64. attachBackend
  65. }