Skip to content

Commit cf1eeed

Browse files
author
caiweidong
committed
Use key in probedPlugin
1 parent ebe3255 commit cf1eeed

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

pkg/volume/plugins.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,9 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
657657
}
658658

659659
pm.refreshProbedPlugins()
660-
for _, plugin := range pm.probedPlugins {
660+
for pluginName, plugin := range pm.probedPlugins {
661661
if plugin.CanSupport(spec) {
662-
matchedPluginNames = append(matchedPluginNames, plugin.GetPluginName())
662+
matchedPluginNames = append(matchedPluginNames, pluginName)
663663
matches = append(matches, plugin)
664664
}
665665
}
@@ -713,19 +713,15 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
713713
// Once we can get rid of legacy names we can reduce this to a map lookup.
714714
matchedPluginNames := []string{}
715715
matches := []VolumePlugin{}
716-
for k, v := range pm.plugins {
717-
if v.GetPluginName() == name {
718-
matchedPluginNames = append(matchedPluginNames, k)
719-
matches = append(matches, v)
720-
}
716+
if v, found := pm.plugins[name]; found {
717+
matchedPluginNames = append(matchedPluginNames, name)
718+
matches = append(matches, v)
721719
}
722720

723721
pm.refreshProbedPlugins()
724-
for _, plugin := range pm.probedPlugins {
725-
if plugin.GetPluginName() == name {
726-
matchedPluginNames = append(matchedPluginNames, plugin.GetPluginName())
727-
matches = append(matches, plugin)
728-
}
722+
if plugin, found := pm.probedPlugins[name]; found {
723+
matchedPluginNames = append(matchedPluginNames, name)
724+
matches = append(matches, plugin)
729725
}
730726

731727
if len(matches) == 0 {

0 commit comments

Comments
 (0)