1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

daemon: no map[string]bool from GetNetworkDriverList

No user of GetNetworkDriverList needs to access the map by key.
The only user of GetNetworkDriverList is in docker info and with a map
the network list is always flipping because loop is not deterministic.
Fix this by returning a string slice which instead is.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-07-23 19:57:53 +02:00
parent a110512e38
commit 7ca635a1ec
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
2 changed files with 13 additions and 13 deletions

View file

@ -175,12 +175,7 @@ func (daemon *Daemon) showPluginsInfo() types.PluginsInfo {
var pluginsInfo types.PluginsInfo var pluginsInfo types.PluginsInfo
pluginsInfo.Volume = volumedrivers.GetDriverList() pluginsInfo.Volume = volumedrivers.GetDriverList()
pluginsInfo.Network = daemon.GetNetworkDriverList()
networkDriverList := daemon.GetNetworkDriverList()
for nd := range networkDriverList {
pluginsInfo.Network = append(pluginsInfo.Network, nd)
}
pluginsInfo.Authorization = daemon.configStore.AuthorizationPlugins pluginsInfo.Authorization = daemon.configStore.AuthorizationPlugins
return pluginsInfo return pluginsInfo

View file

@ -3,6 +3,7 @@ package daemon
import ( import (
"fmt" "fmt"
"net" "net"
"sort"
"strings" "strings"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
@ -328,21 +329,25 @@ func (daemon *Daemon) DisconnectContainerFromNetwork(containerName string, netwo
// GetNetworkDriverList returns the list of plugins drivers // GetNetworkDriverList returns the list of plugins drivers
// registered for network. // registered for network.
func (daemon *Daemon) GetNetworkDriverList() map[string]bool { func (daemon *Daemon) GetNetworkDriverList() []string {
pluginList := make(map[string]bool) pluginList := []string{}
pluginMap := make(map[string]bool)
if !daemon.NetworkControllerEnabled() { if !daemon.NetworkControllerEnabled() {
return nil return nil
} }
c := daemon.netController networks := daemon.netController.Networks()
networks := c.Networks()
for _, network := range networks { for _, network := range networks {
driver := network.Type() if !pluginMap[network.Type()] {
pluginList[driver] = true pluginList = append(pluginList, network.Type())
pluginMap[network.Type()] = true
}
} }
// TODO : Replace this with proper libnetwork API // TODO : Replace this with proper libnetwork API
pluginList["overlay"] = true pluginList = append(pluginList, "overlay")
sort.Strings(pluginList)
return pluginList return pluginList
} }