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:
saadali
2016-05-30 15:48:21 -07:00
parent 130341b5f1
commit 9b6a505f8a
48 changed files with 763 additions and 240 deletions

View File

@@ -58,10 +58,20 @@ func (plugin *downwardAPIPlugin) Init(host volume.VolumeHost) error {
return nil
}
func (plugin *downwardAPIPlugin) Name() string {
func (plugin *downwardAPIPlugin) GetPluginName() string {
return downwardAPIPluginName
}
func (plugin *downwardAPIPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
volumeSource, _ := getVolumeSource(spec)
if volumeSource == nil {
return "", fmt.Errorf("Spec does not reference a DownwardAPI volume type")
}
// Return user defined volume name, since this is an ephemeral volume type
return spec.Name(), nil
}
func (plugin *downwardAPIPlugin) CanSupport(spec *volume.Spec) bool {
return spec.Volume != nil && spec.Volume.DownwardAPI != nil
}
@@ -229,3 +239,15 @@ func (c *downwardAPIVolumeUnmounter) TearDownAt(dir string) error {
func (b *downwardAPIVolumeMounter) getMetaDir() string {
return path.Join(b.plugin.host.GetPodPluginDir(b.podUID, utilstrings.EscapeQualifiedNameForDisk(downwardAPIPluginName)), b.volName)
}
func getVolumeSource(spec *volume.Spec) (*api.DownwardAPIVolumeSource, bool) {
var readOnly bool
var volumeSource *api.DownwardAPIVolumeSource
if spec.Volume != nil && spec.Volume.DownwardAPI != nil {
volumeSource = spec.Volume.DownwardAPI
readOnly = spec.ReadOnly
}
return volumeSource, readOnly
}