mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #25036 from nishanttotla/describe-function-update-executor
Using map to list plugins in node description
This commit is contained in:
commit
301eba03e1
1 changed files with 10 additions and 5 deletions
|
@ -32,13 +32,13 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var plugins []api.PluginDescription
|
plugins := map[api.PluginDescription]struct{}{}
|
||||||
addPlugins := func(typ string, names []string) {
|
addPlugins := func(typ string, names []string) {
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
plugins = append(plugins, api.PluginDescription{
|
plugins[api.PluginDescription{
|
||||||
Type: typ,
|
Type: typ,
|
||||||
Name: name,
|
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("Network", append([]string{"overlay"}, info.Plugins.Network...))
|
||||||
addPlugins("Authorization", info.Plugins.Authorization)
|
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
|
// parse []string labels into a map[string]string
|
||||||
labels := map[string]string{}
|
labels := map[string]string{}
|
||||||
|
@ -70,7 +75,7 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
|
||||||
Engine: &api.EngineDescription{
|
Engine: &api.EngineDescription{
|
||||||
EngineVersion: info.ServerVersion,
|
EngineVersion: info.ServerVersion,
|
||||||
Labels: labels,
|
Labels: labels,
|
||||||
Plugins: plugins,
|
Plugins: pluginFields,
|
||||||
},
|
},
|
||||||
Resources: &api.Resources{
|
Resources: &api.Resources{
|
||||||
NanoCPUs: int64(info.NCPU) * 1e9,
|
NanoCPUs: int64(info.NCPU) * 1e9,
|
||||||
|
|
Loading…
Add table
Reference in a new issue