summaryrefslogtreecommitdiff
path: root/libnetwork/drvregistry
diff options
context:
space:
mode:
authorAnusha Ragunathan <anusha@docker.com>2016-09-27 13:54:25 -0700
committerAnusha Ragunathan <anusha@docker.com>2016-09-27 15:29:10 -0700
commit003e04775b1a937e2cfb1f0c25c6406141e3a14b (patch)
tree6dcf3fb1741ce279b5fe9fadd3c954fbb78ea204 /libnetwork/drvregistry
parent952520472ff018ba9745a67620cc0bf8ce6267c8 (diff)
downloaddocker-003e04775b1a937e2cfb1f0c25c6406141e3a14b.tar.gz
Make libnetwork understand pluginv2.
As part of daemon init, network and ipam drivers are passed a pluginstore object that implements the plugin/getter interface. Use this interface methods in libnetwork to interact with network plugins. This interface provides the new and improved pluginv2 functionality and falls back to pluginv1 (legacy) if necessary. Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Diffstat (limited to 'libnetwork/drvregistry')
-rw-r--r--libnetwork/drvregistry/drvregistry.go26
-rw-r--r--libnetwork/drvregistry/drvregistry_test.go2
2 files changed, 18 insertions, 10 deletions
diff --git a/libnetwork/drvregistry/drvregistry.go b/libnetwork/drvregistry/drvregistry.go
index d2cf781193..af4dee4264 100644
--- a/libnetwork/drvregistry/drvregistry.go
+++ b/libnetwork/drvregistry/drvregistry.go
@@ -5,6 +5,7 @@ import (
"strings"
"sync"
+ "github.com/docker/docker/plugin/getter"
"github.com/docker/libnetwork/driverapi"
"github.com/docker/libnetwork/ipamapi"
"github.com/docker/libnetwork/types"
@@ -28,10 +29,11 @@ type ipamTable map[string]*ipamData
// DrvRegistry holds the registry of all network drivers and IPAM drivers that it knows about.
type DrvRegistry struct {
sync.Mutex
- drivers driverTable
- ipamDrivers ipamTable
- dfn DriverNotifyFunc
- ifn IPAMNotifyFunc
+ drivers driverTable
+ ipamDrivers ipamTable
+ dfn DriverNotifyFunc
+ ifn IPAMNotifyFunc
+ pluginGetter getter.PluginGetter
}
// Functors definition
@@ -52,12 +54,13 @@ type IPAMNotifyFunc func(name string, driver ipamapi.Ipam, cap *ipamapi.Capabili
type DriverNotifyFunc func(name string, driver driverapi.Driver, capability driverapi.Capability) error
// New retruns a new driver registry handle.
-func New(lDs, gDs interface{}, dfn DriverNotifyFunc, ifn IPAMNotifyFunc) (*DrvRegistry, error) {
+func New(lDs, gDs interface{}, dfn DriverNotifyFunc, ifn IPAMNotifyFunc, pg getter.PluginGetter) (*DrvRegistry, error) {
r := &DrvRegistry{
- drivers: make(driverTable),
- ipamDrivers: make(ipamTable),
- dfn: dfn,
- ifn: ifn,
+ drivers: make(driverTable),
+ ipamDrivers: make(ipamTable),
+ dfn: dfn,
+ ifn: ifn,
+ pluginGetter: pg,
}
return r, nil
@@ -149,6 +152,11 @@ func (r *DrvRegistry) IPAMDefaultAddressSpaces(name string) (string, string, err
return i.defaultLocalAddressSpace, i.defaultGlobalAddressSpace, nil
}
+// GetPluginGetter returns the plugingetter
+func (r *DrvRegistry) GetPluginGetter() getter.PluginGetter {
+ return r.pluginGetter
+}
+
// RegisterDriver registers the network driver when it gets discovered.
func (r *DrvRegistry) RegisterDriver(ntype string, driver driverapi.Driver, capability driverapi.Capability) error {
if strings.TrimSpace(ntype) == "" {
diff --git a/libnetwork/drvregistry/drvregistry_test.go b/libnetwork/drvregistry/drvregistry_test.go
index 0b1f7a6843..e52e28c28b 100644
--- a/libnetwork/drvregistry/drvregistry_test.go
+++ b/libnetwork/drvregistry/drvregistry_test.go
@@ -88,7 +88,7 @@ func (m *mockDriver) EventNotify(etype driverapi.EventType, nid, tableName, key
}
func getNew(t *testing.T) *DrvRegistry {
- reg, err := New(nil, nil, nil, nil)
+ reg, err := New(nil, nil, nil, nil, nil)
if err != nil {
t.Fatal(err)
}