fixed newRecycler func for HostPath & NFS

pull/6/head
markturansky 2015-07-29 14:13:05 -04:00
parent dcd6537b1b
commit 649374ddb4
2 changed files with 11 additions and 18 deletions

View File

@ -86,11 +86,10 @@ func (plugin *hostPathPlugin) NewRecycler(spec *volume.Spec) (volume.Recycler, e
}
func newRecycler(spec *volume.Spec, host volume.VolumeHost) (volume.Recycler, error) {
if spec.VolumeSource.HostPath != nil {
return &hostPathRecycler{spec.Name, spec.VolumeSource.HostPath.Path, host}, nil
} else {
return &hostPathRecycler{spec.Name, spec.PersistentVolumeSource.HostPath.Path, host}, nil
if spec.PersistentVolumeSource.HostPath == nil {
return nil, fmt.Errorf("spec.PersistentVolumeSource.HostPath is nil")
}
return &hostPathRecycler{spec.Name, spec.PersistentVolumeSource.HostPath.Path, host}, nil
}
// HostPath volumes represent a bare host file or directory mount.

View File

@ -223,21 +223,15 @@ func (c *nfsCleaner) TearDownAt(dir string) error {
}
func newRecycler(spec *volume.Spec, host volume.VolumeHost) (volume.Recycler, error) {
if spec.VolumeSource.HostPath != nil {
return &nfsRecycler{
name: spec.Name,
server: spec.VolumeSource.NFS.Server,
path: spec.VolumeSource.NFS.Path,
host: host,
}, nil
} else {
return &nfsRecycler{
name: spec.Name,
server: spec.PersistentVolumeSource.NFS.Server,
path: spec.PersistentVolumeSource.NFS.Path,
host: host,
}, nil
if spec.PersistentVolumeSource.NFS == nil {
return nil, fmt.Errorf("spec.PersistentVolumeSource.NFS is nil")
}
return &nfsRecycler{
name: spec.Name,
server: spec.PersistentVolumeSource.NFS.Server,
path: spec.PersistentVolumeSource.NFS.Path,
host: host,
}, nil
}
// nfsRecycler scrubs an NFS volume by running "rm -rf" on the volume in a pod.