executor.go 2.4 KB

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