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

@@ -54,6 +54,12 @@ func (plugin *hostPathPlugin) CanSupport(spec *api.Volume) bool {
return false
}
func (plugin *hostPathPlugin) GetAccessModes() []api.AccessModeType {
return []api.AccessModeType{
api.ReadWriteOnce,
}
}
func (plugin *hostPathPlugin) NewBuilder(spec *api.Volume, podRef *api.ObjectReference) (volume.Builder, error) {
return &hostPath{spec.HostPath.Path}, nil
}

View File

@@ -43,6 +43,19 @@ func TestCanSupport(t *testing.T) {
}
}
func TestGetAccessModes(t *testing.T) {
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(), volume.NewFakeVolumeHost("/tmp/fake", nil, nil))
plug, err := plugMgr.FindPersistentPluginByName("kubernetes.io/host-path")
if err != nil {
t.Errorf("Can't find the plugin by name")
}
if len(plug.GetAccessModes()) != 1 || plug.GetAccessModes()[0] != api.ReadWriteOnce {
t.Errorf("Expected %s AccessModeType", api.ReadWriteOnce)
}
}
func TestPlugin(t *testing.T) {
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(), volume.NewFakeVolumeHost("fake", nil, nil))