backend.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package executor // import "github.com/docker/docker/daemon/cluster/executor"
  2. import (
  3. "context"
  4. "io"
  5. "time"
  6. "github.com/distribution/reference"
  7. "github.com/docker/distribution"
  8. "github.com/docker/docker/api/types"
  9. "github.com/docker/docker/api/types/backend"
  10. "github.com/docker/docker/api/types/container"
  11. "github.com/docker/docker/api/types/events"
  12. "github.com/docker/docker/api/types/filters"
  13. "github.com/docker/docker/api/types/network"
  14. "github.com/docker/docker/api/types/registry"
  15. "github.com/docker/docker/api/types/swarm"
  16. "github.com/docker/docker/api/types/system"
  17. "github.com/docker/docker/api/types/volume"
  18. containerpkg "github.com/docker/docker/container"
  19. clustertypes "github.com/docker/docker/daemon/cluster/provider"
  20. networkSettings "github.com/docker/docker/daemon/network"
  21. "github.com/docker/docker/image"
  22. "github.com/docker/docker/libnetwork"
  23. "github.com/docker/docker/libnetwork/cluster"
  24. networktypes "github.com/docker/docker/libnetwork/types"
  25. "github.com/docker/docker/plugin"
  26. volumeopts "github.com/docker/docker/volume/service/opts"
  27. "github.com/moby/swarmkit/v2/agent/exec"
  28. ocispec "github.com/opencontainers/image-spec/specs-go/v1"
  29. )
  30. // Backend defines the executor component for a swarm agent.
  31. type Backend interface {
  32. CreateManagedNetwork(clustertypes.NetworkCreateRequest) error
  33. DeleteManagedNetwork(networkID string) error
  34. FindNetwork(idName string) (*libnetwork.Network, error)
  35. SetupIngress(clustertypes.NetworkCreateRequest, string) (<-chan struct{}, error)
  36. ReleaseIngress() (<-chan struct{}, error)
  37. CreateManagedContainer(ctx context.Context, config backend.ContainerCreateConfig) (container.CreateResponse, error)
  38. ContainerStart(ctx context.Context, name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
  39. ContainerStop(ctx context.Context, name string, config container.StopOptions) error
  40. ContainerLogs(ctx context.Context, name string, config *container.LogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
  41. ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error
  42. ActivateContainerServiceBinding(containerName string) error
  43. DeactivateContainerServiceBinding(containerName string) error
  44. UpdateContainerServiceConfig(containerName string, serviceConfig *clustertypes.ServiceConfig) error
  45. ContainerInspectCurrent(ctx context.Context, name string, size bool) (*types.ContainerJSON, error)
  46. ContainerWait(ctx context.Context, name string, condition containerpkg.WaitCondition) (<-chan containerpkg.StateStatus, error)
  47. ContainerRm(name string, config *backend.ContainerRmConfig) error
  48. ContainerKill(name string, sig string) error
  49. SetContainerDependencyStore(name string, store exec.DependencyGetter) error
  50. SetContainerSecretReferences(name string, refs []*swarm.SecretReference) error
  51. SetContainerConfigReferences(name string, refs []*swarm.ConfigReference) error
  52. SystemInfo(context.Context) (*system.Info, error)
  53. Containers(ctx context.Context, config *container.ListOptions) ([]*types.Container, error)
  54. SetNetworkBootstrapKeys([]*networktypes.EncryptionKey) error
  55. DaemonJoinsCluster(provider cluster.Provider)
  56. DaemonLeavesCluster()
  57. IsSwarmCompatible() error
  58. SubscribeToEvents(since, until time.Time, filter filters.Args) ([]events.Message, chan interface{})
  59. UnsubscribeFromEvents(listener chan interface{})
  60. UpdateAttachment(string, string, string, *network.NetworkingConfig) error
  61. WaitForDetachment(context.Context, string, string, string, string) error
  62. PluginManager() *plugin.Manager
  63. PluginGetter() *plugin.Store
  64. GetAttachmentStore() *networkSettings.AttachmentStore
  65. HasExperimental() bool
  66. }
  67. // VolumeBackend is used by an executor to perform volume operations
  68. type VolumeBackend interface {
  69. Create(ctx context.Context, name, driverName string, opts ...volumeopts.CreateOption) (*volume.Volume, error)
  70. }
  71. // ImageBackend is used by an executor to perform image operations
  72. type ImageBackend interface {
  73. PullImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
  74. GetRepositories(context.Context, reference.Named, *registry.AuthConfig) ([]distribution.Repository, error)
  75. GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*image.Image, error)
  76. }