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
ca9347f5
Unverified
Commit
ca9347f5
authored
May 13, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 13, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77838 from tedyu/matched-plugin
Move the array of plugin names to inside the last if block in VolumePluginMgr#FindPluginBySpec
parents
a60d2126
2001feea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
plugins.go
pkg/volume/plugins.go
+15
-11
No files found.
pkg/volume/plugins.go
View file @
ca9347f5
...
...
@@ -647,19 +647,16 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
return
nil
,
fmt
.
Errorf
(
"Could not find plugin because volume spec is nil"
)
}
matchedPluginNames
:=
[]
string
{}
matches
:=
[]
VolumePlugin
{}
for
k
,
v
:=
range
pm
.
plugins
{
for
_
,
v
:=
range
pm
.
plugins
{
if
v
.
CanSupport
(
spec
)
{
matchedPluginNames
=
append
(
matchedPluginNames
,
k
)
matches
=
append
(
matches
,
v
)
}
}
pm
.
refreshProbedPlugins
()
for
pluginName
,
plugin
:=
range
pm
.
probedPlugins
{
for
_
,
plugin
:=
range
pm
.
probedPlugins
{
if
plugin
.
CanSupport
(
spec
)
{
matchedPluginNames
=
append
(
matchedPluginNames
,
pluginName
)
matches
=
append
(
matches
,
plugin
)
}
}
...
...
@@ -668,6 +665,10 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
return
nil
,
fmt
.
Errorf
(
"no volume plugin matched"
)
}
if
len
(
matches
)
>
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
matches
[
0
],
nil
...
...
@@ -684,11 +685,9 @@ func (pm *VolumePluginMgr) IsPluginMigratableBySpec(spec *Spec) (bool, error) {
return
false
,
fmt
.
Errorf
(
"could not find if plugin is migratable because volume spec is nil"
)
}
matchedPluginNames
:=
[]
string
{}
matches
:=
[]
VolumePlugin
{}
for
k
,
v
:=
range
pm
.
plugins
{
for
_
,
v
:=
range
pm
.
plugins
{
if
v
.
CanSupport
(
spec
)
{
matchedPluginNames
=
append
(
matchedPluginNames
,
k
)
matches
=
append
(
matches
,
v
)
}
}
...
...
@@ -698,6 +697,10 @@ func (pm *VolumePluginMgr) IsPluginMigratableBySpec(spec *Spec) (bool, error) {
return
false
,
nil
}
if
len
(
matches
)
>
1
{
matchedPluginNames
:=
[]
string
{}
for
_
,
plugin
:=
range
matches
{
matchedPluginNames
=
append
(
matchedPluginNames
,
plugin
.
GetPluginName
())
}
return
false
,
fmt
.
Errorf
(
"multiple volume plugins matched: %s"
,
strings
.
Join
(
matchedPluginNames
,
","
))
}
...
...
@@ -711,16 +714,13 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
defer
pm
.
mutex
.
Unlock
()
// Once we can get rid of legacy names we can reduce this to a map lookup.
matchedPluginNames
:=
[]
string
{}
matches
:=
[]
VolumePlugin
{}
if
v
,
found
:=
pm
.
plugins
[
name
];
found
{
matchedPluginNames
=
append
(
matchedPluginNames
,
name
)
matches
=
append
(
matches
,
v
)
}
pm
.
refreshProbedPlugins
()
if
plugin
,
found
:=
pm
.
probedPlugins
[
name
];
found
{
matchedPluginNames
=
append
(
matchedPluginNames
,
name
)
matches
=
append
(
matches
,
plugin
)
}
...
...
@@ -728,6 +728,10 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
return
nil
,
fmt
.
Errorf
(
"no volume plugin matched"
)
}
if
len
(
matches
)
>
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
matches
[
0
],
nil
...
...
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