Browse code

sort volume drivers and auth plugins in info response

Signed-off-by: allencloud <allen.sun@daocloud.io>

allencloud authored on 2017/01/22 15:59:29
Showing 3 changed files
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"io"
9 9
 	"io/ioutil"
10 10
 	"runtime"
11
+	"sort"
11 12
 	"strings"
12 13
 	"sync"
13 14
 
... ...
@@ -523,3 +524,16 @@ func ValidateConfiguration(config *Config) error {
523 523
 
524 524
 	return nil
525 525
 }
526
+
527
+// GetAuthorizationPlugins returns daemon's sorted authorization plugins
528
+func (config *Config) GetAuthorizationPlugins() []string {
529
+	config.reloadLock.Lock()
530
+	defer config.reloadLock.Unlock()
531
+
532
+	authPlugins := make([]string, 0, len(config.AuthorizationPlugins))
533
+	for _, p := range config.AuthorizationPlugins {
534
+		authPlugins = append(authPlugins, p)
535
+	}
536
+	sort.Strings(authPlugins)
537
+	return authPlugins
538
+}
... ...
@@ -174,7 +174,7 @@ func (daemon *Daemon) showPluginsInfo() types.PluginsInfo {
174 174
 
175 175
 	pluginsInfo.Volume = volumedrivers.GetDriverList()
176 176
 	pluginsInfo.Network = daemon.GetNetworkDriverList()
177
-	pluginsInfo.Authorization = daemon.configStore.AuthorizationPlugins
177
+	pluginsInfo.Authorization = daemon.configStore.GetAuthorizationPlugins()
178 178
 
179 179
 	return pluginsInfo
180 180
 }
... ...
@@ -4,6 +4,7 @@ package volumedrivers
4 4
 
5 5
 import (
6 6
 	"fmt"
7
+	"sort"
7 8
 	"sync"
8 9
 
9 10
 	"github.com/docker/docker/pkg/locker"
... ...
@@ -176,6 +177,7 @@ func GetDriverList() []string {
176 176
 		driverList = append(driverList, driverName)
177 177
 	}
178 178
 	drivers.Unlock()
179
+	sort.Strings(driverList)
179 180
 	return driverList
180 181
 }
181 182