This is necessary for IPAM and network plugins.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
| ... | ... |
@@ -24,3 +24,10 @@ func (ps Store) GetAllByCap(capability string) ([]getter.CompatPlugin, error) {
|
| 24 | 24 |
func (ps Store) Get(name, capability string, _ int) (getter.CompatPlugin, error) {
|
| 25 | 25 |
return plugins.Get(name, capability) |
| 26 | 26 |
} |
| 27 |
+ |
|
| 28 |
+// Handle sets a callback for a given capability. It is only used by network |
|
| 29 |
+// and ipam drivers during plugin registration. The callback registers the |
|
| 30 |
+// driver with the subsystem (network, ipam). |
|
| 31 |
+func (ps *Store) Handle(capability string, callback func(string, *plugins.Client)) {
|
|
| 32 |
+ plugins.Handle(capability, callback) |
|
| 33 |
+} |
| ... | ... |
@@ -208,15 +208,13 @@ func (ps *Store) GetAllByCap(capability string) ([]getter.CompatPlugin, error) {
|
| 208 | 208 |
// Handle sets a callback for a given capability. It is only used by network |
| 209 | 209 |
// and ipam drivers during plugin registration. The callback registers the |
| 210 | 210 |
// driver with the subsystem (network, ipam). |
| 211 |
-func (ps Store) Handle(capability string, callback func(string, *plugins.Client)) {
|
|
| 211 |
+func (ps *Store) Handle(capability string, callback func(string, *plugins.Client)) {
|
|
| 212 | 212 |
pluginType := fmt.Sprintf("docker.%s/1", strings.ToLower(capability))
|
| 213 | 213 |
|
| 214 |
- store := &ps |
|
| 215 |
- |
|
| 216 | 214 |
// Register callback with new plugin model. |
| 217 |
- store.Lock() |
|
| 218 |
- store.handlers[pluginType] = callback |
|
| 219 |
- store.Unlock() |
|
| 215 |
+ ps.Lock() |
|
| 216 |
+ ps.handlers[pluginType] = callback |
|
| 217 |
+ ps.Unlock() |
|
| 220 | 218 |
|
| 221 | 219 |
// Register callback with legacy plugin model. |
| 222 | 220 |
if allowV1PluginsFallback {
|