Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
c18ecb08
Commit
c18ecb08
authored
Jul 25, 2017
by
Jing Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check volumespec is nil in FindPluginBySpec
This PR fixes issue #49513
parent
bb485466
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
plugins.go
pkg/volume/plugins.go
+4
-0
plugins_test.go
pkg/volume/plugins_test.go
+11
-0
No files found.
pkg/volume/plugins.go
View file @
c18ecb08
...
@@ -387,6 +387,10 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
...
@@ -387,6 +387,10 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
pm
.
mutex
.
Lock
()
pm
.
mutex
.
Lock
()
defer
pm
.
mutex
.
Unlock
()
defer
pm
.
mutex
.
Unlock
()
if
spec
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Could not find plugin because volume spec is nil"
)
}
matches
:=
[]
string
{}
matches
:=
[]
string
{}
for
k
,
v
:=
range
pm
.
plugins
{
for
k
,
v
:=
range
pm
.
plugins
{
if
v
.
CanSupport
(
spec
)
{
if
v
.
CanSupport
(
spec
)
{
...
...
pkg/volume/plugins_test.go
View file @
c18ecb08
...
@@ -112,6 +112,17 @@ func TestVolumePluginMgrFunc(t *testing.T) {
...
@@ -112,6 +112,17 @@ func TestVolumePluginMgrFunc(t *testing.T) {
if
plug
.
GetPluginName
()
!=
"testPlugin"
{
if
plug
.
GetPluginName
()
!=
"testPlugin"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
GetPluginName
())
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
)
{
func
Test_ValidatePodTemplate
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment