util

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2016 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MOUNT_BINARY   = "mount"
	UMOUNT_BINARY  = "umount"
	NSENTER_BINARY = "nsenter"

	IMAGE_FILE_NAME = "disk.img"
	BLOCK_DEV_NAME  = "disk.dev"

	FILE_TYPE_REGULAR     = "regular file"
	FILE_TYPE_DIRECTORY   = "directory"
	FILE_TYPE_BLOCKDEVICE = "block special file"

	FILE_STAT_FORMAT_SIZE        = "%s"
	FILE_STAT_FORMAT_TYPE        = "%F"
	FILE_STAT_FORMAT_MAJOR_MINOR = "%t %T"
)
View Source
const (
	PRESERVED_CHECKSUM_LENGTH = 64
)

Variables

This section is empty.

Functions

func AttachLoopbackDevice

func AttachLoopbackDevice(file string, readonly bool) (string, error)

func CheckBinaryVersion

func CheckBinaryVersion(binaryName, minVersion string, args []string) error

func CheckName

func CheckName(name string) error

func CheckUUID

func CheckUUID(uuid string) error

func CompressData

func CompressData(data []byte) (io.ReadSeeker, error)

func CompressDir

func CompressDir(sourceDir, targetFile string) error

func CompressFile

func CompressFile(filePath string) error

func ConfigExists

func ConfigExists(fileName string) bool

func Copy

func Copy(src, dst string) error

func DecompressAndVerify

func DecompressAndVerify(src io.Reader, checksum string) (io.Reader, error)

func DecompressDir

func DecompressDir(sourceFile, targetDir string) error

If sourceFile is inside targetDir, it would be deleted automatically

func DecompressFile

func DecompressFile(filePath string) error

func DetachLoopbackDevice

func DetachLoopbackDevice(file, dev string) error

func EncodeData

func EncodeData(v interface{}) (*bytes.Buffer, error)

func Execute

func Execute(binary string, args []string) (string, error)

func ExtractUUIDs

func ExtractUUIDs(names []string, prefix, suffix string) ([]string, error)

func GetChecksum

func GetChecksum(data []byte) string

func GetFileChecksum

func GetFileChecksum(filePath string) (string, error)

func GetFlag added in v0.4.1

func GetFlag(v interface{}, key string, required bool, err error) (string, error)

func GetName

func GetName(v interface{}, key string, required bool, err error) (string, error)

func GetUUID

func GetUUID(v interface{}, key string, required bool, err error) (string, error)

func InitMountNamespace added in v0.4.1

func InitMountNamespace(fd string) error

func ListConfigIDs

func ListConfigIDs(root, prefix, suffix string) ([]string, error)

func LoadConfig

func LoadConfig(fileName string, v interface{}) error

func LockFile

func LockFile(fileName string) (*os.File, error)

func MkdirIfNotExists

func MkdirIfNotExists(path string) error

func MountPointPrepareBlockDevice added in v0.4.1

func MountPointPrepareBlockDevice(mp string, dev string) error

func MountPointPrepareImageFile added in v0.4.1

func MountPointPrepareImageFile(mp string, size int64) error

func MountPointRemoveFile added in v0.4.1

func MountPointRemoveFile(file string) error

func Now

func Now() string

func ObjectConfig

func ObjectConfig(obj interface{}) (string, error)

func ObjectDelete

func ObjectDelete(obj interface{}) error

func ObjectExists

func ObjectExists(obj interface{}) (bool, error)

func ObjectLoad

func ObjectLoad(obj interface{}) error

func ObjectSave

func ObjectSave(obj interface{}) error

func ParseSize

func ParseSize(size string) (int64, error)

func RemoveConfig

func RemoveConfig(fileName string) error

func RequiredMissingError

func RequiredMissingError(name string) error

func SaveConfig

func SaveConfig(fileName string, v interface{}) error

func SliceToMap

func SliceToMap(slices []string) map[string]string

func UnescapeURL added in v0.4.1

func UnescapeURL(url string) string

func UnlockFile

func UnlockFile(f *os.File) error

func ValidNetworkAddr added in v0.4.1

func ValidNetworkAddr(addr string) bool

func ValidateName

func ValidateName(name string) bool

func ValidateUUID

func ValidateUUID(s string) bool

func VolumeMount added in v0.4.1

func VolumeMount(v interface{}, mountPoint string, remount bool) (string, error)

func VolumeMountPointDirectoryCreate added in v0.4.1

func VolumeMountPointDirectoryCreate(v interface{}, dirName string) error

func VolumeMountPointDirectoryRemove added in v0.4.1

func VolumeMountPointDirectoryRemove(v interface{}, dirName string) error

func VolumeMountPointFileExists added in v0.4.1

func VolumeMountPointFileExists(v interface{}, file string, expectType string) bool

func VolumeUmount added in v0.4.1

func VolumeUmount(v interface{}) error

Types

type Index

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

func NewIndex

func NewIndex() *Index

func (*Index) Add

func (idx *Index) Add(key, value string) error

func (*Index) Delete

func (idx *Index) Delete(key string) error

func (*Index) Get

func (idx *Index) Get(key string) string

type ObjectOperations

type ObjectOperations interface {
	ConfigFile() (string, error)
}

type VolumeHelper added in v0.4.1

type VolumeHelper interface {
	GetDevice() (string, error)
	GetMountOpts() []string
	GenerateDefaultMountPoint() string
}

Caller must implement VolumeHelper interface, and must have fields "UUID" and "MountPoint"

Jump to

Keyboard shortcuts

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