mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #49596 from jingxu97/July/checkVolumeSpecNil
Automatic merge from submit-queue Check volumespec is nil in FindPluginBySpec
This commit is contained in:
commit
9c508f12fb
@ -387,6 +387,10 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
|
||||
pm.mutex.Lock()
|
||||
defer pm.mutex.Unlock()
|
||||
|
||||
if spec == nil {
|
||||
return nil, fmt.Errorf("Could not find plugin because volume spec is nil")
|
||||
}
|
||||
|
||||
matches := []string{}
|
||||
for k, v := range pm.plugins {
|
||||
if v.CanSupport(spec) {
|
||||
|
@ -112,6 +112,17 @@ func TestVolumePluginMgrFunc(t *testing.T) {
|
||||
if plug.GetPluginName() != "testPlugin" {
|
||||
t.Errorf("Wrong name: %s", plug.GetPluginName())
|
||||
}
|
||||
|
||||
plug, err = vpm.FindPluginBySpec(nil)
|
||||
if err == nil {
|
||||
t.Errorf("Should return error if volume spec is nil")
|
||||
}
|
||||
|
||||
volumeSpec := &Spec{}
|
||||
plug, err = vpm.FindPluginBySpec(volumeSpec)
|
||||
if err != nil {
|
||||
t.Errorf("Should return test plugin if volume spec is not nil")
|
||||
}
|
||||
}
|
||||
|
||||
func Test_ValidatePodTemplate(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user