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
39a996ea
Commit
39a996ea
authored
Sep 18, 2017
by
xiangpengzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use const instead of hard code for volume plugin
parent
93ddb7be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
plugin.go
pkg/volume/flexvolume/plugin.go
+5
-2
plugins_test.go
pkg/volume/plugins_test.go
+5
-3
No files found.
pkg/volume/flexvolume/plugin.go
View file @
39a996ea
...
...
@@ -32,7 +32,10 @@ import (
"k8s.io/utils/exec"
)
const
flexVolumePluginName
=
"kubernetes.io/flexvolume"
const
(
flexVolumePluginName
=
"kubernetes.io/flexvolume"
flexVolumePluginNamePrefix
=
"flexvolume-"
)
// FlexVolumePlugin object.
type
flexVolumePlugin
struct
{
...
...
@@ -102,7 +105,7 @@ func (plugin *flexVolumePlugin) getExecutable() string {
// Name is part of the volume.VolumePlugin interface.
func
(
plugin
*
flexVolumePlugin
)
GetPluginName
()
string
{
return
"flexvolume-"
+
plugin
.
driverName
return
flexVolumePluginNamePrefix
+
plugin
.
driverName
}
// GetVolumeName is part of the volume.VolumePlugin interface.
...
...
pkg/volume/plugins_test.go
View file @
39a996ea
...
...
@@ -24,6 +24,8 @@ import (
"k8s.io/apimachinery/pkg/types"
)
const
testPluginName
=
"kubernetes.io/testPlugin"
func
TestSpecSourceConverters
(
t
*
testing
.
T
)
{
v
:=
&
v1
.
Volume
{
Name
:
"foo"
,
...
...
@@ -62,7 +64,7 @@ func (plugin *testPlugins) Init(host VolumeHost) error {
}
func
(
plugin
*
testPlugins
)
GetPluginName
()
string
{
return
"testPlugin"
return
testPluginName
}
func
(
plugin
*
testPlugins
)
GetVolumeName
(
spec
*
Spec
)
(
string
,
error
)
{
...
...
@@ -106,11 +108,11 @@ func TestVolumePluginMgrFunc(t *testing.T) {
var
prober
DynamicPluginProber
=
nil
// TODO (#51147) inject mock
vpm
.
InitPlugins
(
newTestPlugin
(),
prober
,
nil
)
plug
,
err
:=
vpm
.
FindPluginByName
(
"testPlugin"
)
plug
,
err
:=
vpm
.
FindPluginByName
(
testPluginName
)
if
err
!=
nil
{
t
.
Errorf
(
"Can't find the plugin by name"
)
}
if
plug
.
GetPluginName
()
!=
"testPlugin"
{
if
plug
.
GetPluginName
()
!=
testPluginName
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
GetPluginName
())
}
...
...
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