github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/swarmkit/agent/exec/executor.go (about)

     1  package exec
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/docker/swarmkit/api"
     7  )
     8  
     9  // Executor provides controllers for tasks.
    10  type Executor interface {
    11  	// Describe returns the underlying node description.
    12  	Describe(ctx context.Context) (*api.NodeDescription, error)
    13  
    14  	// Configure uses the node object state to propagate node
    15  	// state to the underlying executor.
    16  	Configure(ctx context.Context, node *api.Node) error
    17  
    18  	// Controller provides a controller for the given task.
    19  	Controller(t *api.Task) (Controller, error)
    20  
    21  	// SetNetworkBootstrapKeys passes the symmetric keys from the
    22  	// manager to the executor.
    23  	SetNetworkBootstrapKeys([]*api.EncryptionKey) error
    24  }
    25  
    26  // SecretsProvider is implemented by objects that can store secrets, typically
    27  // an executor.
    28  type SecretsProvider interface {
    29  	Secrets() SecretsManager
    30  }
    31  
    32  // ConfigsProvider is implemented by objects that can store configs,
    33  // typically an executor.
    34  type ConfigsProvider interface {
    35  	Configs() ConfigsManager
    36  }
    37  
    38  // DependencyManager is a meta-object that can keep track of typed objects
    39  // such as secrets and configs.
    40  type DependencyManager interface {
    41  	SecretsProvider
    42  	ConfigsProvider
    43  }
    44  
    45  // DependencyGetter is a meta-object that can provide access to typed objects
    46  // such as secrets and configs.
    47  type DependencyGetter interface {
    48  	Secrets() SecretGetter
    49  	Configs() ConfigGetter
    50  }
    51  
    52  // SecretGetter contains secret data necessary for the Controller.
    53  type SecretGetter interface {
    54  	// Get returns the the secret with a specific secret ID, if available.
    55  	// When the secret is not available, the return will be nil.
    56  	Get(secretID string) (*api.Secret, error)
    57  }
    58  
    59  // SecretsManager is the interface for secret storage and updates.
    60  type SecretsManager interface {
    61  	SecretGetter
    62  
    63  	Add(secrets ...api.Secret) // add one or more secrets
    64  	Remove(secrets []string)   // remove the secrets by ID
    65  	Reset()                    // remove all secrets
    66  }
    67  
    68  // ConfigGetter contains config data necessary for the Controller.
    69  type ConfigGetter interface {
    70  	// Get returns the the config with a specific config ID, if available.
    71  	// When the config is not available, the return will be nil.
    72  	Get(configID string) (*api.Config, error)
    73  }
    74  
    75  // ConfigsManager is the interface for config storage and updates.
    76  type ConfigsManager interface {
    77  	ConfigGetter
    78  
    79  	Add(configs ...api.Config) // add one or more configs
    80  	Remove(configs []string)   // remove the configs by ID
    81  	Reset()                    // remove all configs
    82  }