util

package
v2.3.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FakeEntryFile is mock dir entry of type file.
	FakeEntryFile = "file"
	// FakeEntryBlock is mock dir entry of type block.
	FakeEntryBlock = "block"
	// FakeEntryUnknown is mock dir entry of type unknown.
	FakeEntryUnknown = "unknown"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIUtil

type APIUtil interface {
	// Create PersistentVolume object
	CreatePV(pv *v1.PersistentVolume) (*v1.PersistentVolume, error)

	// Delete PersistentVolume object
	DeletePV(pvName string) error

	// CreateJob Creates a Job execution.
	CreateJob(job *batch_v1.Job) error

	// DeleteJob deletes specified Job by its name and namespace.
	DeleteJob(jobName string, namespace string) error
}

APIUtil is an interface for the K8s API

func NewAPIUtil

func NewAPIUtil(client *kubernetes.Clientset) APIUtil

NewAPIUtil creates a new APIUtil object that represents the K8s API

type FakeAPIUtil

type FakeAPIUtil struct {
	CreatedJobs map[string]*batch_v1.Job
	DeletedJobs map[string]string
	// contains filtered or unexported fields
}

FakeAPIUtil is a fake API wrapper for unit testing

func NewFakeAPIUtil

func NewFakeAPIUtil(shouldFail bool, cache *cache.VolumeCache) *FakeAPIUtil

NewFakeAPIUtil returns an APIUtil object that can be used for unit testing

func (*FakeAPIUtil) CreateJob

func (u *FakeAPIUtil) CreateJob(job *batch_v1.Job) error

CreateJob mocks job create method.

func (*FakeAPIUtil) CreatePV

func (u *FakeAPIUtil) CreatePV(pv *v1.PersistentVolume) (*v1.PersistentVolume, error)

CreatePV will add the PV to the created list and cache

func (*FakeAPIUtil) DeleteJob

func (u *FakeAPIUtil) DeleteJob(jobName string, namespace string) error

DeleteJob mocks delete jon method.

func (*FakeAPIUtil) DeletePV

func (u *FakeAPIUtil) DeletePV(pvName string) error

DeletePV will delete the PV from the created list and cache, and also add it to the deleted list

func (*FakeAPIUtil) GetAndResetCreatedPVs

func (u *FakeAPIUtil) GetAndResetCreatedPVs() map[string]*v1.PersistentVolume

GetAndResetCreatedPVs returns createdPVs and resets the map This is only for testing

func (*FakeAPIUtil) GetAndResetDeletedPVs

func (u *FakeAPIUtil) GetAndResetDeletedPVs() map[string]*v1.PersistentVolume

GetAndResetDeletedPVs returns createdPVs and resets the map This is only for testing

type FakeDirEntry

type FakeDirEntry struct {
	Name       string
	VolumeType string
	// Expected hash value of the PV name
	Hash     uint32
	Capacity int64
}

FakeDirEntry contains a representation of a file under a directory

type FakeVolumeUtil

type FakeVolumeUtil struct {
	// contains filtered or unexported fields
}

FakeVolumeUtil is a stub interface for unit testing

func NewFakeVolumeUtil

func NewFakeVolumeUtil(deleteShouldFail bool, dirFiles map[string][]*FakeDirEntry) *FakeVolumeUtil

NewFakeVolumeUtil returns a VolumeUtil object for use in unit testing

func (*FakeVolumeUtil) AddNewDirEntries

func (u *FakeVolumeUtil) AddNewDirEntries(mountDir string, dirFiles map[string][]*FakeDirEntry)

AddNewDirEntries adds the given files to the current directory listing This is only for testing

func (*FakeVolumeUtil) DeleteContents

func (u *FakeVolumeUtil) DeleteContents(fullPath string) error

DeleteContents removes all the contents under the given directory

func (*FakeVolumeUtil) GetBlockCapacityByte

func (u *FakeVolumeUtil) GetBlockCapacityByte(fullPath string) (int64, error)

GetBlockCapacityByte returns the space in the specified block device.

func (*FakeVolumeUtil) GetFsCapacityByte

func (u *FakeVolumeUtil) GetFsCapacityByte(fullPath string) (int64, error)

GetFsCapacityByte returns capacity in byte about a mounted filesystem.

func (*FakeVolumeUtil) IsBlock

func (u *FakeVolumeUtil) IsBlock(fullPath string) (bool, error)

IsBlock checks if the given path is a block device

func (*FakeVolumeUtil) IsDir

func (u *FakeVolumeUtil) IsDir(fullPath string) (bool, error)

IsDir checks if the given path is a directory

func (*FakeVolumeUtil) ReadDir

func (u *FakeVolumeUtil) ReadDir(fullPath string) ([]string, error)

ReadDir returns the list of all files under the given directory

type VolumeUtil

type VolumeUtil interface {
	// IsDir checks if the given path is a directory
	IsDir(fullPath string) (bool, error)

	// IsBlock checks if the given path is a directory
	IsBlock(fullPath string) (bool, error)

	// ReadDir returns a list of files under the specified directory
	ReadDir(fullPath string) ([]string, error)

	// Delete all the contents under the given path, but not the path itself
	DeleteContents(fullPath string) error

	// Get capacity for fs on full path
	GetFsCapacityByte(fullPath string) (int64, error)

	// Get capacity of the block device
	GetBlockCapacityByte(fullPath string) (int64, error)
}

VolumeUtil is an interface for local filesystem operations

func NewVolumeUtil

func NewVolumeUtil() VolumeUtil

NewVolumeUtil returns a VolumeUtil object for performing local filesystem operations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL