@@ -647,19 +647,16 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
647
647
return nil , fmt .Errorf ("Could not find plugin because volume spec is nil" )
648
648
}
649
649
650
- matchedPluginNames := []string {}
651
650
matches := []VolumePlugin {}
652
- for k , v := range pm .plugins {
651
+ for _ , v := range pm .plugins {
653
652
if v .CanSupport (spec ) {
654
- matchedPluginNames = append (matchedPluginNames , k )
655
653
matches = append (matches , v )
656
654
}
657
655
}
658
656
659
657
pm .refreshProbedPlugins ()
660
- for pluginName , plugin := range pm .probedPlugins {
658
+ for _ , plugin := range pm .probedPlugins {
661
659
if plugin .CanSupport (spec ) {
662
- matchedPluginNames = append (matchedPluginNames , pluginName )
663
660
matches = append (matches , plugin )
664
661
}
665
662
}
@@ -668,6 +665,10 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
668
665
return nil , fmt .Errorf ("no volume plugin matched" )
669
666
}
670
667
if len (matches ) > 1 {
668
+ matchedPluginNames := []string {}
669
+ for _ , plugin := range matches {
670
+ matchedPluginNames = append (matchedPluginNames , plugin .GetPluginName ())
671
+ }
671
672
return nil , fmt .Errorf ("multiple volume plugins matched: %s" , strings .Join (matchedPluginNames , "," ))
672
673
}
673
674
return matches [0 ], nil
@@ -684,11 +685,9 @@ func (pm *VolumePluginMgr) IsPluginMigratableBySpec(spec *Spec) (bool, error) {
684
685
return false , fmt .Errorf ("could not find if plugin is migratable because volume spec is nil" )
685
686
}
686
687
687
- matchedPluginNames := []string {}
688
688
matches := []VolumePlugin {}
689
- for k , v := range pm .plugins {
689
+ for _ , v := range pm .plugins {
690
690
if v .CanSupport (spec ) {
691
- matchedPluginNames = append (matchedPluginNames , k )
692
691
matches = append (matches , v )
693
692
}
694
693
}
@@ -698,6 +697,10 @@ func (pm *VolumePluginMgr) IsPluginMigratableBySpec(spec *Spec) (bool, error) {
698
697
return false , nil
699
698
}
700
699
if len (matches ) > 1 {
700
+ matchedPluginNames := []string {}
701
+ for _ , plugin := range matches {
702
+ matchedPluginNames = append (matchedPluginNames , plugin .GetPluginName ())
703
+ }
701
704
return false , fmt .Errorf ("multiple volume plugins matched: %s" , strings .Join (matchedPluginNames , "," ))
702
705
}
703
706
@@ -711,23 +714,24 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
711
714
defer pm .mutex .Unlock ()
712
715
713
716
// Once we can get rid of legacy names we can reduce this to a map lookup.
714
- matchedPluginNames := []string {}
715
717
matches := []VolumePlugin {}
716
718
if v , found := pm .plugins [name ]; found {
717
- matchedPluginNames = append (matchedPluginNames , name )
718
719
matches = append (matches , v )
719
720
}
720
721
721
722
pm .refreshProbedPlugins ()
722
723
if plugin , found := pm .probedPlugins [name ]; found {
723
- matchedPluginNames = append (matchedPluginNames , name )
724
724
matches = append (matches , plugin )
725
725
}
726
726
727
727
if len (matches ) == 0 {
728
728
return nil , fmt .Errorf ("no volume plugin matched" )
729
729
}
730
730
if len (matches ) > 1 {
731
+ matchedPluginNames := []string {}
732
+ for _ , plugin := range matches {
733
+ matchedPluginNames = append (matchedPluginNames , plugin .GetPluginName ())
734
+ }
731
735
return nil , fmt .Errorf ("multiple volume plugins matched: %s" , strings .Join (matchedPluginNames , "," ))
732
736
}
733
737
return matches [0 ], nil
0 commit comments