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
cd359ffa
Commit
cd359ffa
authored
May 10, 2015
by
Paul Morie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor volume interfaces to receive pod instead of ObjectReference
parent
738f403e
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
93 additions
and
88 deletions
+93
-88
volumes.go
pkg/kubelet/volumes.go
+5
-11
aws_ebs.go
pkg/volume/aws_ebs/aws_ebs.go
+2
-2
empty_dir.go
pkg/volume/empty_dir/empty_dir.go
+4
-4
empty_dir_test.go
pkg/volume/empty_dir/empty_dir_test.go
+8
-4
gce_pd.go
pkg/volume/gce_pd/gce_pd.go
+2
-2
gce_pd_test.go
pkg/volume/gce_pd/gce_pd_test.go
+2
-1
git_repo.go
pkg/volume/git_repo/git_repo.go
+8
-8
git_repo_test.go
pkg/volume/git_repo/git_repo_test.go
+4
-2
glusterfs.go
pkg/volume/glusterfs/glusterfs.go
+8
-8
glusterfs_test.go
pkg/volume/glusterfs/glusterfs_test.go
+2
-1
host_path.go
pkg/volume/host_path/host_path.go
+1
-1
host_path_test.go
pkg/volume/host_path/host_path_test.go
+2
-1
iscsi.go
pkg/volume/iscsi/iscsi.go
+2
-2
nfs.go
pkg/volume/nfs/nfs.go
+7
-7
nfs_test.go
pkg/volume/nfs/nfs_test.go
+2
-1
persistent_claim.go
pkg/volume/persistent_claim/persistent_claim.go
+3
-3
persistent_claim_test.go
pkg/volume/persistent_claim/persistent_claim_test.go
+4
-2
plugins.go
pkg/volume/plugins.go
+3
-3
secret.go
pkg/volume/secret/secret.go
+16
-18
secret_test.go
pkg/volume/secret/secret_test.go
+4
-3
testing.go
pkg/volume/testing.go
+4
-4
No files found.
pkg/kubelet/volumes.go
View file @
cd359ffa
...
@@ -56,8 +56,8 @@ func (vh *volumeHost) GetKubeClient() client.Interface {
...
@@ -56,8 +56,8 @@ func (vh *volumeHost) GetKubeClient() client.Interface {
return
vh
.
kubelet
.
kubeClient
return
vh
.
kubelet
.
kubeClient
}
}
func
(
vh
*
volumeHost
)
NewWrapperBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
vh
*
volumeHost
)
NewWrapperBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
b
,
err
:=
vh
.
kubelet
.
newVolumeBuilderFromPlugins
(
spec
,
pod
Ref
,
opts
,
mounter
)
b
,
err
:=
vh
.
kubelet
.
newVolumeBuilderFromPlugins
(
spec
,
pod
,
opts
,
mounter
)
if
err
==
nil
&&
b
==
nil
{
if
err
==
nil
&&
b
==
nil
{
return
nil
,
errUnsupportedVolumeType
return
nil
,
errUnsupportedVolumeType
}
}
...
@@ -80,7 +80,7 @@ func (vh *volumeHost) NewWrapperCleaner(spec *volume.Spec, podUID types.UID, mou
...
@@ -80,7 +80,7 @@ func (vh *volumeHost) NewWrapperCleaner(spec *volume.Spec, podUID types.UID, mou
return
c
,
nil
return
c
,
nil
}
}
func
(
kl
*
Kubelet
)
newVolumeBuilderFromPlugins
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
kl
*
Kubelet
)
newVolumeBuilderFromPlugins
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
plugin
,
err
:=
kl
.
volumePluginMgr
.
FindPluginBySpec
(
spec
)
plugin
,
err
:=
kl
.
volumePluginMgr
.
FindPluginBySpec
(
spec
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"can't use volume plugins for %s: %v"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
),
err
)
return
nil
,
fmt
.
Errorf
(
"can't use volume plugins for %s: %v"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
),
err
)
...
@@ -89,7 +89,7 @@ func (kl *Kubelet) newVolumeBuilderFromPlugins(spec *volume.Spec, podRef *api.Ob
...
@@ -89,7 +89,7 @@ func (kl *Kubelet) newVolumeBuilderFromPlugins(spec *volume.Spec, podRef *api.Ob
// Not found but not an error
// Not found but not an error
return
nil
,
nil
return
nil
,
nil
}
}
builder
,
err
:=
plugin
.
NewBuilder
(
spec
,
pod
Ref
,
opts
,
mounter
)
builder
,
err
:=
plugin
.
NewBuilder
(
spec
,
pod
,
opts
,
mounter
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to instantiate volume plugin for %s: %v"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
),
err
)
return
nil
,
fmt
.
Errorf
(
"failed to instantiate volume plugin for %s: %v"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
),
err
)
}
}
...
@@ -102,12 +102,6 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.Pod) (kubecontainer.VolumeMap,
...
@@ -102,12 +102,6 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.Pod) (kubecontainer.VolumeMap,
for
i
:=
range
pod
.
Spec
.
Volumes
{
for
i
:=
range
pod
.
Spec
.
Volumes
{
volSpec
:=
&
pod
.
Spec
.
Volumes
[
i
]
volSpec
:=
&
pod
.
Spec
.
Volumes
[
i
]
podRef
,
err
:=
api
.
GetReference
(
pod
)
if
err
!=
nil
{
glog
.
Errorf
(
"Error getting object reference for pod: %v"
,
pod
,
err
)
return
nil
,
err
}
rootContext
,
err
:=
kl
.
getRootDirContext
()
rootContext
,
err
:=
kl
.
getRootDirContext
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -115,7 +109,7 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.Pod) (kubecontainer.VolumeMap,
...
@@ -115,7 +109,7 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.Pod) (kubecontainer.VolumeMap,
// Try to use a plugin for this volume.
// Try to use a plugin for this volume.
internal
:=
volume
.
NewSpecFromVolume
(
volSpec
)
internal
:=
volume
.
NewSpecFromVolume
(
volSpec
)
builder
,
err
:=
kl
.
newVolumeBuilderFromPlugins
(
internal
,
pod
Ref
,
volume
.
VolumeOptions
{
rootContext
},
kl
.
mounter
)
builder
,
err
:=
kl
.
newVolumeBuilderFromPlugins
(
internal
,
pod
,
volume
.
VolumeOptions
{
rootContext
},
kl
.
mounter
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Could not create volume builder for pod %s: %v"
,
pod
.
UID
,
err
)
glog
.
Errorf
(
"Could not create volume builder for pod %s: %v"
,
pod
.
UID
,
err
)
return
nil
,
err
return
nil
,
err
...
...
pkg/volume/aws_ebs/aws_ebs.go
View file @
cd359ffa
...
@@ -68,9 +68,9 @@ func (plugin *awsElasticBlockStorePlugin) GetAccessModes() []api.AccessModeType
...
@@ -68,9 +68,9 @@ func (plugin *awsElasticBlockStorePlugin) GetAccessModes() []api.AccessModeType
}
}
}
}
func
(
plugin
*
awsElasticBlockStorePlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
awsElasticBlockStorePlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
// Inject real implementations here, test through the internal function.
// Inject real implementations here, test through the internal function.
return
plugin
.
newBuilderInternal
(
spec
,
pod
Ref
.
UID
,
&
AWSDiskUtil
{},
mounter
)
return
plugin
.
newBuilderInternal
(
spec
,
pod
.
UID
,
&
AWSDiskUtil
{},
mounter
)
}
}
func
(
plugin
*
awsElasticBlockStorePlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
pdManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
awsElasticBlockStorePlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
pdManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
...
...
pkg/volume/empty_dir/empty_dir.go
View file @
cd359ffa
...
@@ -71,11 +71,11 @@ func (plugin *emptyDirPlugin) CanSupport(spec *volume.Spec) bool {
...
@@ -71,11 +71,11 @@ func (plugin *emptyDirPlugin) CanSupport(spec *volume.Spec) bool {
return
false
return
false
}
}
func
(
plugin
*
emptyDirPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
emptyDirPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
return
plugin
.
newBuilderInternal
(
spec
,
pod
Ref
,
mounter
,
&
realMountDetector
{
mounter
},
opts
)
return
plugin
.
newBuilderInternal
(
spec
,
pod
,
mounter
,
&
realMountDetector
{
mounter
},
opts
)
}
}
func
(
plugin
*
emptyDirPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
mounter
mount
.
Interface
,
mountDetector
mountDetector
,
opts
volume
.
VolumeOptions
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
emptyDirPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
mounter
mount
.
Interface
,
mountDetector
mountDetector
,
opts
volume
.
VolumeOptions
)
(
volume
.
Builder
,
error
)
{
if
plugin
.
legacyMode
{
if
plugin
.
legacyMode
{
// Legacy mode instances can be cleaned up but not created anew.
// Legacy mode instances can be cleaned up but not created anew.
return
nil
,
fmt
.
Errorf
(
"legacy mode: can not create new instances"
)
return
nil
,
fmt
.
Errorf
(
"legacy mode: can not create new instances"
)
...
@@ -85,7 +85,7 @@ func (plugin *emptyDirPlugin) newBuilderInternal(spec *volume.Spec, podRef *api.
...
@@ -85,7 +85,7 @@ func (plugin *emptyDirPlugin) newBuilderInternal(spec *volume.Spec, podRef *api.
medium
=
spec
.
VolumeSource
.
EmptyDir
.
Medium
medium
=
spec
.
VolumeSource
.
EmptyDir
.
Medium
}
}
return
&
emptyDir
{
return
&
emptyDir
{
podUID
:
pod
Ref
.
UID
,
podUID
:
pod
.
UID
,
volName
:
spec
.
Name
,
volName
:
spec
.
Name
,
medium
:
medium
,
medium
:
medium
,
mounter
:
mounter
,
mounter
:
mounter
,
...
...
pkg/volume/empty_dir/empty_dir_test.go
View file @
cd359ffa
...
@@ -74,7 +74,8 @@ func TestPlugin(t *testing.T) {
...
@@ -74,7 +74,8 @@ func TestPlugin(t *testing.T) {
}
}
mounter
:=
mount
.
FakeMounter
{}
mounter
:=
mount
.
FakeMounter
{}
mountDetector
:=
fakeMountDetector
{}
mountDetector
:=
fakeMountDetector
{}
builder
,
err
:=
plug
.
(
*
emptyDirPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
spec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
&
mounter
,
&
mountDetector
,
volume
.
VolumeOptions
{
""
})
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
(
*
emptyDirPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
spec
),
pod
,
&
mounter
,
&
mountDetector
,
volume
.
VolumeOptions
{
""
})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -133,7 +134,8 @@ func TestPluginTmpfs(t *testing.T) {
...
@@ -133,7 +134,8 @@ func TestPluginTmpfs(t *testing.T) {
}
}
mounter
:=
mount
.
FakeMounter
{}
mounter
:=
mount
.
FakeMounter
{}
mountDetector
:=
fakeMountDetector
{}
mountDetector
:=
fakeMountDetector
{}
builder
,
err
:=
plug
.
(
*
emptyDirPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
spec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
&
mounter
,
&
mountDetector
,
volume
.
VolumeOptions
{
""
})
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
(
*
emptyDirPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
spec
),
pod
,
&
mounter
,
&
mountDetector
,
volume
.
VolumeOptions
{
""
})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -197,7 +199,8 @@ func TestPluginBackCompat(t *testing.T) {
...
@@ -197,7 +199,8 @@ func TestPluginBackCompat(t *testing.T) {
spec
:=
&
api
.
Volume
{
spec
:=
&
api
.
Volume
{
Name
:
"vol1"
,
Name
:
"vol1"
,
}
}
builder
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
volume
.
VolumeOptions
{
""
},
nil
)
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
pod
,
volume
.
VolumeOptions
{
""
},
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -222,7 +225,8 @@ func TestPluginLegacy(t *testing.T) {
...
@@ -222,7 +225,8 @@ func TestPluginLegacy(t *testing.T) {
}
}
spec
:=
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}
spec
:=
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}
if
_
,
err
:=
plug
.
(
*
emptyDirPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
&
spec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
&
mount
.
FakeMounter
{},
&
fakeMountDetector
{},
volume
.
VolumeOptions
{
""
});
err
==
nil
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
if
_
,
err
:=
plug
.
(
*
emptyDirPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
&
spec
),
pod
,
&
mount
.
FakeMounter
{},
&
fakeMountDetector
{},
volume
.
VolumeOptions
{
""
});
err
==
nil
{
t
.
Errorf
(
"Expected failiure"
)
t
.
Errorf
(
"Expected failiure"
)
}
}
...
...
pkg/volume/gce_pd/gce_pd.go
View file @
cd359ffa
...
@@ -75,9 +75,9 @@ func (plugin *gcePersistentDiskPlugin) GetAccessModes() []api.AccessModeType {
...
@@ -75,9 +75,9 @@ func (plugin *gcePersistentDiskPlugin) GetAccessModes() []api.AccessModeType {
}
}
}
}
func
(
plugin
*
gcePersistentDiskPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
gcePersistentDiskPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
// Inject real implementations here, test through the internal function.
// Inject real implementations here, test through the internal function.
return
plugin
.
newBuilderInternal
(
spec
,
pod
Ref
.
UID
,
&
GCEDiskUtil
{},
mounter
)
return
plugin
.
newBuilderInternal
(
spec
,
pod
.
UID
,
&
GCEDiskUtil
{},
mounter
)
}
}
func
(
plugin
*
gcePersistentDiskPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
pdManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
gcePersistentDiskPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
pdManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
...
...
pkg/volume/gce_pd/gce_pd_test.go
View file @
cd359ffa
...
@@ -186,7 +186,8 @@ func TestPluginLegacy(t *testing.T) {
...
@@ -186,7 +186,8 @@ func TestPluginLegacy(t *testing.T) {
}
}
spec
:=
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}}
spec
:=
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}}
if
_
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
volume
.
VolumeOptions
{
""
},
nil
);
err
==
nil
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
if
_
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
pod
,
volume
.
VolumeOptions
{
""
},
nil
);
err
==
nil
{
t
.
Errorf
(
"Expected failiure"
)
t
.
Errorf
(
"Expected failiure"
)
}
}
...
...
pkg/volume/git_repo/git_repo.go
View file @
cd359ffa
...
@@ -67,13 +67,13 @@ func (plugin *gitRepoPlugin) CanSupport(spec *volume.Spec) bool {
...
@@ -67,13 +67,13 @@ func (plugin *gitRepoPlugin) CanSupport(spec *volume.Spec) bool {
return
spec
.
VolumeSource
.
GitRepo
!=
nil
return
spec
.
VolumeSource
.
GitRepo
!=
nil
}
}
func
(
plugin
*
gitRepoPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
gitRepoPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
if
plugin
.
legacyMode
{
if
plugin
.
legacyMode
{
// Legacy mode instances can be cleaned up but not created anew.
// Legacy mode instances can be cleaned up but not created anew.
return
nil
,
fmt
.
Errorf
(
"legacy mode: can not create new instances"
)
return
nil
,
fmt
.
Errorf
(
"legacy mode: can not create new instances"
)
}
}
return
&
gitRepo
{
return
&
gitRepo
{
pod
Ref
:
*
podRef
,
pod
:
*
pod
,
volName
:
spec
.
Name
,
volName
:
spec
.
Name
,
source
:
spec
.
VolumeSource
.
GitRepo
.
Repository
,
source
:
spec
.
VolumeSource
.
GitRepo
.
Repository
,
revision
:
spec
.
VolumeSource
.
GitRepo
.
Revision
,
revision
:
spec
.
VolumeSource
.
GitRepo
.
Revision
,
...
@@ -91,7 +91,7 @@ func (plugin *gitRepoPlugin) NewCleaner(volName string, podUID types.UID, mounte
...
@@ -91,7 +91,7 @@ func (plugin *gitRepoPlugin) NewCleaner(volName string, podUID types.UID, mounte
legacy
=
true
legacy
=
true
}
}
return
&
gitRepo
{
return
&
gitRepo
{
pod
Ref
:
api
.
ObjectReference
{
UID
:
podUID
},
pod
:
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
podUID
}
},
volName
:
volName
,
volName
:
volName
,
plugin
:
plugin
,
plugin
:
plugin
,
legacyMode
:
legacy
,
legacyMode
:
legacy
,
...
@@ -103,7 +103,7 @@ func (plugin *gitRepoPlugin) NewCleaner(volName string, podUID types.UID, mounte
...
@@ -103,7 +103,7 @@ func (plugin *gitRepoPlugin) NewCleaner(volName string, podUID types.UID, mounte
// These do not persist beyond the lifetime of a pod.
// These do not persist beyond the lifetime of a pod.
type
gitRepo
struct
{
type
gitRepo
struct
{
volName
string
volName
string
pod
Ref
api
.
ObjectReference
pod
api
.
Pod
source
string
source
string
revision
string
revision
string
exec
exec
.
Interface
exec
exec
.
Interface
...
@@ -134,7 +134,7 @@ func (gr *gitRepo) SetUpAt(dir string) error {
...
@@ -134,7 +134,7 @@ func (gr *gitRepo) SetUpAt(dir string) error {
}
}
// Wrap EmptyDir, let it do the setup.
// Wrap EmptyDir, let it do the setup.
wrapped
,
err
:=
gr
.
plugin
.
host
.
NewWrapperBuilder
(
wrappedVolumeSpec
,
&
gr
.
pod
Ref
,
gr
.
opts
,
gr
.
mounter
)
wrapped
,
err
:=
gr
.
plugin
.
host
.
NewWrapperBuilder
(
wrappedVolumeSpec
,
&
gr
.
pod
,
gr
.
opts
,
gr
.
mounter
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -172,7 +172,7 @@ func (gr *gitRepo) SetUpAt(dir string) error {
...
@@ -172,7 +172,7 @@ func (gr *gitRepo) SetUpAt(dir string) error {
}
}
func
(
gr
*
gitRepo
)
getMetaDir
()
string
{
func
(
gr
*
gitRepo
)
getMetaDir
()
string
{
return
path
.
Join
(
gr
.
plugin
.
host
.
GetPodPluginDir
(
gr
.
pod
Ref
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
gitRepoPluginName
)),
gr
.
volName
)
return
path
.
Join
(
gr
.
plugin
.
host
.
GetPodPluginDir
(
gr
.
pod
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
gitRepoPluginName
)),
gr
.
volName
)
}
}
func
(
gr
*
gitRepo
)
execCommand
(
command
string
,
args
[]
string
,
dir
string
)
([]
byte
,
error
)
{
func
(
gr
*
gitRepo
)
execCommand
(
command
string
,
args
[]
string
,
dir
string
)
([]
byte
,
error
)
{
...
@@ -186,7 +186,7 @@ func (gr *gitRepo) GetPath() string {
...
@@ -186,7 +186,7 @@ func (gr *gitRepo) GetPath() string {
if
gr
.
legacyMode
{
if
gr
.
legacyMode
{
name
=
gitRepoPluginLegacyName
name
=
gitRepoPluginLegacyName
}
}
return
gr
.
plugin
.
host
.
GetPodVolumeDir
(
gr
.
pod
Ref
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
gr
.
volName
)
return
gr
.
plugin
.
host
.
GetPodVolumeDir
(
gr
.
pod
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
gr
.
volName
)
}
}
// TearDown simply deletes everything in the directory.
// TearDown simply deletes everything in the directory.
...
@@ -197,7 +197,7 @@ func (gr *gitRepo) TearDown() error {
...
@@ -197,7 +197,7 @@ func (gr *gitRepo) TearDown() error {
// TearDownAt simply deletes everything in the directory.
// TearDownAt simply deletes everything in the directory.
func
(
gr
*
gitRepo
)
TearDownAt
(
dir
string
)
error
{
func
(
gr
*
gitRepo
)
TearDownAt
(
dir
string
)
error
{
// Wrap EmptyDir, let it do the teardown.
// Wrap EmptyDir, let it do the teardown.
wrapped
,
err
:=
gr
.
plugin
.
host
.
NewWrapperCleaner
(
wrappedVolumeSpec
,
gr
.
pod
Ref
.
UID
,
gr
.
mounter
)
wrapped
,
err
:=
gr
.
plugin
.
host
.
NewWrapperCleaner
(
wrappedVolumeSpec
,
gr
.
pod
.
UID
,
gr
.
mounter
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/volume/git_repo/git_repo_test.go
View file @
cd359ffa
...
@@ -119,7 +119,8 @@ func TestPlugin(t *testing.T) {
...
@@ -119,7 +119,8 @@ func TestPlugin(t *testing.T) {
},
},
},
},
}
}
builder
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
volume
.
VolumeOptions
{
""
},
mount
.
New
())
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
pod
,
volume
.
VolumeOptions
{
""
},
mount
.
New
())
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -175,7 +176,8 @@ func TestPluginLegacy(t *testing.T) {
...
@@ -175,7 +176,8 @@ func TestPluginLegacy(t *testing.T) {
}
}
spec
:=
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}}
spec
:=
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}}
if
_
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
volume
.
VolumeOptions
{
""
},
nil
);
err
==
nil
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
if
_
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
pod
,
volume
.
VolumeOptions
{
""
},
nil
);
err
==
nil
{
t
.
Errorf
(
"Expected failiure"
)
t
.
Errorf
(
"Expected failiure"
)
}
}
...
...
pkg/volume/glusterfs/glusterfs.go
View file @
cd359ffa
...
@@ -64,19 +64,19 @@ func (plugin *glusterfsPlugin) GetAccessModes() []api.AccessModeType {
...
@@ -64,19 +64,19 @@ func (plugin *glusterfsPlugin) GetAccessModes() []api.AccessModeType {
}
}
}
}
func
(
plugin
*
glusterfsPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
glusterfsPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
ep_name
:=
spec
.
VolumeSource
.
Glusterfs
.
EndpointsName
ep_name
:=
spec
.
VolumeSource
.
Glusterfs
.
EndpointsName
ns
:=
pod
Ref
.
Namespace
ns
:=
pod
.
Namespace
ep
,
err
:=
plugin
.
host
.
GetKubeClient
()
.
Endpoints
(
ns
)
.
Get
(
ep_name
)
ep
,
err
:=
plugin
.
host
.
GetKubeClient
()
.
Endpoints
(
ns
)
.
Get
(
ep_name
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Glusterfs: failed to get endpoints %s[%v]"
,
ep_name
,
err
)
glog
.
Errorf
(
"Glusterfs: failed to get endpoints %s[%v]"
,
ep_name
,
err
)
return
nil
,
err
return
nil
,
err
}
}
glog
.
V
(
1
)
.
Infof
(
"Glusterfs: endpoints %v"
,
ep
)
glog
.
V
(
1
)
.
Infof
(
"Glusterfs: endpoints %v"
,
ep
)
return
plugin
.
newBuilderInternal
(
spec
,
ep
,
pod
Ref
,
mounter
,
exec
.
New
())
return
plugin
.
newBuilderInternal
(
spec
,
ep
,
pod
,
mounter
,
exec
.
New
())
}
}
func
(
plugin
*
glusterfsPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
ep
*
api
.
Endpoints
,
pod
Ref
*
api
.
ObjectReference
,
mounter
mount
.
Interface
,
exe
exec
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
glusterfsPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
ep
*
api
.
Endpoints
,
pod
*
api
.
Pod
,
mounter
mount
.
Interface
,
exe
exec
.
Interface
)
(
volume
.
Builder
,
error
)
{
return
&
glusterfs
{
return
&
glusterfs
{
volName
:
spec
.
Name
,
volName
:
spec
.
Name
,
hosts
:
ep
,
hosts
:
ep
,
...
@@ -84,7 +84,7 @@ func (plugin *glusterfsPlugin) newBuilderInternal(spec *volume.Spec, ep *api.End
...
@@ -84,7 +84,7 @@ func (plugin *glusterfsPlugin) newBuilderInternal(spec *volume.Spec, ep *api.End
readonly
:
spec
.
VolumeSource
.
Glusterfs
.
ReadOnly
,
readonly
:
spec
.
VolumeSource
.
Glusterfs
.
ReadOnly
,
mounter
:
mounter
,
mounter
:
mounter
,
exe
:
exe
,
exe
:
exe
,
pod
Ref
:
podRef
,
pod
:
pod
,
plugin
:
plugin
,
plugin
:
plugin
,
},
nil
},
nil
}
}
...
@@ -97,7 +97,7 @@ func (plugin *glusterfsPlugin) newCleanerInternal(volName string, podUID types.U
...
@@ -97,7 +97,7 @@ func (plugin *glusterfsPlugin) newCleanerInternal(volName string, podUID types.U
return
&
glusterfs
{
return
&
glusterfs
{
volName
:
volName
,
volName
:
volName
,
mounter
:
mounter
,
mounter
:
mounter
,
pod
Ref
:
&
api
.
ObjectReference
{
UID
:
podUID
},
pod
:
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
podUID
}
},
plugin
:
plugin
,
plugin
:
plugin
,
},
nil
},
nil
}
}
...
@@ -105,7 +105,7 @@ func (plugin *glusterfsPlugin) newCleanerInternal(volName string, podUID types.U
...
@@ -105,7 +105,7 @@ func (plugin *glusterfsPlugin) newCleanerInternal(volName string, podUID types.U
// Glusterfs volumes represent a bare host file or directory mount of an Glusterfs export.
// Glusterfs volumes represent a bare host file or directory mount of an Glusterfs export.
type
glusterfs
struct
{
type
glusterfs
struct
{
volName
string
volName
string
pod
Ref
*
api
.
ObjectReference
pod
*
api
.
Pod
hosts
*
api
.
Endpoints
hosts
*
api
.
Endpoints
path
string
path
string
readonly
bool
readonly
bool
...
@@ -142,7 +142,7 @@ func (glusterfsVolume *glusterfs) SetUpAt(dir string) error {
...
@@ -142,7 +142,7 @@ func (glusterfsVolume *glusterfs) SetUpAt(dir string) error {
func
(
glusterfsVolume
*
glusterfs
)
GetPath
()
string
{
func
(
glusterfsVolume
*
glusterfs
)
GetPath
()
string
{
name
:=
glusterfsPluginName
name
:=
glusterfsPluginName
return
glusterfsVolume
.
plugin
.
host
.
GetPodVolumeDir
(
glusterfsVolume
.
pod
Ref
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
glusterfsVolume
.
volName
)
return
glusterfsVolume
.
plugin
.
host
.
GetPodVolumeDir
(
glusterfsVolume
.
pod
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
glusterfsVolume
.
volName
)
}
}
func
(
glusterfsVolume
*
glusterfs
)
TearDown
()
error
{
func
(
glusterfsVolume
*
glusterfs
)
TearDown
()
error
{
...
...
pkg/volume/glusterfs/glusterfs_test.go
View file @
cd359ffa
...
@@ -94,7 +94,8 @@ func TestPlugin(t *testing.T) {
...
@@ -94,7 +94,8 @@ func TestPlugin(t *testing.T) {
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
},
},
}
}
builder
,
err
:=
plug
.
(
*
glusterfsPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
spec
),
ep
,
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
&
mount
.
FakeMounter
{},
&
fake
)
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
(
*
glusterfsPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
spec
),
ep
,
pod
,
&
mount
.
FakeMounter
{},
&
fake
)
volumePath
:=
builder
.
GetPath
()
volumePath
:=
builder
.
GetPath
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
...
...
pkg/volume/host_path/host_path.go
View file @
cd359ffa
...
@@ -58,7 +58,7 @@ func (plugin *hostPathPlugin) GetAccessModes() []api.AccessModeType {
...
@@ -58,7 +58,7 @@ func (plugin *hostPathPlugin) GetAccessModes() []api.AccessModeType {
}
}
}
}
func
(
plugin
*
hostPathPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
_
volume
.
VolumeOptions
,
_
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
hostPathPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
_
volume
.
VolumeOptions
,
_
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
if
spec
.
VolumeSource
.
HostPath
!=
nil
{
if
spec
.
VolumeSource
.
HostPath
!=
nil
{
return
&
hostPath
{
spec
.
VolumeSource
.
HostPath
.
Path
},
nil
return
&
hostPath
{
spec
.
VolumeSource
.
HostPath
.
Path
},
nil
}
else
{
}
else
{
...
...
pkg/volume/host_path/host_path_test.go
View file @
cd359ffa
...
@@ -68,7 +68,8 @@ func TestPlugin(t *testing.T) {
...
@@ -68,7 +68,8 @@ func TestPlugin(t *testing.T) {
Name
:
"vol1"
,
Name
:
"vol1"
,
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/vol1"
}},
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/vol1"
}},
}
}
builder
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
volume
.
VolumeOptions
{},
nil
)
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
spec
),
pod
,
volume
.
VolumeOptions
{},
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
...
pkg/volume/iscsi/iscsi.go
View file @
cd359ffa
...
@@ -72,9 +72,9 @@ func (plugin *ISCSIPlugin) GetAccessModes() []api.AccessModeType {
...
@@ -72,9 +72,9 @@ func (plugin *ISCSIPlugin) GetAccessModes() []api.AccessModeType {
}
}
}
}
func
(
plugin
*
ISCSIPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
ISCSIPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
// Inject real implementations here, test through the internal function.
// Inject real implementations here, test through the internal function.
return
plugin
.
newBuilderInternal
(
spec
,
pod
Ref
.
UID
,
&
ISCSIUtil
{},
mounter
)
return
plugin
.
newBuilderInternal
(
spec
,
pod
.
UID
,
&
ISCSIUtil
{},
mounter
)
}
}
func
(
plugin
*
ISCSIPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
ISCSIPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
...
...
pkg/volume/nfs/nfs.go
View file @
cd359ffa
...
@@ -64,18 +64,18 @@ func (plugin *nfsPlugin) GetAccessModes() []api.AccessModeType {
...
@@ -64,18 +64,18 @@ func (plugin *nfsPlugin) GetAccessModes() []api.AccessModeType {
}
}
}
}
func
(
plugin
*
nfsPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
_
volume
.
VolumeOptions
,
_
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
nfsPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
_
volume
.
VolumeOptions
,
_
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
return
plugin
.
newBuilderInternal
(
spec
,
pod
Ref
,
plugin
.
mounter
)
return
plugin
.
newBuilderInternal
(
spec
,
pod
,
plugin
.
mounter
)
}
}
func
(
plugin
*
nfsPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
nfsPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
return
&
nfs
{
return
&
nfs
{
volName
:
spec
.
Name
,
volName
:
spec
.
Name
,
server
:
spec
.
VolumeSource
.
NFS
.
Server
,
server
:
spec
.
VolumeSource
.
NFS
.
Server
,
exportPath
:
spec
.
VolumeSource
.
NFS
.
Path
,
exportPath
:
spec
.
VolumeSource
.
NFS
.
Path
,
readOnly
:
spec
.
VolumeSource
.
NFS
.
ReadOnly
,
readOnly
:
spec
.
VolumeSource
.
NFS
.
ReadOnly
,
mounter
:
mounter
,
mounter
:
mounter
,
pod
Ref
:
podRef
,
pod
:
pod
,
plugin
:
plugin
,
plugin
:
plugin
,
},
nil
},
nil
}
}
...
@@ -91,7 +91,7 @@ func (plugin *nfsPlugin) newCleanerInternal(volName string, podUID types.UID, mo
...
@@ -91,7 +91,7 @@ func (plugin *nfsPlugin) newCleanerInternal(volName string, podUID types.UID, mo
exportPath
:
""
,
exportPath
:
""
,
readOnly
:
false
,
readOnly
:
false
,
mounter
:
mounter
,
mounter
:
mounter
,
pod
Ref
:
&
api
.
ObjectReference
{
UID
:
podUID
},
pod
:
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
podUID
}
},
plugin
:
plugin
,
plugin
:
plugin
,
},
nil
},
nil
}
}
...
@@ -99,7 +99,7 @@ func (plugin *nfsPlugin) newCleanerInternal(volName string, podUID types.UID, mo
...
@@ -99,7 +99,7 @@ func (plugin *nfsPlugin) newCleanerInternal(volName string, podUID types.UID, mo
// NFS volumes represent a bare host file or directory mount of an NFS export.
// NFS volumes represent a bare host file or directory mount of an NFS export.
type
nfs
struct
{
type
nfs
struct
{
volName
string
volName
string
pod
Ref
*
api
.
ObjectReference
pod
*
api
.
Pod
server
string
server
string
exportPath
string
exportPath
string
readOnly
bool
readOnly
bool
...
@@ -158,7 +158,7 @@ func (nfsVolume *nfs) SetUpAt(dir string) error {
...
@@ -158,7 +158,7 @@ func (nfsVolume *nfs) SetUpAt(dir string) error {
func
(
nfsVolume
*
nfs
)
GetPath
()
string
{
func
(
nfsVolume
*
nfs
)
GetPath
()
string
{
name
:=
nfsPluginName
name
:=
nfsPluginName
return
nfsVolume
.
plugin
.
host
.
GetPodVolumeDir
(
nfsVolume
.
pod
Ref
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
nfsVolume
.
volName
)
return
nfsVolume
.
plugin
.
host
.
GetPodVolumeDir
(
nfsVolume
.
pod
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
nfsVolume
.
volName
)
}
}
func
(
nfsVolume
*
nfs
)
TearDown
()
error
{
func
(
nfsVolume
*
nfs
)
TearDown
()
error
{
...
...
pkg/volume/nfs/nfs_test.go
View file @
cd359ffa
...
@@ -78,7 +78,8 @@ func TestPlugin(t *testing.T) {
...
@@ -78,7 +78,8 @@ func TestPlugin(t *testing.T) {
VolumeSource
:
api
.
VolumeSource
{
NFS
:
&
api
.
NFSVolumeSource
{
"localhost"
,
"/tmp"
,
false
}},
VolumeSource
:
api
.
VolumeSource
{
NFS
:
&
api
.
NFSVolumeSource
{
"localhost"
,
"/tmp"
,
false
}},
}
}
fake
:=
&
mount
.
FakeMounter
{}
fake
:=
&
mount
.
FakeMounter
{}
builder
,
err
:=
plug
.
(
*
nfsPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
spec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
fake
)
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
(
*
nfsPlugin
)
.
newBuilderInternal
(
volume
.
NewSpecFromVolume
(
spec
),
pod
,
fake
)
volumePath
:=
builder
.
GetPath
()
volumePath
:=
builder
.
GetPath
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
...
...
pkg/volume/persistent_claim/persistent_claim.go
View file @
cd359ffa
...
@@ -51,8 +51,8 @@ func (plugin *persistentClaimPlugin) CanSupport(spec *volume.Spec) bool {
...
@@ -51,8 +51,8 @@ func (plugin *persistentClaimPlugin) CanSupport(spec *volume.Spec) bool {
return
spec
.
VolumeSource
.
PersistentVolumeClaimVolumeSource
!=
nil
return
spec
.
VolumeSource
.
PersistentVolumeClaimVolumeSource
!=
nil
}
}
func
(
plugin
*
persistentClaimPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
Ref
*
api
.
ObjectReference
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
persistentClaimPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
claim
,
err
:=
plugin
.
host
.
GetKubeClient
()
.
PersistentVolumeClaims
(
pod
Ref
.
Namespace
)
.
Get
(
spec
.
VolumeSource
.
PersistentVolumeClaimVolumeSource
.
ClaimName
)
claim
,
err
:=
plugin
.
host
.
GetKubeClient
()
.
PersistentVolumeClaims
(
pod
.
Namespace
)
.
Get
(
spec
.
VolumeSource
.
PersistentVolumeClaimVolumeSource
.
ClaimName
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error finding claim: %+v
\n
"
,
spec
.
VolumeSource
.
PersistentVolumeClaimVolumeSource
.
ClaimName
)
glog
.
Errorf
(
"Error finding claim: %+v
\n
"
,
spec
.
VolumeSource
.
PersistentVolumeClaimVolumeSource
.
ClaimName
)
return
nil
,
err
return
nil
,
err
...
@@ -68,7 +68,7 @@ func (plugin *persistentClaimPlugin) NewBuilder(spec *volume.Spec, podRef *api.O
...
@@ -68,7 +68,7 @@ func (plugin *persistentClaimPlugin) NewBuilder(spec *volume.Spec, podRef *api.O
return
nil
,
err
return
nil
,
err
}
}
builder
,
err
:=
plugin
.
host
.
NewWrapperBuilder
(
volume
.
NewSpecFromPersistentVolume
(
pv
),
pod
Ref
,
opts
,
mounter
)
builder
,
err
:=
plugin
.
host
.
NewWrapperBuilder
(
volume
.
NewSpecFromPersistentVolume
(
pv
),
pod
,
opts
,
mounter
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error creating builder for claim: %+v
\n
"
,
claim
.
Name
)
glog
.
Errorf
(
"Error creating builder for claim: %+v
\n
"
,
claim
.
Name
)
return
nil
,
err
return
nil
,
err
...
...
pkg/volume/persistent_claim/persistent_claim_test.go
View file @
cd359ffa
...
@@ -169,7 +169,8 @@ func TestNewBuilder(t *testing.T) {
...
@@ -169,7 +169,8 @@ func TestNewBuilder(t *testing.T) {
Name
:
"vol1"
,
Name
:
"vol1"
,
VolumeSource
:
item
.
podVolume
,
VolumeSource
:
item
.
podVolume
,
}
}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
volume
.
VolumeOptions
{},
nil
)
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
pod
,
volume
.
VolumeOptions
{},
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -229,7 +230,8 @@ func TestNewBuilderClaimNotBound(t *testing.T) {
...
@@ -229,7 +230,8 @@ func TestNewBuilderClaimNotBound(t *testing.T) {
Name
:
"vol1"
,
Name
:
"vol1"
,
VolumeSource
:
podVolume
,
VolumeSource
:
podVolume
,
}
}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)},
volume
.
VolumeOptions
{},
nil
)
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
types
.
UID
(
"poduid"
)}}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
pod
,
volume
.
VolumeOptions
{},
nil
)
if
builder
!=
nil
{
if
builder
!=
nil
{
t
.
Errorf
(
"Expected a nil builder if the claim wasn't bound"
)
t
.
Errorf
(
"Expected a nil builder if the claim wasn't bound"
)
}
}
...
...
pkg/volume/plugins.go
View file @
cd359ffa
...
@@ -62,8 +62,8 @@ type VolumePlugin interface {
...
@@ -62,8 +62,8 @@ type VolumePlugin interface {
// NewBuilder creates a new volume.Builder from an API specification.
// NewBuilder creates a new volume.Builder from an API specification.
// Ownership of the spec pointer in *not* transferred.
// Ownership of the spec pointer in *not* transferred.
// - spec: The api.Volume spec
// - spec: The api.Volume spec
// - pod
Ref: a reference to t
he enclosing pod
// - pod
: T
he enclosing pod
NewBuilder
(
spec
*
Spec
,
podRef
*
api
.
ObjectReference
,
opts
VolumeOptions
,
mounter
mount
.
Interface
)
(
Builder
,
error
)
NewBuilder
(
spec
*
Spec
,
podRef
*
api
.
Pod
,
opts
VolumeOptions
,
mounter
mount
.
Interface
)
(
Builder
,
error
)
// NewCleaner creates a new volume.Cleaner from recoverable state.
// NewCleaner creates a new volume.Cleaner from recoverable state.
// - name: The volume name, as per the api.Volume spec.
// - name: The volume name, as per the api.Volume spec.
...
@@ -106,7 +106,7 @@ type VolumeHost interface {
...
@@ -106,7 +106,7 @@ type VolumeHost interface {
// the provided spec. This is used to implement volume plugins which
// the provided spec. This is used to implement volume plugins which
// "wrap" other plugins. For example, the "secret" volume is
// "wrap" other plugins. For example, the "secret" volume is
// implemented in terms of the "emptyDir" volume.
// implemented in terms of the "emptyDir" volume.
NewWrapperBuilder
(
spec
*
Spec
,
pod
Ref
*
api
.
ObjectReference
,
opts
VolumeOptions
,
mounter
mount
.
Interface
)
(
Builder
,
error
)
NewWrapperBuilder
(
spec
*
Spec
,
pod
*
api
.
Pod
,
opts
VolumeOptions
,
mounter
mount
.
Interface
)
(
Builder
,
error
)
// NewWrapperCleaner finds an appropriate plugin with which to handle
// NewWrapperCleaner finds an appropriate plugin with which to handle
// the provided spec. See comments on NewWrapperBuilder for more
// the provided spec. See comments on NewWrapperBuilder for more
...
...
pkg/volume/secret/secret.go
View file @
cd359ffa
...
@@ -44,6 +44,8 @@ type secretPlugin struct {
...
@@ -44,6 +44,8 @@ type secretPlugin struct {
host
volume
.
VolumeHost
host
volume
.
VolumeHost
}
}
var
_
volume
.
VolumePlugin
=
&
secretPlugin
{}
func
(
plugin
*
secretPlugin
)
Init
(
host
volume
.
VolumeHost
)
{
func
(
plugin
*
secretPlugin
)
Init
(
host
volume
.
VolumeHost
)
{
plugin
.
host
=
host
plugin
.
host
=
host
}
}
...
@@ -56,12 +58,8 @@ func (plugin *secretPlugin) CanSupport(spec *volume.Spec) bool {
...
@@ -56,12 +58,8 @@ func (plugin *secretPlugin) CanSupport(spec *volume.Spec) bool {
return
spec
.
VolumeSource
.
Secret
!=
nil
return
spec
.
VolumeSource
.
Secret
!=
nil
}
}
func
(
plugin
*
secretPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
podRef
*
api
.
ObjectReference
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
secretPlugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
return
plugin
.
newBuilderInternal
(
spec
,
podRef
,
opts
,
mounter
)
return
&
secretVolume
{
spec
.
Name
,
*
pod
,
plugin
,
spec
.
VolumeSource
.
Secret
.
SecretName
,
&
opts
,
mounter
},
nil
}
func
(
plugin
*
secretPlugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
podRef
*
api
.
ObjectReference
,
opts
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
return
&
secretVolume
{
spec
.
Name
,
*
podRef
,
plugin
,
spec
.
VolumeSource
.
Secret
.
SecretName
,
&
opts
,
mounter
},
nil
}
}
func
(
plugin
*
secretPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
func
(
plugin
*
secretPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
...
@@ -69,14 +67,14 @@ func (plugin *secretPlugin) NewCleaner(volName string, podUID types.UID, mounter
...
@@ -69,14 +67,14 @@ func (plugin *secretPlugin) NewCleaner(volName string, podUID types.UID, mounter
}
}
func
(
plugin
*
secretPlugin
)
newCleanerInternal
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
func
(
plugin
*
secretPlugin
)
newCleanerInternal
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
return
&
secretVolume
{
volName
,
api
.
ObjectReference
{
UID
:
podUID
},
plugin
,
""
,
nil
,
mounter
},
nil
return
&
secretVolume
{
volName
,
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
podUID
}
},
plugin
,
""
,
nil
,
mounter
},
nil
}
}
// secretVolume handles retrieving secrets from the API server
// secretVolume handles retrieving secrets from the API server
// and placing them into the volume on the host.
// and placing them into the volume on the host.
type
secretVolume
struct
{
type
secretVolume
struct
{
volName
string
volName
string
pod
Ref
api
.
ObjectReference
pod
api
.
Pod
plugin
*
secretPlugin
plugin
*
secretPlugin
secretName
string
secretName
string
opts
*
volume
.
VolumeOptions
opts
*
volume
.
VolumeOptions
...
@@ -98,10 +96,10 @@ func (sv *secretVolume) SetUpAt(dir string) error {
...
@@ -98,10 +96,10 @@ func (sv *secretVolume) SetUpAt(dir string) error {
return
nil
return
nil
}
}
glog
.
V
(
3
)
.
Infof
(
"Setting up volume %v for pod %v at %v"
,
sv
.
volName
,
sv
.
pod
Ref
.
UID
,
dir
)
glog
.
V
(
3
)
.
Infof
(
"Setting up volume %v for pod %v at %v"
,
sv
.
volName
,
sv
.
pod
.
UID
,
dir
)
// Wrap EmptyDir, let it do the setup.
// Wrap EmptyDir, let it do the setup.
wrapped
,
err
:=
sv
.
plugin
.
host
.
NewWrapperBuilder
(
wrappedVolumeSpec
,
&
sv
.
pod
Ref
,
*
sv
.
opts
,
sv
.
mounter
)
wrapped
,
err
:=
sv
.
plugin
.
host
.
NewWrapperBuilder
(
wrappedVolumeSpec
,
&
sv
.
pod
,
*
sv
.
opts
,
sv
.
mounter
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -114,14 +112,14 @@ func (sv *secretVolume) SetUpAt(dir string) error {
...
@@ -114,14 +112,14 @@ func (sv *secretVolume) SetUpAt(dir string) error {
return
fmt
.
Errorf
(
"Cannot setup secret volume %v because kube client is not configured"
,
sv
)
return
fmt
.
Errorf
(
"Cannot setup secret volume %v because kube client is not configured"
,
sv
)
}
}
secret
,
err
:=
kubeClient
.
Secrets
(
sv
.
pod
Ref
.
Namespace
)
.
Get
(
sv
.
secretName
)
secret
,
err
:=
kubeClient
.
Secrets
(
sv
.
pod
.
Namespace
)
.
Get
(
sv
.
secretName
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Couldn't get secret %v/%v"
,
sv
.
pod
Ref
.
Namespace
,
sv
.
secretName
)
glog
.
Errorf
(
"Couldn't get secret %v/%v"
,
sv
.
pod
.
Namespace
,
sv
.
secretName
)
return
err
return
err
}
else
{
}
else
{
totalBytes
:=
totalSecretBytes
(
secret
)
totalBytes
:=
totalSecretBytes
(
secret
)
glog
.
V
(
3
)
.
Infof
(
"Received secret %v/%v containing (%v) pieces of data, %v total bytes"
,
glog
.
V
(
3
)
.
Infof
(
"Received secret %v/%v containing (%v) pieces of data, %v total bytes"
,
sv
.
pod
Ref
.
Namespace
,
sv
.
pod
.
Namespace
,
sv
.
secretName
,
sv
.
secretName
,
len
(
secret
.
Data
),
len
(
secret
.
Data
),
totalBytes
)
totalBytes
)
...
@@ -129,7 +127,7 @@ func (sv *secretVolume) SetUpAt(dir string) error {
...
@@ -129,7 +127,7 @@ func (sv *secretVolume) SetUpAt(dir string) error {
for
name
,
data
:=
range
secret
.
Data
{
for
name
,
data
:=
range
secret
.
Data
{
hostFilePath
:=
path
.
Join
(
dir
,
name
)
hostFilePath
:=
path
.
Join
(
dir
,
name
)
glog
.
V
(
3
)
.
Infof
(
"Writing secret data %v/%v/%v (%v bytes) to host file %v"
,
sv
.
pod
Ref
.
Namespace
,
sv
.
secretName
,
name
,
len
(
data
),
hostFilePath
)
glog
.
V
(
3
)
.
Infof
(
"Writing secret data %v/%v/%v (%v bytes) to host file %v"
,
sv
.
pod
.
Namespace
,
sv
.
secretName
,
name
,
len
(
data
),
hostFilePath
)
err
:=
ioutil
.
WriteFile
(
hostFilePath
,
data
,
0444
)
err
:=
ioutil
.
WriteFile
(
hostFilePath
,
data
,
0444
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error writing secret data to host path: %v, %v"
,
hostFilePath
,
err
)
glog
.
Errorf
(
"Error writing secret data to host path: %v, %v"
,
hostFilePath
,
err
)
...
@@ -152,7 +150,7 @@ func totalSecretBytes(secret *api.Secret) int {
...
@@ -152,7 +150,7 @@ func totalSecretBytes(secret *api.Secret) int {
}
}
func
(
sv
*
secretVolume
)
GetPath
()
string
{
func
(
sv
*
secretVolume
)
GetPath
()
string
{
return
sv
.
plugin
.
host
.
GetPodVolumeDir
(
sv
.
pod
Ref
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
secretPluginName
),
sv
.
volName
)
return
sv
.
plugin
.
host
.
GetPodVolumeDir
(
sv
.
pod
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
secretPluginName
),
sv
.
volName
)
}
}
func
(
sv
*
secretVolume
)
TearDown
()
error
{
func
(
sv
*
secretVolume
)
TearDown
()
error
{
...
@@ -160,10 +158,10 @@ func (sv *secretVolume) TearDown() error {
...
@@ -160,10 +158,10 @@ func (sv *secretVolume) TearDown() error {
}
}
func
(
sv
*
secretVolume
)
TearDownAt
(
dir
string
)
error
{
func
(
sv
*
secretVolume
)
TearDownAt
(
dir
string
)
error
{
glog
.
V
(
3
)
.
Infof
(
"Tearing down volume %v for pod %v at %v"
,
sv
.
volName
,
sv
.
pod
Ref
.
UID
,
dir
)
glog
.
V
(
3
)
.
Infof
(
"Tearing down volume %v for pod %v at %v"
,
sv
.
volName
,
sv
.
pod
.
UID
,
dir
)
// Wrap EmptyDir, let it do the teardown.
// Wrap EmptyDir, let it do the teardown.
wrapped
,
err
:=
sv
.
plugin
.
host
.
NewWrapperCleaner
(
wrappedVolumeSpec
,
sv
.
pod
Ref
.
UID
,
sv
.
mounter
)
wrapped
,
err
:=
sv
.
plugin
.
host
.
NewWrapperCleaner
(
wrappedVolumeSpec
,
sv
.
pod
.
UID
,
sv
.
mounter
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -171,5 +169,5 @@ func (sv *secretVolume) TearDownAt(dir string) error {
...
@@ -171,5 +169,5 @@ func (sv *secretVolume) TearDownAt(dir string) error {
}
}
func
(
sv
*
secretVolume
)
getMetaDir
()
string
{
func
(
sv
*
secretVolume
)
getMetaDir
()
string
{
return
path
.
Join
(
sv
.
plugin
.
host
.
GetPodPluginDir
(
sv
.
pod
Ref
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
secretPluginName
)),
sv
.
volName
)
return
path
.
Join
(
sv
.
plugin
.
host
.
GetPodPluginDir
(
sv
.
pod
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
secretPluginName
)),
sv
.
volName
)
}
}
pkg/volume/secret/secret_test.go
View file @
cd359ffa
...
@@ -60,7 +60,7 @@ func TestCanSupport(t *testing.T) {
...
@@ -60,7 +60,7 @@ func TestCanSupport(t *testing.T) {
func
TestPlugin
(
t
*
testing
.
T
)
{
func
TestPlugin
(
t
*
testing
.
T
)
{
var
(
var
(
testPodUID
=
"test_pod_uid"
testPodUID
=
types
.
UID
(
"test_pod_uid"
)
testVolumeName
=
"test_volume_name"
testVolumeName
=
"test_volume_name"
testNamespace
=
"test_secret_namespace"
testNamespace
=
"test_secret_namespace"
testName
=
"test_secret_name"
testName
=
"test_secret_name"
...
@@ -97,7 +97,8 @@ func TestPlugin(t *testing.T) {
...
@@ -97,7 +97,8 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Can't find the plugin by name"
)
t
.
Errorf
(
"Can't find the plugin by name"
)
}
}
builder
,
err
:=
plugin
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
volumeSpec
),
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
testPodUID
)},
volume
.
VolumeOptions
{},
&
mount
.
FakeMounter
{})
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
testPodUID
}}
builder
,
err
:=
plugin
.
NewBuilder
(
volume
.
NewSpecFromVolume
(
volumeSpec
),
pod
,
volume
.
VolumeOptions
{},
&
mount
.
FakeMounter
{})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -139,7 +140,7 @@ func TestPlugin(t *testing.T) {
...
@@ -139,7 +140,7 @@ func TestPlugin(t *testing.T) {
}
}
}
}
cleaner
,
err
:=
plugin
.
NewCleaner
(
testVolumeName
,
t
ypes
.
UID
(
testPodUID
)
,
mount
.
New
())
cleaner
,
err
:=
plugin
.
NewCleaner
(
testVolumeName
,
t
estPodUID
,
mount
.
New
())
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Cleaner: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Cleaner: %v"
,
err
)
}
}
...
...
pkg/volume/testing.go
View file @
cd359ffa
...
@@ -56,12 +56,12 @@ func (f *fakeVolumeHost) GetKubeClient() client.Interface {
...
@@ -56,12 +56,12 @@ func (f *fakeVolumeHost) GetKubeClient() client.Interface {
return
f
.
kubeClient
return
f
.
kubeClient
}
}
func
(
f
*
fakeVolumeHost
)
NewWrapperBuilder
(
spec
*
Spec
,
pod
Ref
*
api
.
ObjectReference
,
opts
VolumeOptions
,
mounter
mount
.
Interface
)
(
Builder
,
error
)
{
func
(
f
*
fakeVolumeHost
)
NewWrapperBuilder
(
spec
*
Spec
,
pod
*
api
.
Pod
,
opts
VolumeOptions
,
mounter
mount
.
Interface
)
(
Builder
,
error
)
{
plug
,
err
:=
f
.
pluginMgr
.
FindPluginBySpec
(
spec
)
plug
,
err
:=
f
.
pluginMgr
.
FindPluginBySpec
(
spec
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
plug
.
NewBuilder
(
spec
,
pod
Ref
,
opts
,
mounter
)
return
plug
.
NewBuilder
(
spec
,
pod
,
opts
,
mounter
)
}
}
func
(
f
*
fakeVolumeHost
)
NewWrapperCleaner
(
spec
*
Spec
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
Cleaner
,
error
)
{
func
(
f
*
fakeVolumeHost
)
NewWrapperCleaner
(
spec
*
Spec
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
Cleaner
,
error
)
{
...
@@ -96,8 +96,8 @@ func (plugin *FakeVolumePlugin) CanSupport(spec *Spec) bool {
...
@@ -96,8 +96,8 @@ func (plugin *FakeVolumePlugin) CanSupport(spec *Spec) bool {
return
true
return
true
}
}
func
(
plugin
*
FakeVolumePlugin
)
NewBuilder
(
spec
*
Spec
,
pod
Ref
*
api
.
ObjectReference
,
opts
VolumeOptions
,
mounter
mount
.
Interface
)
(
Builder
,
error
)
{
func
(
plugin
*
FakeVolumePlugin
)
NewBuilder
(
spec
*
Spec
,
pod
*
api
.
Pod
,
opts
VolumeOptions
,
mounter
mount
.
Interface
)
(
Builder
,
error
)
{
return
&
FakeVolume
{
pod
Ref
.
UID
,
spec
.
Name
,
plugin
},
nil
return
&
FakeVolume
{
pod
.
UID
,
spec
.
Name
,
plugin
},
nil
}
}
func
(
plugin
*
FakeVolumePlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
Cleaner
,
error
)
{
func
(
plugin
*
FakeVolumePlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
Cleaner
,
error
)
{
...
...
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