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:
@@ -54,10 +54,23 @@ func (plugin *gitRepoPlugin) Init(host volume.VolumeHost) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (plugin *gitRepoPlugin) Name() string {
|
||||
func (plugin *gitRepoPlugin) GetPluginName() string {
|
||||
return gitRepoPluginName
|
||||
}
|
||||
|
||||
func (plugin *gitRepoPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||
volumeSource, _ := getVolumeSource(spec)
|
||||
if volumeSource == nil {
|
||||
return "", fmt.Errorf("Spec does not reference a GCE volume type")
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"%v:%v:%v",
|
||||
volumeSource.Repository,
|
||||
volumeSource.Revision,
|
||||
volumeSource.Directory), nil
|
||||
}
|
||||
|
||||
func (plugin *gitRepoPlugin) CanSupport(spec *volume.Spec) bool {
|
||||
return spec.Volume != nil && spec.Volume.GitRepo != nil
|
||||
}
|
||||
@@ -226,3 +239,15 @@ func (c *gitRepoVolumeUnmounter) TearDownAt(dir string) error {
|
||||
}
|
||||
return wrapped.TearDownAt(dir)
|
||||
}
|
||||
|
||||
func getVolumeSource(spec *volume.Spec) (*api.GitRepoVolumeSource, bool) {
|
||||
var readOnly bool
|
||||
var volumeSource *api.GitRepoVolumeSource
|
||||
|
||||
if spec.Volume != nil && spec.Volume.GitRepo != nil {
|
||||
volumeSource = spec.Volume.GitRepo
|
||||
readOnly = spec.ReadOnly
|
||||
}
|
||||
|
||||
return volumeSource, readOnly
|
||||
}
|
||||
|
Reference in New Issue
Block a user