backend.go 4.0 KB

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