Refactored Volume plugins to use InternalVolume instead of API types
This commit is contained in:
@@ -53,11 +53,8 @@ func (plugin *glusterfsPlugin) Name() string {
|
||||
return glusterfsPluginName
|
||||
}
|
||||
|
||||
func (plugin *glusterfsPlugin) CanSupport(spec *api.Volume) bool {
|
||||
if spec.VolumeSource.Glusterfs != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
func (plugin *glusterfsPlugin) CanSupport(spec *volume.Spec) bool {
|
||||
return spec.VolumeSource.Glusterfs != nil || spec.PersistentVolumeSource.Glusterfs != nil
|
||||
}
|
||||
|
||||
func (plugin *glusterfsPlugin) GetAccessModes() []api.AccessModeType {
|
||||
@@ -68,7 +65,7 @@ func (plugin *glusterfsPlugin) GetAccessModes() []api.AccessModeType {
|
||||
}
|
||||
}
|
||||
|
||||
func (plugin *glusterfsPlugin) NewBuilder(spec *api.Volume, podRef *api.ObjectReference, _ volume.VolumeOptions) (volume.Builder, error) {
|
||||
func (plugin *glusterfsPlugin) NewBuilder(spec *volume.Spec, podRef *api.ObjectReference, _ volume.VolumeOptions) (volume.Builder, error) {
|
||||
ep_name := spec.VolumeSource.Glusterfs.EndpointsName
|
||||
ns := api.NamespaceDefault
|
||||
ep, err := plugin.host.GetKubeClient().Endpoints(ns).Get(ep_name)
|
||||
@@ -80,7 +77,7 @@ func (plugin *glusterfsPlugin) NewBuilder(spec *api.Volume, podRef *api.ObjectRe
|
||||
return plugin.newBuilderInternal(spec, ep, podRef, mount.New(), exec.New())
|
||||
}
|
||||
|
||||
func (plugin *glusterfsPlugin) newBuilderInternal(spec *api.Volume, ep *api.Endpoints, podRef *api.ObjectReference, mounter mount.Interface, exe exec.Interface) (volume.Builder, error) {
|
||||
func (plugin *glusterfsPlugin) newBuilderInternal(spec *volume.Spec, ep *api.Endpoints, podRef *api.ObjectReference, mounter mount.Interface, exe exec.Interface) (volume.Builder, error) {
|
||||
return &glusterfs{
|
||||
volName: spec.Name,
|
||||
hosts: ep,
|
||||
|
@@ -37,10 +37,10 @@ func TestCanSupport(t *testing.T) {
|
||||
if plug.Name() != "kubernetes.io/glusterfs" {
|
||||
t.Errorf("Wrong name: %s", plug.Name())
|
||||
}
|
||||
if !plug.CanSupport(&api.Volume{VolumeSource: api.VolumeSource{Glusterfs: &api.GlusterfsVolumeSource{}}}) {
|
||||
if !plug.CanSupport(&volume.Spec{Name: "foo", VolumeSource: api.VolumeSource{Glusterfs: &api.GlusterfsVolumeSource{}}}) {
|
||||
t.Errorf("Expected true")
|
||||
}
|
||||
if plug.CanSupport(&api.Volume{VolumeSource: api.VolumeSource{}}) {
|
||||
if plug.CanSupport(&volume.Spec{Name: "foo", VolumeSource: api.VolumeSource{}}) {
|
||||
t.Errorf("Expected false")
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func TestPlugin(t *testing.T) {
|
||||
func(cmd string, args ...string) exec.Cmd { return exec.InitFakeCmd(&fcmd, cmd, args...) },
|
||||
},
|
||||
}
|
||||
builder, err := plug.(*glusterfsPlugin).newBuilderInternal(spec, ep, &api.ObjectReference{UID: types.UID("poduid")}, &mount.FakeMounter{}, &fake)
|
||||
builder, err := plug.(*glusterfsPlugin).newBuilderInternal(volume.NewSpecFromVolume(spec), ep, &api.ObjectReference{UID: types.UID("poduid")}, &mount.FakeMounter{}, &fake)
|
||||
volumePath := builder.GetPath()
|
||||
if err != nil {
|
||||
t.Errorf("Failed to make a new Builder: %v", err)
|
||||
|
Reference in New Issue
Block a user