github.com/lazyboychen7/engine@v17.12.1-ce-rc2+incompatible/plugin/defs.go (about)

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