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
2001feea
Commit
2001feea
authored
May 14, 2019
by
Ted Yu
Committed by
Ted Yu
May 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the array of plugin names to inside the last if block in VolumePluginMgr#FindPluginBySpec
parent
21bec91e
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 @
2001feea
...
@@ -647,19 +647,16 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
...
@@ -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"
)
return
nil
,
fmt
.
Errorf
(
"Could not find plugin because volume spec is nil"
)
}
}
matchedPluginNames
:=
[]
string
{}
matches
:=
[]
VolumePlugin
{}
matches
:=
[]
VolumePlugin
{}
for
k
,
v
:=
range
pm
.
plugins
{
for
_
,
v
:=
range
pm
.
plugins
{
if
v
.
CanSupport
(
spec
)
{
if
v
.
CanSupport
(
spec
)
{
matchedPluginNames
=
append
(
matchedPluginNames
,
k
)
matches
=
append
(
matches
,
v
)
matches
=
append
(
matches
,
v
)
}
}
}
}
pm
.
refreshProbedPlugins
()
pm
.
refreshProbedPlugins
()
for
pluginName
,
plugin
:=
range
pm
.
probedPlugins
{
for
_
,
plugin
:=
range
pm
.
probedPlugins
{
if
plugin
.
CanSupport
(
spec
)
{
if
plugin
.
CanSupport
(
spec
)
{
matchedPluginNames
=
append
(
matchedPluginNames
,
pluginName
)
matches
=
append
(
matches
,
plugin
)
matches
=
append
(
matches
,
plugin
)
}
}
}
}
...
@@ -668,6 +665,10 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
...
@@ -668,6 +665,10 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
return
nil
,
fmt
.
Errorf
(
"no volume plugin matched"
)
return
nil
,
fmt
.
Errorf
(
"no volume plugin matched"
)
}
}
if
len
(
matches
)
>
1
{
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
nil
,
fmt
.
Errorf
(
"multiple volume plugins matched: %s"
,
strings
.
Join
(
matchedPluginNames
,
","
))
}
}
return
matches
[
0
],
nil
return
matches
[
0
],
nil
...
@@ -684,11 +685,9 @@ func (pm *VolumePluginMgr) IsPluginMigratableBySpec(spec *Spec) (bool, error) {
...
@@ -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"
)
return
false
,
fmt
.
Errorf
(
"could not find if plugin is migratable because volume spec is nil"
)
}
}
matchedPluginNames
:=
[]
string
{}
matches
:=
[]
VolumePlugin
{}
matches
:=
[]
VolumePlugin
{}
for
k
,
v
:=
range
pm
.
plugins
{
for
_
,
v
:=
range
pm
.
plugins
{
if
v
.
CanSupport
(
spec
)
{
if
v
.
CanSupport
(
spec
)
{
matchedPluginNames
=
append
(
matchedPluginNames
,
k
)
matches
=
append
(
matches
,
v
)
matches
=
append
(
matches
,
v
)
}
}
}
}
...
@@ -698,6 +697,10 @@ func (pm *VolumePluginMgr) IsPluginMigratableBySpec(spec *Spec) (bool, error) {
...
@@ -698,6 +697,10 @@ func (pm *VolumePluginMgr) IsPluginMigratableBySpec(spec *Spec) (bool, error) {
return
false
,
nil
return
false
,
nil
}
}
if
len
(
matches
)
>
1
{
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
,
","
))
return
false
,
fmt
.
Errorf
(
"multiple volume plugins matched: %s"
,
strings
.
Join
(
matchedPluginNames
,
","
))
}
}
...
@@ -711,16 +714,13 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
...
@@ -711,16 +714,13 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
defer
pm
.
mutex
.
Unlock
()
defer
pm
.
mutex
.
Unlock
()
// Once we can get rid of legacy names we can reduce this to a map lookup.
// Once we can get rid of legacy names we can reduce this to a map lookup.
matchedPluginNames
:=
[]
string
{}
matches
:=
[]
VolumePlugin
{}
matches
:=
[]
VolumePlugin
{}
if
v
,
found
:=
pm
.
plugins
[
name
];
found
{
if
v
,
found
:=
pm
.
plugins
[
name
];
found
{
matchedPluginNames
=
append
(
matchedPluginNames
,
name
)
matches
=
append
(
matches
,
v
)
matches
=
append
(
matches
,
v
)
}
}
pm
.
refreshProbedPlugins
()
pm
.
refreshProbedPlugins
()
if
plugin
,
found
:=
pm
.
probedPlugins
[
name
];
found
{
if
plugin
,
found
:=
pm
.
probedPlugins
[
name
];
found
{
matchedPluginNames
=
append
(
matchedPluginNames
,
name
)
matches
=
append
(
matches
,
plugin
)
matches
=
append
(
matches
,
plugin
)
}
}
...
@@ -728,6 +728,10 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
...
@@ -728,6 +728,10 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
return
nil
,
fmt
.
Errorf
(
"no volume plugin matched"
)
return
nil
,
fmt
.
Errorf
(
"no volume plugin matched"
)
}
}
if
len
(
matches
)
>
1
{
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
nil
,
fmt
.
Errorf
(
"multiple volume plugins matched: %s"
,
strings
.
Join
(
matchedPluginNames
,
","
))
}
}
return
matches
[
0
],
nil
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