Browse code

Sort plugin names in node description

Signed-off-by: Nishant Totla <nishanttotla@gmail.com>

Nishant Totla authored on 2016/07/26 02:38:24
Showing 1 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 package container
2 2
 
3 3
 import (
4
+	"sort"
4 5
 	"strings"
5 6
 
6 7
 	executorpkg "github.com/docker/docker/daemon/cluster/executor"
... ...
@@ -47,6 +48,8 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
47 47
 	addPlugins("Network", append([]string{"overlay"}, info.Plugins.Network...))
48 48
 	addPlugins("Authorization", info.Plugins.Authorization)
49 49
 
50
+	sort.Sort(sortedPlugins(plugins))
51
+
50 52
 	// parse []string labels into a map[string]string
51 53
 	labels := map[string]string{}
52 54
 	for _, l := range info.Labels {
... ...
@@ -137,3 +140,16 @@ func (e *executor) SetNetworkBootstrapKeys(keys []*api.EncryptionKey) error {
137 137
 
138 138
 	return nil
139 139
 }
140
+
141
+type sortedPlugins []api.PluginDescription
142
+
143
+func (sp sortedPlugins) Len() int { return len(sp) }
144
+
145
+func (sp sortedPlugins) Swap(i, j int) { sp[i], sp[j] = sp[j], sp[i] }
146
+
147
+func (sp sortedPlugins) Less(i, j int) bool {
148
+	if sp[i].Type != sp[j].Type {
149
+		return sp[i].Type < sp[j].Type
150
+	}
151
+	return sp[i].Name < sp[j].Name
152
+}