util

package
v2.3.2-rc2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 13 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.Interface) APIUtil

NewAPIUtil creates a new APIUtil object that represents the K8s API

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