mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-02 14:23:54 +00:00
cleanup: remove duplicate import
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
This commit is contained in:
@@ -37,7 +37,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
utiltesting "k8s.io/client-go/util/testing"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
. "k8s.io/kubernetes/pkg/volume"
|
||||
"k8s.io/kubernetes/pkg/volume/util"
|
||||
"k8s.io/kubernetes/pkg/volume/util/recyclerclient"
|
||||
volumetypes "k8s.io/kubernetes/pkg/volume/util/types"
|
||||
@@ -150,9 +149,9 @@ func makeFakeOutput(output string, rc int) testingexec.FakeAction {
|
||||
}
|
||||
}
|
||||
|
||||
func ProbeVolumePlugins(config VolumeConfig) []VolumePlugin {
|
||||
func ProbeVolumePlugins(config volume.VolumeConfig) []volume.VolumePlugin {
|
||||
if _, ok := config.OtherAttributes["fake-property"]; ok {
|
||||
return []VolumePlugin{
|
||||
return []volume.VolumePlugin{
|
||||
&FakeVolumePlugin{
|
||||
PluginName: "fake-plugin",
|
||||
Host: nil,
|
||||
@@ -160,7 +159,7 @@ func ProbeVolumePlugins(config VolumeConfig) []VolumePlugin {
|
||||
},
|
||||
}
|
||||
}
|
||||
return []VolumePlugin{&FakeVolumePlugin{PluginName: "fake-plugin"}}
|
||||
return []volume.VolumePlugin{&FakeVolumePlugin{PluginName: "fake-plugin"}}
|
||||
}
|
||||
|
||||
// FakeVolumePlugin is useful for testing. It tries to be a fully compliant
|
||||
@@ -170,9 +169,9 @@ func ProbeVolumePlugins(config VolumeConfig) []VolumePlugin {
|
||||
type FakeVolumePlugin struct {
|
||||
sync.RWMutex
|
||||
PluginName string
|
||||
Host VolumeHost
|
||||
Config VolumeConfig
|
||||
LastProvisionerOptions VolumeOptions
|
||||
Host volume.VolumeHost
|
||||
Config volume.VolumeConfig
|
||||
LastProvisionerOptions volume.VolumeOptions
|
||||
NewAttacherCallCount int
|
||||
NewDetacherCallCount int
|
||||
NodeExpandCallCount int
|
||||
@@ -187,7 +186,7 @@ type FakeVolumePlugin struct {
|
||||
NonAttachable bool
|
||||
|
||||
// Add callbacks as needed
|
||||
WaitForAttachHook func(spec *Spec, devicePath string, pod *v1.Pod, spectimeout time.Duration) (string, error)
|
||||
WaitForAttachHook func(spec *volume.Spec, devicePath string, pod *v1.Pod, spectimeout time.Duration) (string, error)
|
||||
UnmountDeviceHook func(globalMountPath string) error
|
||||
|
||||
Mounters []*FakeVolume
|
||||
@@ -198,15 +197,15 @@ type FakeVolumePlugin struct {
|
||||
BlockVolumeUnmappers []*FakeVolume
|
||||
}
|
||||
|
||||
var _ VolumePlugin = &FakeVolumePlugin{}
|
||||
var _ BlockVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ RecyclableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ DeletableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ ProvisionableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ AttachableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ VolumePluginWithAttachLimits = &FakeVolumePlugin{}
|
||||
var _ DeviceMountableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ NodeExpandableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ volume.VolumePlugin = &FakeVolumePlugin{}
|
||||
var _ volume.BlockVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ volume.RecyclableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ volume.DeletableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ volume.ProvisionableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ volume.AttachableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ volume.VolumePluginWithAttachLimits = &FakeVolumePlugin{}
|
||||
var _ volume.DeviceMountableVolumePlugin = &FakeVolumePlugin{}
|
||||
var _ volume.NodeExpandableVolumePlugin = &FakeVolumePlugin{}
|
||||
|
||||
func (plugin *FakeVolumePlugin) getFakeVolume(list *[]*FakeVolume) *FakeVolume {
|
||||
if list != nil {
|
||||
@@ -233,7 +232,7 @@ func (plugin *FakeVolumePlugin) getFakeVolume(list *[]*FakeVolume) *FakeVolume {
|
||||
return volume
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) Init(host VolumeHost) error {
|
||||
func (plugin *FakeVolumePlugin) Init(host volume.VolumeHost) error {
|
||||
plugin.Lock()
|
||||
defer plugin.Unlock()
|
||||
plugin.Host = host
|
||||
@@ -246,7 +245,7 @@ func (plugin *FakeVolumePlugin) GetPluginName() string {
|
||||
return plugin.PluginName
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) GetVolumeName(spec *Spec) (string, error) {
|
||||
func (plugin *FakeVolumePlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||
var volumeName string
|
||||
if spec.Volume != nil && spec.Volume.GCEPersistentDisk != nil {
|
||||
volumeName = spec.Volume.GCEPersistentDisk.PDName
|
||||
@@ -262,7 +261,7 @@ func (plugin *FakeVolumePlugin) GetVolumeName(spec *Spec) (string, error) {
|
||||
return volumeName, nil
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) CanSupport(spec *Spec) bool {
|
||||
func (plugin *FakeVolumePlugin) CanSupport(spec *volume.Spec) bool {
|
||||
// TODO: maybe pattern-match on spec.Name() to decide?
|
||||
return true
|
||||
}
|
||||
@@ -279,17 +278,17 @@ func (plugin *FakeVolumePlugin) SupportsBulkVolumeVerification() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) NewMounter(spec *Spec, pod *v1.Pod, opts VolumeOptions) (Mounter, error) {
|
||||
func (plugin *FakeVolumePlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, opts volume.VolumeOptions) (volume.Mounter, error) {
|
||||
plugin.Lock()
|
||||
defer plugin.Unlock()
|
||||
volume := plugin.getFakeVolume(&plugin.Mounters)
|
||||
volume.Lock()
|
||||
defer volume.Unlock()
|
||||
volume.PodUID = pod.UID
|
||||
volume.VolName = spec.Name()
|
||||
volume.Plugin = plugin
|
||||
volume.MetricsNil = MetricsNil{}
|
||||
return volume, nil
|
||||
fakeVolume := plugin.getFakeVolume(&plugin.Mounters)
|
||||
fakeVolume.Lock()
|
||||
defer fakeVolume.Unlock()
|
||||
fakeVolume.PodUID = pod.UID
|
||||
fakeVolume.VolName = spec.Name()
|
||||
fakeVolume.Plugin = plugin
|
||||
fakeVolume.MetricsNil = volume.MetricsNil{}
|
||||
return fakeVolume, nil
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) GetMounters() (Mounters []*FakeVolume) {
|
||||
@@ -298,17 +297,17 @@ func (plugin *FakeVolumePlugin) GetMounters() (Mounters []*FakeVolume) {
|
||||
return plugin.Mounters
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) NewUnmounter(volName string, podUID types.UID) (Unmounter, error) {
|
||||
func (plugin *FakeVolumePlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) {
|
||||
plugin.Lock()
|
||||
defer plugin.Unlock()
|
||||
volume := plugin.getFakeVolume(&plugin.Unmounters)
|
||||
volume.Lock()
|
||||
defer volume.Unlock()
|
||||
volume.PodUID = podUID
|
||||
volume.VolName = volName
|
||||
volume.Plugin = plugin
|
||||
volume.MetricsNil = MetricsNil{}
|
||||
return volume, nil
|
||||
fakeVolume := plugin.getFakeVolume(&plugin.Unmounters)
|
||||
fakeVolume.Lock()
|
||||
defer fakeVolume.Unlock()
|
||||
fakeVolume.PodUID = podUID
|
||||
fakeVolume.VolName = volName
|
||||
fakeVolume.Plugin = plugin
|
||||
fakeVolume.MetricsNil = volume.MetricsNil{}
|
||||
return fakeVolume, nil
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) GetUnmounters() (Unmounters []*FakeVolume) {
|
||||
@@ -318,7 +317,7 @@ func (plugin *FakeVolumePlugin) GetUnmounters() (Unmounters []*FakeVolume) {
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
func (plugin *FakeVolumePlugin) NewBlockVolumeMapper(spec *Spec, pod *v1.Pod, opts VolumeOptions) (BlockVolumeMapper, error) {
|
||||
func (plugin *FakeVolumePlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod, opts volume.VolumeOptions) (volume.BlockVolumeMapper, error) {
|
||||
plugin.Lock()
|
||||
defer plugin.Unlock()
|
||||
volume := plugin.getFakeVolume(&plugin.BlockVolumeMappers)
|
||||
@@ -340,7 +339,7 @@ func (plugin *FakeVolumePlugin) GetBlockVolumeMapper() (BlockVolumeMappers []*Fa
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
func (plugin *FakeVolumePlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (BlockVolumeUnmapper, error) {
|
||||
func (plugin *FakeVolumePlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
||||
plugin.Lock()
|
||||
defer plugin.Unlock()
|
||||
volume := plugin.getFakeVolume(&plugin.BlockVolumeUnmappers)
|
||||
@@ -359,14 +358,14 @@ func (plugin *FakeVolumePlugin) GetBlockVolumeUnmapper() (BlockVolumeUnmappers [
|
||||
return plugin.BlockVolumeUnmappers
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) NewAttacher() (Attacher, error) {
|
||||
func (plugin *FakeVolumePlugin) NewAttacher() (volume.Attacher, error) {
|
||||
plugin.Lock()
|
||||
defer plugin.Unlock()
|
||||
plugin.NewAttacherCallCount = plugin.NewAttacherCallCount + 1
|
||||
return plugin.getFakeVolume(&plugin.Attachers), nil
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) NewDeviceMounter() (DeviceMounter, error) {
|
||||
func (plugin *FakeVolumePlugin) NewDeviceMounter() (volume.DeviceMounter, error) {
|
||||
return plugin.NewAttacher()
|
||||
}
|
||||
|
||||
@@ -382,7 +381,7 @@ func (plugin *FakeVolumePlugin) GetNewAttacherCallCount() int {
|
||||
return plugin.NewAttacherCallCount
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) NewDetacher() (Detacher, error) {
|
||||
func (plugin *FakeVolumePlugin) NewDetacher() (volume.Detacher, error) {
|
||||
plugin.Lock()
|
||||
defer plugin.Unlock()
|
||||
plugin.NewDetacherCallCount = plugin.NewDetacherCallCount + 1
|
||||
@@ -398,7 +397,7 @@ func (plugin *FakeVolumePlugin) NewDetacher() (Detacher, error) {
|
||||
return detacher, nil
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) NewDeviceUnmounter() (DeviceUnmounter, error) {
|
||||
func (plugin *FakeVolumePlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) {
|
||||
return plugin.NewDetacher()
|
||||
}
|
||||
|
||||
@@ -414,23 +413,23 @@ func (plugin *FakeVolumePlugin) GetNewDetacherCallCount() int {
|
||||
return plugin.NewDetacherCallCount
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) CanAttach(spec *Spec) (bool, error) {
|
||||
func (plugin *FakeVolumePlugin) CanAttach(spec *volume.Spec) (bool, error) {
|
||||
return !plugin.NonAttachable, nil
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) CanDeviceMount(spec *Spec) (bool, error) {
|
||||
func (plugin *FakeVolumePlugin) CanDeviceMount(spec *volume.Spec) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) Recycle(pvName string, spec *Spec, eventRecorder recyclerclient.RecycleEventRecorder) error {
|
||||
func (plugin *FakeVolumePlugin) Recycle(pvName string, spec *volume.Spec, eventRecorder recyclerclient.RecycleEventRecorder) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) NewDeleter(spec *Spec) (Deleter, error) {
|
||||
return &FakeDeleter{"/attributesTransferredFromSpec", MetricsNil{}}, nil
|
||||
func (plugin *FakeVolumePlugin) NewDeleter(spec *volume.Spec) (volume.Deleter, error) {
|
||||
return &FakeDeleter{"/attributesTransferredFromSpec", volume.MetricsNil{}}, nil
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) NewProvisioner(options VolumeOptions) (Provisioner, error) {
|
||||
func (plugin *FakeVolumePlugin) NewProvisioner(options volume.VolumeOptions) (volume.Provisioner, error) {
|
||||
plugin.Lock()
|
||||
defer plugin.Unlock()
|
||||
plugin.LastProvisionerOptions = options
|
||||
@@ -441,8 +440,8 @@ func (plugin *FakeVolumePlugin) GetAccessModes() []v1.PersistentVolumeAccessMode
|
||||
return []v1.PersistentVolumeAccessMode{}
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*Spec, error) {
|
||||
return &Spec{
|
||||
func (plugin *FakeVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
||||
return &volume.Spec{
|
||||
Volume: &v1.Volume{
|
||||
Name: volumeName,
|
||||
},
|
||||
@@ -450,8 +449,8 @@ func (plugin *FakeVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
func (plugin *FakeVolumePlugin) ConstructBlockVolumeSpec(podUID types.UID, volumeName, mountPath string) (*Spec, error) {
|
||||
return &Spec{
|
||||
func (plugin *FakeVolumePlugin) ConstructBlockVolumeSpec(podUID types.UID, volumeName, mountPath string) (*volume.Spec, error) {
|
||||
return &volume.Spec{
|
||||
Volume: &v1.Volume{
|
||||
Name: volumeName,
|
||||
},
|
||||
@@ -463,7 +462,7 @@ func (plugin *FakeVolumePlugin) GetDeviceMountRefs(deviceMountPath string) ([]st
|
||||
}
|
||||
|
||||
// Expandable volume support
|
||||
func (plugin *FakeVolumePlugin) ExpandVolumeDevice(spec *Spec, newSize resource.Quantity, oldSize resource.Quantity) (resource.Quantity, error) {
|
||||
func (plugin *FakeVolumePlugin) ExpandVolumeDevice(spec *volume.Spec, newSize resource.Quantity, oldSize resource.Quantity) (resource.Quantity, error) {
|
||||
return resource.Quantity{}, nil
|
||||
}
|
||||
|
||||
@@ -471,7 +470,7 @@ func (plugin *FakeVolumePlugin) RequiresFSResize() bool {
|
||||
return !plugin.DisableNodeExpansion
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) NodeExpand(resizeOptions NodeResizeOptions) (bool, error) {
|
||||
func (plugin *FakeVolumePlugin) NodeExpand(resizeOptions volume.NodeResizeOptions) (bool, error) {
|
||||
plugin.NodeExpandCallCount++
|
||||
if resizeOptions.VolumeSpec.Name() == FailWithInUseVolumeName {
|
||||
return false, volumetypes.NewFailedPreconditionError("volume-in-use")
|
||||
@@ -490,7 +489,7 @@ func (plugin *FakeVolumePlugin) GetVolumeLimits() (map[string]int64, error) {
|
||||
return plugin.VolumeLimits, plugin.VolumeLimitsError
|
||||
}
|
||||
|
||||
func (plugin *FakeVolumePlugin) VolumeLimitKey(spec *Spec) string {
|
||||
func (plugin *FakeVolumePlugin) VolumeLimitKey(spec *volume.Spec) string {
|
||||
return plugin.LimitKey
|
||||
}
|
||||
|
||||
@@ -505,30 +504,30 @@ func (f *FakeBasicVolumePlugin) GetPluginName() string {
|
||||
return f.Plugin.GetPluginName()
|
||||
}
|
||||
|
||||
func (f *FakeBasicVolumePlugin) GetVolumeName(spec *Spec) (string, error) {
|
||||
func (f *FakeBasicVolumePlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||
return f.Plugin.GetVolumeName(spec)
|
||||
}
|
||||
|
||||
// CanSupport tests whether the plugin supports a given volume specification by
|
||||
// testing volume spec name begins with plugin name or not.
|
||||
// This is useful to choose plugin by volume in testing.
|
||||
func (f *FakeBasicVolumePlugin) CanSupport(spec *Spec) bool {
|
||||
func (f *FakeBasicVolumePlugin) CanSupport(spec *volume.Spec) bool {
|
||||
return strings.HasPrefix(spec.Name(), f.GetPluginName())
|
||||
}
|
||||
|
||||
func (f *FakeBasicVolumePlugin) ConstructVolumeSpec(ame, mountPath string) (*Spec, error) {
|
||||
func (f *FakeBasicVolumePlugin) ConstructVolumeSpec(ame, mountPath string) (*volume.Spec, error) {
|
||||
return f.Plugin.ConstructVolumeSpec(ame, mountPath)
|
||||
}
|
||||
|
||||
func (f *FakeBasicVolumePlugin) Init(ost VolumeHost) error {
|
||||
func (f *FakeBasicVolumePlugin) Init(ost volume.VolumeHost) error {
|
||||
return f.Plugin.Init(ost)
|
||||
}
|
||||
|
||||
func (f *FakeBasicVolumePlugin) NewMounter(spec *Spec, pod *v1.Pod, opts VolumeOptions) (Mounter, error) {
|
||||
func (f *FakeBasicVolumePlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, opts volume.VolumeOptions) (volume.Mounter, error) {
|
||||
return f.Plugin.NewMounter(spec, pod, opts)
|
||||
}
|
||||
|
||||
func (f *FakeBasicVolumePlugin) NewUnmounter(volName string, podUID types.UID) (Unmounter, error) {
|
||||
func (f *FakeBasicVolumePlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) {
|
||||
return f.Plugin.NewUnmounter(volName, podUID)
|
||||
}
|
||||
|
||||
@@ -544,22 +543,22 @@ func (f *FakeBasicVolumePlugin) SupportsMountOption() bool {
|
||||
return f.Plugin.SupportsMountOption()
|
||||
}
|
||||
|
||||
var _ VolumePlugin = &FakeBasicVolumePlugin{}
|
||||
var _ volume.VolumePlugin = &FakeBasicVolumePlugin{}
|
||||
|
||||
// FakeDeviceMountableVolumePlugin implements an device mountable plugin based on FakeBasicVolumePlugin.
|
||||
type FakeDeviceMountableVolumePlugin struct {
|
||||
FakeBasicVolumePlugin
|
||||
}
|
||||
|
||||
func (f *FakeDeviceMountableVolumePlugin) CanDeviceMount(spec *Spec) (bool, error) {
|
||||
func (f *FakeDeviceMountableVolumePlugin) CanDeviceMount(spec *volume.Spec) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (f *FakeDeviceMountableVolumePlugin) NewDeviceMounter() (DeviceMounter, error) {
|
||||
func (f *FakeDeviceMountableVolumePlugin) NewDeviceMounter() (volume.DeviceMounter, error) {
|
||||
return f.Plugin.NewDeviceMounter()
|
||||
}
|
||||
|
||||
func (f *FakeDeviceMountableVolumePlugin) NewDeviceUnmounter() (DeviceUnmounter, error) {
|
||||
func (f *FakeDeviceMountableVolumePlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) {
|
||||
return f.Plugin.NewDeviceUnmounter()
|
||||
}
|
||||
|
||||
@@ -567,33 +566,33 @@ func (f *FakeDeviceMountableVolumePlugin) GetDeviceMountRefs(deviceMountPath str
|
||||
return f.Plugin.GetDeviceMountRefs(deviceMountPath)
|
||||
}
|
||||
|
||||
var _ VolumePlugin = &FakeDeviceMountableVolumePlugin{}
|
||||
var _ DeviceMountableVolumePlugin = &FakeDeviceMountableVolumePlugin{}
|
||||
var _ volume.VolumePlugin = &FakeDeviceMountableVolumePlugin{}
|
||||
var _ volume.DeviceMountableVolumePlugin = &FakeDeviceMountableVolumePlugin{}
|
||||
|
||||
// FakeAttachableVolumePlugin implements an attachable plugin based on FakeDeviceMountableVolumePlugin.
|
||||
type FakeAttachableVolumePlugin struct {
|
||||
FakeDeviceMountableVolumePlugin
|
||||
}
|
||||
|
||||
func (f *FakeAttachableVolumePlugin) NewAttacher() (Attacher, error) {
|
||||
func (f *FakeAttachableVolumePlugin) NewAttacher() (volume.Attacher, error) {
|
||||
return f.Plugin.NewAttacher()
|
||||
}
|
||||
|
||||
func (f *FakeAttachableVolumePlugin) NewDetacher() (Detacher, error) {
|
||||
func (f *FakeAttachableVolumePlugin) NewDetacher() (volume.Detacher, error) {
|
||||
return f.Plugin.NewDetacher()
|
||||
}
|
||||
|
||||
func (f *FakeAttachableVolumePlugin) CanAttach(spec *Spec) (bool, error) {
|
||||
func (f *FakeAttachableVolumePlugin) CanAttach(spec *volume.Spec) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
var _ VolumePlugin = &FakeAttachableVolumePlugin{}
|
||||
var _ AttachableVolumePlugin = &FakeAttachableVolumePlugin{}
|
||||
var _ volume.VolumePlugin = &FakeAttachableVolumePlugin{}
|
||||
var _ volume.AttachableVolumePlugin = &FakeAttachableVolumePlugin{}
|
||||
|
||||
type FakeFileVolumePlugin struct {
|
||||
}
|
||||
|
||||
func (plugin *FakeFileVolumePlugin) Init(host VolumeHost) error {
|
||||
func (plugin *FakeFileVolumePlugin) Init(host volume.VolumeHost) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -601,11 +600,11 @@ func (plugin *FakeFileVolumePlugin) GetPluginName() string {
|
||||
return "fake-file-plugin"
|
||||
}
|
||||
|
||||
func (plugin *FakeFileVolumePlugin) GetVolumeName(spec *Spec) (string, error) {
|
||||
func (plugin *FakeFileVolumePlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (plugin *FakeFileVolumePlugin) CanSupport(spec *Spec) bool {
|
||||
func (plugin *FakeFileVolumePlugin) CanSupport(spec *volume.Spec) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -621,20 +620,20 @@ func (plugin *FakeFileVolumePlugin) SupportsBulkVolumeVerification() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (plugin *FakeFileVolumePlugin) NewMounter(spec *Spec, podRef *v1.Pod, opts VolumeOptions) (Mounter, error) {
|
||||
func (plugin *FakeFileVolumePlugin) NewMounter(spec *volume.Spec, podRef *v1.Pod, opts volume.VolumeOptions) (volume.Mounter, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (plugin *FakeFileVolumePlugin) NewUnmounter(name string, podUID types.UID) (Unmounter, error) {
|
||||
func (plugin *FakeFileVolumePlugin) NewUnmounter(name string, podUID types.UID) (volume.Unmounter, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (plugin *FakeFileVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*Spec, error) {
|
||||
func (plugin *FakeFileVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewFakeFileVolumePlugin() []VolumePlugin {
|
||||
return []VolumePlugin{&FakeFileVolumePlugin{}}
|
||||
func NewFakeFileVolumePlugin() []volume.VolumePlugin {
|
||||
return []volume.VolumePlugin{&FakeFileVolumePlugin{}}
|
||||
}
|
||||
|
||||
type FakeVolume struct {
|
||||
@@ -642,13 +641,13 @@ type FakeVolume struct {
|
||||
PodUID types.UID
|
||||
VolName string
|
||||
Plugin *FakeVolumePlugin
|
||||
MetricsNil
|
||||
volume.MetricsNil
|
||||
VolumesAttached map[string]sets.String
|
||||
DeviceMountState map[string]string
|
||||
VolumeMountState map[string]string
|
||||
|
||||
// Add callbacks as needed
|
||||
WaitForAttachHook func(spec *Spec, devicePath string, pod *v1.Pod, spectimeout time.Duration) (string, error)
|
||||
WaitForAttachHook func(spec *volume.Spec, devicePath string, pod *v1.Pod, spectimeout time.Duration) (string, error)
|
||||
UnmountDeviceHook func(globalMountPath string) error
|
||||
|
||||
SetUpCallCount int
|
||||
@@ -667,7 +666,7 @@ type FakeVolume struct {
|
||||
PodDeviceMapPathCallCount int
|
||||
}
|
||||
|
||||
func getUniqueVolumeName(spec *Spec) (string, error) {
|
||||
func getUniqueVolumeName(spec *volume.Spec) (string, error) {
|
||||
var volumeName string
|
||||
if spec.Volume != nil && spec.Volume.GCEPersistentDisk != nil {
|
||||
volumeName = spec.Volume.GCEPersistentDisk.PDName
|
||||
@@ -681,15 +680,15 @@ func getUniqueVolumeName(spec *Spec) (string, error) {
|
||||
return volumeName, nil
|
||||
}
|
||||
|
||||
func (_ *FakeVolume) GetAttributes() Attributes {
|
||||
return Attributes{
|
||||
func (_ *FakeVolume) GetAttributes() volume.Attributes {
|
||||
return volume.Attributes{
|
||||
ReadOnly: false,
|
||||
Managed: true,
|
||||
SELinuxRelabel: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) SetUp(mounterArgs MounterArgs) error {
|
||||
func (fv *FakeVolume) SetUp(mounterArgs volume.MounterArgs) error {
|
||||
fv.Lock()
|
||||
defer fv.Unlock()
|
||||
err := fv.setupInternal(mounterArgs)
|
||||
@@ -697,7 +696,7 @@ func (fv *FakeVolume) SetUp(mounterArgs MounterArgs) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) setupInternal(mounterArgs MounterArgs) error {
|
||||
func (fv *FakeVolume) setupInternal(mounterArgs volume.MounterArgs) error {
|
||||
if fv.VolName == TimeoutOnSetupVolumeName {
|
||||
fv.VolumeMountState[fv.VolName] = volumeMountUncertain
|
||||
return volumetypes.NewUncertainProgressError("time out on setup")
|
||||
@@ -745,7 +744,7 @@ func (fv *FakeVolume) GetSetUpCallCount() int {
|
||||
return fv.SetUpCallCount
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) SetUpAt(dir string, mounterArgs MounterArgs) error {
|
||||
func (fv *FakeVolume) SetUpAt(dir string, mounterArgs volume.MounterArgs) error {
|
||||
return os.MkdirAll(dir, 0750)
|
||||
}
|
||||
|
||||
@@ -831,7 +830,7 @@ func (fv *FakeVolume) GetSetUpDeviceCallCount() int {
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
func (fv *FakeVolume) GetGlobalMapPath(spec *Spec) (string, error) {
|
||||
func (fv *FakeVolume) GetGlobalMapPath(spec *volume.Spec) (string, error) {
|
||||
fv.RLock()
|
||||
defer fv.RUnlock()
|
||||
fv.GlobalMapPathCallCount++
|
||||
@@ -954,7 +953,7 @@ func (fv *FakeVolume) GetMapPodDeviceCallCount() int {
|
||||
return fv.MapPodDeviceCallCount
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) Attach(spec *Spec, nodeName types.NodeName) (string, error) {
|
||||
func (fv *FakeVolume) Attach(spec *volume.Spec, nodeName types.NodeName) (string, error) {
|
||||
fv.Lock()
|
||||
defer fv.Unlock()
|
||||
fv.AttachCallCount++
|
||||
@@ -993,7 +992,7 @@ func (fv *FakeVolume) GetAttachCallCount() int {
|
||||
return fv.AttachCallCount
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) WaitForAttach(spec *Spec, devicePath string, pod *v1.Pod, spectimeout time.Duration) (string, error) {
|
||||
func (fv *FakeVolume) WaitForAttach(spec *volume.Spec, devicePath string, pod *v1.Pod, spectimeout time.Duration) (string, error) {
|
||||
fv.Lock()
|
||||
defer fv.Unlock()
|
||||
fv.WaitForAttachCallCount++
|
||||
@@ -1009,14 +1008,14 @@ func (fv *FakeVolume) GetWaitForAttachCallCount() int {
|
||||
return fv.WaitForAttachCallCount
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) GetDeviceMountPath(spec *Spec) (string, error) {
|
||||
func (fv *FakeVolume) GetDeviceMountPath(spec *volume.Spec) (string, error) {
|
||||
fv.Lock()
|
||||
defer fv.Unlock()
|
||||
fv.GetDeviceMountPathCallCount++
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) mountDeviceInternal(spec *Spec, devicePath string, deviceMountPath string) error {
|
||||
func (fv *FakeVolume) mountDeviceInternal(spec *volume.Spec, devicePath string, deviceMountPath string) error {
|
||||
fv.Lock()
|
||||
defer fv.Unlock()
|
||||
if spec.Name() == TimeoutOnMountDeviceVolumeName {
|
||||
@@ -1058,7 +1057,7 @@ func (fv *FakeVolume) mountDeviceInternal(spec *Spec, devicePath string, deviceM
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) MountDevice(spec *Spec, devicePath string, deviceMountPath string, _ volume.DeviceMounterArgs) error {
|
||||
func (fv *FakeVolume) MountDevice(spec *volume.Spec, devicePath string, deviceMountPath string, _ volume.DeviceMounterArgs) error {
|
||||
return fv.mountDeviceInternal(spec, devicePath, deviceMountPath)
|
||||
}
|
||||
|
||||
@@ -1097,7 +1096,7 @@ func (fv *FakeVolume) Detach(volumeName string, nodeName types.NodeName) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) VolumesAreAttached(spec []*Spec, nodeName types.NodeName) (map[*Spec]bool, error) {
|
||||
func (fv *FakeVolume) VolumesAreAttached(spec []*volume.Spec, nodeName types.NodeName) (map[*volume.Spec]bool, error) {
|
||||
fv.Lock()
|
||||
defer fv.Unlock()
|
||||
return nil, nil
|
||||
@@ -1121,7 +1120,7 @@ func (fv *FakeVolume) UnmountDevice(globalMountPath string) error {
|
||||
|
||||
type FakeDeleter struct {
|
||||
path string
|
||||
MetricsNil
|
||||
volume.MetricsNil
|
||||
}
|
||||
|
||||
func (fd *FakeDeleter) Delete() error {
|
||||
@@ -1134,8 +1133,8 @@ func (fd *FakeDeleter) GetPath() string {
|
||||
}
|
||||
|
||||
type FakeProvisioner struct {
|
||||
Options VolumeOptions
|
||||
Host VolumeHost
|
||||
Options volume.VolumeOptions
|
||||
Host volume.VolumeHost
|
||||
ProvisionDelaySeconds int
|
||||
}
|
||||
|
||||
@@ -1626,8 +1625,8 @@ func VerifyGetMapPodDeviceCallCount(
|
||||
|
||||
// GetTestVolumePluginMgr creates, initializes, and returns a test volume plugin
|
||||
// manager and fake volume plugin using a fake volume host.
|
||||
func GetTestVolumePluginMgr(t *testing.T) (*VolumePluginMgr, *FakeVolumePlugin) {
|
||||
plugins := ProbeVolumePlugins(VolumeConfig{})
|
||||
func GetTestVolumePluginMgr(t *testing.T) (*volume.VolumePluginMgr, *FakeVolumePlugin) {
|
||||
plugins := ProbeVolumePlugins(volume.VolumeConfig{})
|
||||
v := NewFakeVolumeHost(
|
||||
t,
|
||||
"", /* rootDir */
|
||||
@@ -1637,8 +1636,8 @@ func GetTestVolumePluginMgr(t *testing.T) (*VolumePluginMgr, *FakeVolumePlugin)
|
||||
return v.GetPluginMgr(), plugins[0].(*FakeVolumePlugin)
|
||||
}
|
||||
|
||||
func GetTestKubeletVolumePluginMgr(t *testing.T) (*VolumePluginMgr, *FakeVolumePlugin) {
|
||||
plugins := ProbeVolumePlugins(VolumeConfig{})
|
||||
func GetTestKubeletVolumePluginMgr(t *testing.T) (*volume.VolumePluginMgr, *FakeVolumePlugin) {
|
||||
plugins := ProbeVolumePlugins(volume.VolumeConfig{})
|
||||
v := NewFakeKubeletVolumeHost(
|
||||
t,
|
||||
"", /* rootDir */
|
||||
@@ -1648,8 +1647,8 @@ func GetTestKubeletVolumePluginMgr(t *testing.T) (*VolumePluginMgr, *FakeVolumeP
|
||||
return v.GetPluginMgr(), plugins[0].(*FakeVolumePlugin)
|
||||
}
|
||||
|
||||
func GetTestKubeletVolumePluginMgrWithNode(t *testing.T, node *v1.Node) (*VolumePluginMgr, *FakeVolumePlugin) {
|
||||
plugins := ProbeVolumePlugins(VolumeConfig{})
|
||||
func GetTestKubeletVolumePluginMgrWithNode(t *testing.T, node *v1.Node) (*volume.VolumePluginMgr, *FakeVolumePlugin) {
|
||||
plugins := ProbeVolumePlugins(volume.VolumeConfig{})
|
||||
v := NewFakeKubeletVolumeHost(
|
||||
t,
|
||||
"", /* rootDir */
|
||||
@@ -1680,7 +1679,7 @@ func CreateTestPVC(capacity string, accessModes []v1.PersistentVolumeAccessMode)
|
||||
return &claim
|
||||
}
|
||||
|
||||
func MetricsEqualIgnoreTimestamp(a *Metrics, b *Metrics) bool {
|
||||
func MetricsEqualIgnoreTimestamp(a *volume.Metrics, b *volume.Metrics) bool {
|
||||
available := a.Available == b.Available
|
||||
capacity := a.Capacity == b.Capacity
|
||||
used := a.Used == b.Used
|
||||
|
||||
Reference in New Issue
Block a user