Refactored Volume plugins to use InternalVolume instead of API types
This commit is contained in:
@@ -52,8 +52,8 @@ func (plugin *ISCSIPlugin) Name() string {
|
||||
return ISCSIPluginName
|
||||
}
|
||||
|
||||
func (plugin *ISCSIPlugin) CanSupport(spec *api.Volume) bool {
|
||||
if spec.ISCSI == nil {
|
||||
func (plugin *ISCSIPlugin) CanSupport(spec *volume.Spec) bool {
|
||||
if spec.VolumeSource.ISCSI == nil {
|
||||
return false
|
||||
}
|
||||
// see if iscsiadm is there
|
||||
@@ -72,22 +72,23 @@ func (plugin *ISCSIPlugin) GetAccessModes() []api.AccessModeType {
|
||||
}
|
||||
}
|
||||
|
||||
func (plugin *ISCSIPlugin) NewBuilder(spec *api.Volume, podRef *api.ObjectReference, _ volume.VolumeOptions) (volume.Builder, error) {
|
||||
func (plugin *ISCSIPlugin) NewBuilder(spec *volume.Spec, podRef *api.ObjectReference, _ volume.VolumeOptions) (volume.Builder, error) {
|
||||
// Inject real implementations here, test through the internal function.
|
||||
return plugin.newBuilderInternal(spec, podRef.UID, &ISCSIUtil{}, mount.New())
|
||||
}
|
||||
|
||||
func (plugin *ISCSIPlugin) newBuilderInternal(spec *api.Volume, podUID types.UID, manager diskManager, mounter mount.Interface) (volume.Builder, error) {
|
||||
lun := strconv.Itoa(spec.ISCSI.Lun)
|
||||
func (plugin *ISCSIPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UID, manager diskManager, mounter mount.Interface) (volume.Builder, error) {
|
||||
iscsi := spec.VolumeSource.ISCSI
|
||||
lun := strconv.Itoa(iscsi.Lun)
|
||||
|
||||
return &iscsiDisk{
|
||||
podUID: podUID,
|
||||
volName: spec.Name,
|
||||
portal: spec.ISCSI.TargetPortal,
|
||||
iqn: spec.ISCSI.IQN,
|
||||
portal: iscsi.TargetPortal,
|
||||
iqn: iscsi.IQN,
|
||||
lun: lun,
|
||||
fsType: spec.ISCSI.FSType,
|
||||
readOnly: spec.ISCSI.ReadOnly,
|
||||
fsType: iscsi.FSType,
|
||||
readOnly: iscsi.ReadOnly,
|
||||
manager: manager,
|
||||
mounter: mounter,
|
||||
plugin: plugin,
|
||||
|
@@ -81,7 +81,7 @@ func TestPlugin(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
builder, err := plug.(*ISCSIPlugin).newBuilderInternal(spec, types.UID("poduid"), &fakeDiskManager{}, &mount.FakeMounter{})
|
||||
builder, err := plug.(*ISCSIPlugin).newBuilderInternal(volume.NewSpecFromVolume(spec), types.UID("poduid"), &fakeDiskManager{}, &mount.FakeMounter{})
|
||||
if err != nil {
|
||||
t.Errorf("Failed to make a new Builder: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user