util

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 27 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 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 DetachAnyLoopbackDevice

func DetachAnyLoopbackDevice(file 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 ExtractNames

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

func Freeze

func Freeze(mountpoint string) error

func GenerateName

func GenerateName(prefix string) string

func GetChecksum

func GetChecksum(data []byte) string

func GetFieldFromOpts

func GetFieldFromOpts(name string, opts map[string]string) (string, error)

func GetFileChecksum

func GetFileChecksum(filePath string) (string, error)

func GetFlag

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 InitMountNamespace

func InitMountNamespace(fd string) error

func InitTimeout

func InitTimeout(timeout string)

func IsNotExistsError

func IsNotExistsError(err error) bool

func ListConfigIDs

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

func ListLoopbackDevice

func ListLoopbackDevice(file 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

func MountPointPrepareBlockDevice(mp string, dev string) error

func MountPointPrepareImageFile

func MountPointPrepareImageFile(mp string, size int64) error

func MountPointRemoveFile

func MountPointRemoveFile(file string) error

func NewUUID

func NewUUID() string

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 Sync

func Sync() error

func UnFreeze

func UnFreeze(mountpoint string) error

func UnescapeURL

func UnescapeURL(url string) string

func UnlockFile

func UnlockFile(f *os.File) error

func ValidNetworkAddr

func ValidNetworkAddr(addr string) bool

func ValidateName

func ValidateName(name string) bool

func VolumeMount

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

func VolumeMountPointDirectoryCreate

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

func VolumeMountPointDirectoryRemove

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

func VolumeMountPointFileExists

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

func VolumeUmount

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

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

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

Jump to

Keyboard shortcuts

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