backend.go 3.1 KB

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