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>
| ... | ... |
@@ -175,12 +175,7 @@ func (daemon *Daemon) showPluginsInfo() types.PluginsInfo {
|
| 175 | 175 |
var pluginsInfo types.PluginsInfo |
| 176 | 176 |
|
| 177 | 177 |
pluginsInfo.Volume = volumedrivers.GetDriverList() |
| 178 |
- |
|
| 179 |
- networkDriverList := daemon.GetNetworkDriverList() |
|
| 180 |
- for nd := range networkDriverList {
|
|
| 181 |
- pluginsInfo.Network = append(pluginsInfo.Network, nd) |
|
| 182 |
- } |
|
| 183 |
- |
|
| 178 |
+ pluginsInfo.Network = daemon.GetNetworkDriverList() |
|
| 184 | 179 |
pluginsInfo.Authorization = daemon.configStore.AuthorizationPlugins |
| 185 | 180 |
|
| 186 | 181 |
return pluginsInfo |
| ... | ... |
@@ -3,6 +3,7 @@ package daemon |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"net" |
| 6 |
+ "sort" |
|
| 6 | 7 |
"strings" |
| 7 | 8 |
|
| 8 | 9 |
"github.com/Sirupsen/logrus" |
| ... | ... |
@@ -328,21 +329,25 @@ func (daemon *Daemon) DisconnectContainerFromNetwork(containerName string, netwo |
| 328 | 328 |
|
| 329 | 329 |
// GetNetworkDriverList returns the list of plugins drivers |
| 330 | 330 |
// registered for network. |
| 331 |
-func (daemon *Daemon) GetNetworkDriverList() map[string]bool {
|
|
| 332 |
- pluginList := make(map[string]bool) |
|
| 331 |
+func (daemon *Daemon) GetNetworkDriverList() []string {
|
|
| 332 |
+ pluginList := []string{}
|
|
| 333 |
+ pluginMap := make(map[string]bool) |
|
| 333 | 334 |
|
| 334 | 335 |
if !daemon.NetworkControllerEnabled() {
|
| 335 | 336 |
return nil |
| 336 | 337 |
} |
| 337 |
- c := daemon.netController |
|
| 338 |
- networks := c.Networks() |
|
| 338 |
+ networks := daemon.netController.Networks() |
|
| 339 | 339 |
|
| 340 | 340 |
for _, network := range networks {
|
| 341 |
- driver := network.Type() |
|
| 342 |
- pluginList[driver] = true |
|
| 341 |
+ if !pluginMap[network.Type()] {
|
|
| 342 |
+ pluginList = append(pluginList, network.Type()) |
|
| 343 |
+ pluginMap[network.Type()] = true |
|
| 344 |
+ } |
|
| 343 | 345 |
} |
| 344 | 346 |
// TODO : Replace this with proper libnetwork API |
| 345 |
- pluginList["overlay"] = true |
|
| 347 |
+ pluginList = append(pluginList, "overlay") |
|
| 348 |
+ |
|
| 349 |
+ sort.Strings(pluginList) |
|
| 346 | 350 |
|
| 347 | 351 |
return pluginList |
| 348 | 352 |
} |