backend.go 4.3 KB

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