github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/daemon/cluster/executor/backend.go (about)

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