util

package
v0.0.0-...-2b48260 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 26 Imported by: 17

Documentation

Index

Constants

View Source
const (
	PreservedChecksumLength = 64

	MountDir = "/var/lib/longhorn-backupstore-mounts"
)

Variables

This section is empty.

Functions

func CheckBackupType

func CheckBackupType(backupTarget string) (string, error)

func CleanUpMountPoints

func CleanUpMountPoints(mounter mount.Interface, log logrus.FieldLogger) error

CleanUpMountPoints tries to clean up all existing mount points for existing backup stores

func CompressData

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

CompressData compresses the given data using the specified compression method

func DecompressAndVerify

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

DecompressAndVerify decompresses the given data and verifies the data integrity

func EnsureMountPoint

func EnsureMountPoint(Kind, mountPoint string, mounter mount.Interface, log logrus.FieldLogger) (mounted bool, err error)

EnsureMountPoint checks if the mount point is valid. If it is invalid, clean up mount point.

func Execute

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

Execute executes a command

func ExecuteWithCustomTimeout

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

ExecuteWithCustomTimeout executes a command with a specified timeout

func ExtractNames

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

func Filter

func Filter(elements []string, predicate func(string) bool) []string

func GenerateName

func GenerateName(prefix string) string

GenerateName generates a 16-byte name

func GetBackupCredential

func GetBackupCredential(backupURL string) (map[string]string, error)

func GetChecksum

func GetChecksum(data []byte) string

GetChecksum gets the SHA256 of the given data

func GetFileChecksum

func GetFileChecksum(filePath string) (string, error)

GetFileChecksum calculates the SHA256 of the file's content

func IsMounted

func IsMounted(mountPoint string) bool

IsMounted checks if the mount point is mounted

func MountWithTimeout

func MountWithTimeout(mounter mount.Interface, source string, target string, fstype string,
	options []string, sensitiveOptions []string, interval, timeout time.Duration) error

MountWithTimeout mounts the backup store to a given mount point with a specified timeout

func NewUUID

func NewUUID() string

NewUUID generates an UUID

func Now

func Now() string

func SetupCredential

func SetupCredential(backupType string, credential map[string]string) error

func SplitMountOptions

func SplitMountOptions(options []string) []string

func UnescapeURL

func UnescapeURL(url string) string

UnescapeURL converts a escape character to a normal one.

func UnorderedEqual

func UnorderedEqual(x, y []string) bool

func ValidateName

func ValidateName(name string) bool

ValidateName validate the given string

Types

type NopCloser

type NopCloser struct {
	io.Writer
}

NopCloser wraps an io.Witer as io.WriteCloser with noop Close

func (NopCloser) Close

func (NopCloser) Close() error

Jump to

Keyboard shortcuts

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