소스 검색

Add Handle method to plugingetter.

This is necessary for IPAM and network plugins.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Anusha Ragunathan 8 년 전
부모
커밋
b3bd7f80af
3개의 변경된 파일12개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 0
      plugin/getter/interface.go
  2. 7 0
      plugin/store/store.go
  3. 4 6
      plugin/store/store_experimental.go

+ 1 - 0
plugin/getter/interface.go

@@ -22,4 +22,5 @@ type CompatPlugin interface {
 type PluginGetter interface {
 	Get(name, capability string, mode int) (CompatPlugin, error)
 	GetAllByCap(capability string) ([]CompatPlugin, error)
+	Handle(capability string, callback func(string, *plugins.Client))
 }

+ 7 - 0
plugin/store/store.go

@@ -24,3 +24,10 @@ func (ps Store) GetAllByCap(capability string) ([]getter.CompatPlugin, error) {
 func (ps Store) Get(name, capability string, _ int) (getter.CompatPlugin, error) {
 	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)
+}

+ 4 - 6
plugin/store/store_experimental.go

@@ -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
 // 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)) {
+func (ps *Store) Handle(capability string, callback func(string, *plugins.Client)) {
 	pluginType := fmt.Sprintf("docker.%s/1", strings.ToLower(capability))
 
-	store := &ps
-
 	// Register callback with new plugin model.
-	store.Lock()
-	store.handlers[pluginType] = callback
-	store.Unlock()
+	ps.Lock()
+	ps.handlers[pluginType] = callback
+	ps.Unlock()
 
 	// Register callback with legacy plugin model.
 	if allowV1PluginsFallback {