defs.go 946 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package plugin
  2. import (
  3. "sync"
  4. "github.com/docker/docker/pkg/plugins"
  5. "github.com/docker/docker/plugin/v2"
  6. )
  7. // Store manages the plugin inventory in memory and on-disk
  8. type Store struct {
  9. sync.RWMutex
  10. plugins map[string]*v2.Plugin
  11. /* handlers are necessary for transition path of legacy plugins
  12. * to the new model. Legacy plugins use Handle() for registering an
  13. * activation callback.*/
  14. handlers map[string][]func(string, *plugins.Client)
  15. }
  16. // NewStore creates a Store.
  17. func NewStore() *Store {
  18. return &Store{
  19. plugins: make(map[string]*v2.Plugin),
  20. handlers: make(map[string][]func(string, *plugins.Client)),
  21. }
  22. }
  23. // CreateOpt is used to configure specific plugin details when created
  24. type CreateOpt func(p *v2.Plugin)
  25. // WithSwarmService is a CreateOpt that flags the passed in a plugin as a plugin
  26. // managed by swarm
  27. func WithSwarmService(id string) CreateOpt {
  28. return func(p *v2.Plugin) {
  29. p.SwarmServiceID = id
  30. }
  31. }