Add an ugly way to match whether network is ours to plugin

Docker Plugin V2 does not expose a plugin name to the plugin, so we
check for "net-plugin" within driver name of a network to detect
whether network is ours.
This commit is contained in:
Martynas Pumputis authored and Bryan Boreham committed 2017-04-12 13:05:40 +00:00
1 parent bdfa06dbe9
commit cfe26ae346
2 files changed
+29 -17

No files matched your search

+14 -14
View File
@@ -28,23 +28,23 @@ type network struct {
}
type driver struct {
name string
scope string
docker *docker.Client
dns bool
isPluginV2 bool
sync.RWMutex
networks map[string]network
scope string
docker *docker.Client
dns bool
isPluginV2 bool
networks map[string]network
isNetworkOur func(driverName string) bool
}
func New(client *docker.Client, weave *weaveapi.Client, name, scope string, dns, isPluginV2 bool) (skel.Driver, error) {
func New(client *docker.Client, weave *weaveapi.Client, scope string, dns, isPluginV2 bool, isNetworkOur func(string) bool) (skel.Driver, error) {
driver := &driver{
name: name,
scope: scope,
docker: client,
dns: dns,
isPluginV2: isPluginV2,
networks: make(map[string]network),
scope: scope,
docker: client,
dns: dns,
isPluginV2: isPluginV2,
networks: make(map[string]network),
isNetworkOur: isNetworkOur,
}
_, err := NewWatcher(client, weave, driver)
@@ -193,7 +193,7 @@ func (driver *driver) findNetworkInfo(id string) (network, error) {
if err != nil {
return network, err
}
return driver.setupNetworkInfo(id, info.Driver == driver.name, info.Options)
return driver.setupNetworkInfo(id, driver.isNetworkOur(info.Driver), info.Options)
}
func (driver *driver) setupNetworkInfo(id string, isOurs bool, options map[string]string) (network, error) {