Rename UniqueDeviceName to UniqueVolumeName
Rename UniqueDeviceName to UniqueVolumeName and move helper functions from attacherdetacher to volumehelper package. Introduce UniquePodName alias
This commit is contained in:
@@ -78,10 +78,19 @@ func (plugin *hostPathPlugin) Init(host volume.VolumeHost) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (plugin *hostPathPlugin) Name() string {
|
||||
func (plugin *hostPathPlugin) GetPluginName() string {
|
||||
return hostPathPluginName
|
||||
}
|
||||
|
||||
func (plugin *hostPathPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||
volumeSource, _ := getVolumeSource(spec)
|
||||
if volumeSource == nil {
|
||||
return "", fmt.Errorf("Spec does not reference an HostPath volume type")
|
||||
}
|
||||
|
||||
return volumeSource.Path, nil
|
||||
}
|
||||
|
||||
func (plugin *hostPathPlugin) CanSupport(spec *volume.Spec) bool {
|
||||
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.HostPath != nil) ||
|
||||
(spec.Volume != nil && spec.Volume.HostPath != nil)
|
||||
@@ -303,3 +312,18 @@ func (r *hostPathDeleter) Delete() error {
|
||||
}
|
||||
return os.RemoveAll(r.GetPath())
|
||||
}
|
||||
|
||||
func getVolumeSource(spec *volume.Spec) (*api.HostPathVolumeSource, bool) {
|
||||
var readOnly bool
|
||||
var volumeSource *api.HostPathVolumeSource
|
||||
|
||||
if spec.Volume != nil && spec.Volume.HostPath != nil {
|
||||
volumeSource = spec.Volume.HostPath
|
||||
readOnly = spec.ReadOnly
|
||||
} else {
|
||||
volumeSource = spec.PersistentVolume.Spec.HostPath
|
||||
readOnly = spec.ReadOnly
|
||||
}
|
||||
|
||||
return volumeSource, readOnly
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user