util

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPClientErrorPrefixTemplate = "resp.StatusCode(%d) != http.StatusOK(200)"

	EnvPodIP = "POD_IP"

	StorageNetworkInterface = "lhnet1"
)
View Source
const (
	DiskConfigFile = "longhorn-disk.cfg"
)

DiskConfigFile should be the same as the schema in longhorn-manager/util

View Source
const (
	QemuImgBinary = "qemu-img"
)
View Source
const (
	SyncingFileConfigFileSuffix = ".cfg"
)

Variables

View Source
var (
	MaximumBackingImageNameSize = 64
)

Functions

func CheckBackupType added in v1.6.0

func CheckBackupType(backupTarget string) (string, error)

func ConvertFromRawToQcow2

func ConvertFromRawToQcow2(filePath string) error

func CopyFile

func CopyFile(srcPath, dstPath string) (int64, error)

func DetectFileFormat

func DetectFileFormat(filePath string) (string, error)

func DetectGRPCServerAvailability

func DetectGRPCServerAvailability(address string, waitIntervalInSecond int, shouldAvailable bool) bool

func DetectHTTPServerAvailability

func DetectHTTPServerAvailability(url string, waitIntervalInSecond int, shouldAvailable bool) bool

func Execute

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

func ExecuteWithTimeout

func ExecuteWithTimeout(timeout time.Duration, envs []string, binary string, args ...string) (string, error)

func FileModificationTime

func FileModificationTime(filePath string) string

func GetDiskConfig

func GetDiskConfig(diskPath string) (string, error)

func GetFileChecksum

func GetFileChecksum(filePath string) (string, error)

func GetHTTPClientErrorPrefix

func GetHTTPClientErrorPrefix(stateCode int) string

func GetIPForPod

func GetIPForPod() (ip string, err error)

func GetLocalIPv4fromInterface

func GetLocalIPv4fromInterface(name string) (ip string, err error)

func GetSyncServiceAddressWithPodIP added in v1.5.4

func GetSyncServiceAddressWithPodIP(address string) (string, error)

func GetSyncingFileConfigFilePath

func GetSyncingFileConfigFilePath(syncingFilePath string) string

func GunzipFile added in v1.5.4

func GunzipFile(filePath string, dstFilePath string) error

func IsGRPCErrorMatchingCode

func IsGRPCErrorMatchingCode(err error, errCode codes.Code) bool

func IsGRPCErrorNotFound

func IsGRPCErrorNotFound(err error) bool

func IsHTTPClientErrorNotFound

func IsHTTPClientErrorNotFound(inputErr error) bool

func PrintJSON

func PrintJSON(obj interface{}) error

func ValidBackingImageName added in v1.6.0

func ValidBackingImageName(name string) bool

func WriteSyncingFileConfig

func WriteSyncingFileConfig(configFilePath string, config *SyncingFileConfig) (err error)

Types

type Bitmap

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

func NewBitmap

func NewBitmap(start, end int32) *Bitmap

NewBitmap allocate a bitmap range from [start, end], notice the end is included

func (*Bitmap) AllocateRange

func (b *Bitmap) AllocateRange(count int32) (int32, int32, error)

func (*Bitmap) ReleaseRange

func (b *Bitmap) ReleaseRange(start, end int32) error

type DiskConfig

type DiskConfig struct {
	DiskUUID string `json:"diskUUID"`
}

type SyncingFileConfig

type SyncingFileConfig struct {
	FilePath         string `json:"name"`
	UUID             string `json:"uuid"`
	Size             int64  `json:"size"`
	ExpectedChecksum string `json:"expectedChecksum"`
	CurrentChecksum  string `json:"currentChecksum"`
	ModificationTime string `json:"modificationTime"`
}

func ReadSyncingFileConfig

func ReadSyncingFileConfig(configFilePath string) (*SyncingFileConfig, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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