mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #26925 from anusha-ragunathan/pluginstore-handle
Add Handle method to plugingetter.
This commit is contained in:
commit
1de5043f4e
3 changed files with 12 additions and 6 deletions
|
@ -22,4 +22,5 @@ type CompatPlugin interface {
|
||||||
type PluginGetter interface {
|
type PluginGetter interface {
|
||||||
Get(name, capability string, mode int) (CompatPlugin, error)
|
Get(name, capability string, mode int) (CompatPlugin, error)
|
||||||
GetAllByCap(capability string) ([]CompatPlugin, error)
|
GetAllByCap(capability string) ([]CompatPlugin, error)
|
||||||
|
Handle(capability string, callback func(string, *plugins.Client))
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,3 +24,10 @@ func (ps Store) GetAllByCap(capability string) ([]getter.CompatPlugin, error) {
|
||||||
func (ps Store) Get(name, capability string, _ int) (getter.CompatPlugin, error) {
|
func (ps Store) Get(name, capability string, _ int) (getter.CompatPlugin, error) {
|
||||||
return plugins.Get(name, capability)
|
return plugins.Get(name, capability)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle sets a callback for a given capability. It is only used by network
|
||||||
|
// and ipam drivers during plugin registration. The callback registers the
|
||||||
|
// driver with the subsystem (network, ipam).
|
||||||
|
func (ps *Store) Handle(capability string, callback func(string, *plugins.Client)) {
|
||||||
|
plugins.Handle(capability, callback)
|
||||||
|
}
|
||||||
|
|
|
@ -208,15 +208,13 @@ func (ps *Store) GetAllByCap(capability string) ([]getter.CompatPlugin, error) {
|
||||||
// Handle sets a callback for a given capability. It is only used by network
|
// Handle sets a callback for a given capability. It is only used by network
|
||||||
// and ipam drivers during plugin registration. The callback registers the
|
// and ipam drivers during plugin registration. The callback registers the
|
||||||
// driver with the subsystem (network, ipam).
|
// driver with the subsystem (network, ipam).
|
||||||
func (ps Store) Handle(capability string, callback func(string, *plugins.Client)) {
|
func (ps *Store) Handle(capability string, callback func(string, *plugins.Client)) {
|
||||||
pluginType := fmt.Sprintf("docker.%s/1", strings.ToLower(capability))
|
pluginType := fmt.Sprintf("docker.%s/1", strings.ToLower(capability))
|
||||||
|
|
||||||
store := &ps
|
|
||||||
|
|
||||||
// Register callback with new plugin model.
|
// Register callback with new plugin model.
|
||||||
store.Lock()
|
ps.Lock()
|
||||||
store.handlers[pluginType] = callback
|
ps.handlers[pluginType] = callback
|
||||||
store.Unlock()
|
ps.Unlock()
|
||||||
|
|
||||||
// Register callback with legacy plugin model.
|
// Register callback with legacy plugin model.
|
||||||
if allowV1PluginsFallback {
|
if allowV1PluginsFallback {
|
||||||
|
|
Loading…
Reference in a new issue