Refactor ConstructVolumeSpec

Return a struct from ConstructVolumeSpec to be able to add more fields to
it later.
This commit is contained in:
Jan Safranek
2022-10-19 14:52:08 +02:00
parent 2dc8cc13a4
commit fc245b339b
35 changed files with 202 additions and 141 deletions

View File

@@ -451,10 +451,12 @@ func (plugin *FakeVolumePlugin) GetAccessModes() []v1.PersistentVolumeAccessMode
return []v1.PersistentVolumeAccessMode{}
}
func (plugin *FakeVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
return &volume.Spec{
Volume: &v1.Volume{
Name: volumeName,
func (plugin *FakeVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (volume.ReconstructedVolume, error) {
return volume.ReconstructedVolume{
Spec: &volume.Spec{
Volume: &v1.Volume{
Name: volumeName,
},
},
}, nil
}
@@ -526,7 +528,7 @@ func (f *FakeBasicVolumePlugin) CanSupport(spec *volume.Spec) bool {
return strings.HasPrefix(spec.Name(), f.GetPluginName())
}
func (f *FakeBasicVolumePlugin) ConstructVolumeSpec(ame, mountPath string) (*volume.Spec, error) {
func (f *FakeBasicVolumePlugin) ConstructVolumeSpec(ame, mountPath string) (volume.ReconstructedVolume, error) {
return f.Plugin.ConstructVolumeSpec(ame, mountPath)
}
@@ -647,8 +649,8 @@ func (plugin *FakeFileVolumePlugin) NewUnmounter(name string, podUID types.UID)
return nil, nil
}
func (plugin *FakeFileVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
return nil, nil
func (plugin *FakeFileVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (volume.ReconstructedVolume, error) {
return volume.ReconstructedVolume{}, nil
}
func NewFakeFileVolumePlugin() []volume.VolumePlugin {