зеркало из https://github.com/microsoft/docker.git
Using map to list plugins in node description
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
This commit is contained in:
Родитель
ebb157ec46
Коммит
feedb7ab5a
|
@ -32,13 +32,13 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var plugins []api.PluginDescription
|
||||
plugins := map[api.PluginDescription]struct{}{}
|
||||
addPlugins := func(typ string, names []string) {
|
||||
for _, name := range names {
|
||||
plugins = append(plugins, api.PluginDescription{
|
||||
plugins[api.PluginDescription{
|
||||
Type: typ,
|
||||
Name: name,
|
||||
})
|
||||
}] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,12 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
|
|||
addPlugins("Network", append([]string{"overlay"}, info.Plugins.Network...))
|
||||
addPlugins("Authorization", info.Plugins.Authorization)
|
||||
|
||||
sort.Sort(sortedPlugins(plugins))
|
||||
pluginFields := make([]api.PluginDescription, 0, len(plugins))
|
||||
for k := range plugins {
|
||||
pluginFields = append(pluginFields, k)
|
||||
}
|
||||
|
||||
sort.Sort(sortedPlugins(pluginFields))
|
||||
|
||||
// parse []string labels into a map[string]string
|
||||
labels := map[string]string{}
|
||||
|
@ -70,7 +75,7 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
|
|||
Engine: &api.EngineDescription{
|
||||
EngineVersion: info.ServerVersion,
|
||||
Labels: labels,
|
||||
Plugins: plugins,
|
||||
Plugins: pluginFields,
|
||||
},
|
||||
Resources: &api.Resources{
|
||||
NanoCPUs: int64(info.NCPU) * 1e9,
|
||||
|
|
Загрузка…
Ссылка в новой задаче