mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #109853 from ping035627/k8s-220506
Cleanup FindPluginBySpec() in VolumePluginMgr
This commit is contained in:
		@@ -662,34 +662,33 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
 | 
				
			|||||||
		return nil, fmt.Errorf("could not find plugin because volume spec is nil")
 | 
							return nil, fmt.Errorf("could not find plugin because volume spec is nil")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	matches := []VolumePlugin{}
 | 
						var match VolumePlugin
 | 
				
			||||||
 | 
						matchedPluginNames := []string{}
 | 
				
			||||||
	for _, v := range pm.plugins {
 | 
						for _, v := range pm.plugins {
 | 
				
			||||||
		if v.CanSupport(spec) {
 | 
							if v.CanSupport(spec) {
 | 
				
			||||||
			matches = append(matches, v)
 | 
								match = v
 | 
				
			||||||
 | 
								matchedPluginNames = append(matchedPluginNames, v.GetPluginName())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pm.refreshProbedPlugins()
 | 
						pm.refreshProbedPlugins()
 | 
				
			||||||
	for _, plugin := range pm.probedPlugins {
 | 
						for _, plugin := range pm.probedPlugins {
 | 
				
			||||||
		if plugin.CanSupport(spec) {
 | 
							if plugin.CanSupport(spec) {
 | 
				
			||||||
			matches = append(matches, plugin)
 | 
								match = plugin
 | 
				
			||||||
 | 
								matchedPluginNames = append(matchedPluginNames, plugin.GetPluginName())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(matches) == 0 {
 | 
						if len(matchedPluginNames) == 0 {
 | 
				
			||||||
		return nil, fmt.Errorf("no volume plugin matched")
 | 
							return nil, fmt.Errorf("no volume plugin matched")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(matches) > 1 {
 | 
						if len(matchedPluginNames) > 1 {
 | 
				
			||||||
		matchedPluginNames := []string{}
 | 
					 | 
				
			||||||
		for _, plugin := range matches {
 | 
					 | 
				
			||||||
			matchedPluginNames = append(matchedPluginNames, plugin.GetPluginName())
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return nil, fmt.Errorf("multiple volume plugins matched: %s", strings.Join(matchedPluginNames, ","))
 | 
							return nil, fmt.Errorf("multiple volume plugins matched: %s", strings.Join(matchedPluginNames, ","))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Issue warning if the matched provider is deprecated
 | 
						// Issue warning if the matched provider is deprecated
 | 
				
			||||||
	pm.logDeprecation(matches[0].GetPluginName())
 | 
						pm.logDeprecation(match.GetPluginName())
 | 
				
			||||||
	return matches[0], nil
 | 
						return match, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// FindPluginByName fetches a plugin by name or by legacy name.  If no plugin
 | 
					// FindPluginByName fetches a plugin by name or by legacy name.  If no plugin
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user