Add GetAccessModes to volume plugin interface

This commit is contained in:
markturansky
2015-03-12 15:37:02 -04:00
parent ed68c8e82b
commit 111f3d5120
12 changed files with 216 additions and 1 deletions

View File

@@ -59,6 +59,14 @@ type VolumePlugin interface {
NewCleaner(name string, podUID types.UID) (Cleaner, error)
}
// PersistentVolumePlugin is an extended interface of VolumePlugin and is used
// by volumes that want to provide long term persistence of data
type PersistentVolumePlugin interface {
VolumePlugin
// GetAccessModes describes the ways a given volume can be accessed/mounted.
GetAccessModes() []api.AccessModeType
}
// VolumeHost is an interface that plugins can use to access the kubelet.
type VolumeHost interface {
// GetPluginDir returns the absolute path to a directory under which
@@ -173,3 +181,24 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
}
return pm.plugins[matches[0]], nil
}
// FindPersistentPluginBySpec looks for a plugin that can support a given volume
// specification. If no plugins can support or more than one plugin can
// support it, return error.
func (pm *VolumePluginMgr) FindPersistentPluginBySpec(spec *api.Volume) (PersistentVolumePlugin, error) {
volumePlugin, err := pm.FindPluginBySpec(spec)
if err != nil {
return nil, err
}
return volumePlugin.(PersistentVolumePlugin), nil
}
// FindPluginByName fetches a plugin by name or by legacy name. If no plugin
// is found, returns error.
func (pm *VolumePluginMgr) FindPersistentPluginByName(name string) (PersistentVolumePlugin, error) {
volumePlugin, err := pm.FindPluginByName(name)
if err != nil {
return nil, err
}
return volumePlugin.(PersistentVolumePlugin), nil
}