Merge pull request #77537 from cwdsuzhou/use_key_in_lugins

Use key in probedPlugin
This commit is contained in:
Kubernetes Prow Robot 2019-05-08 20:13:01 -07:00 committed by GitHub
commit c2966f7c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -657,9 +657,9 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
}
pm.refreshProbedPlugins()
for _, plugin := range pm.probedPlugins {
for pluginName, plugin := range pm.probedPlugins {
if plugin.CanSupport(spec) {
matchedPluginNames = append(matchedPluginNames, plugin.GetPluginName())
matchedPluginNames = append(matchedPluginNames, pluginName)
matches = append(matches, plugin)
}
}
@ -713,20 +713,16 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
// Once we can get rid of legacy names we can reduce this to a map lookup.
matchedPluginNames := []string{}
matches := []VolumePlugin{}
for k, v := range pm.plugins {
if v.GetPluginName() == name {
matchedPluginNames = append(matchedPluginNames, k)
if v, found := pm.plugins[name]; found {
matchedPluginNames = append(matchedPluginNames, name)
matches = append(matches, v)
}
}
pm.refreshProbedPlugins()
for _, plugin := range pm.probedPlugins {
if plugin.GetPluginName() == name {
matchedPluginNames = append(matchedPluginNames, plugin.GetPluginName())
if plugin, found := pm.probedPlugins[name]; found {
matchedPluginNames = append(matchedPluginNames, name)
matches = append(matches, plugin)
}
}
if len(matches) == 0 {
return nil, fmt.Errorf("no volume plugin matched")