utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DockerdProcess        = "dockerd"
	ContainerdProcess     = "containerd"
	ContainerdProcessShim = "containerd-shim"
)
View Source
const (
	// ProcPath is a vfs storing process info for Linux.
	ProcPath = "/proc"
	// HostProcPath is the convention path where host `/proc` is mounted.
	HostProcPath = "/host/proc"
	// DiskRemoveTag indicates a Longhorn is pending to remove.
	DiskRemoveTag = "harvester-ndm-disk-remove"
)
View Source
const (
	NSBinary = "nsenter"
)

Variables

View Source
var CmdTimeoutError error

Functions

func CallerWithCondLock

func CallerWithCondLock[T any](cond *sync.Cond, f func() T) T

CallerWithLock is a helper function to call a function with a condition lock

func ContainsIgnoredCase

func ContainsIgnoredCase(s []string, k string) bool

ContainsIgnoredCase checks if the item of string slice contains the key with case-insensitive

func ForceUmountWithTimeout added in v0.6.3

func ForceUmountWithTimeout(path string, timeout time.Duration) error

ForceUmountWithTimeout umounts the specific device with timeout to the specified path

func GetFullDevPath

func GetFullDevPath(shortPath string) string

GetFullDevPath will return full path with `/dev/` prefix

func GetHostNamespacePath added in v0.6.3

func GetHostNamespacePath(hostProcPath string) string

func IsFSCorrupted

func IsFSCorrupted(err error) bool

IsFSCorrupted checks if the error is caused by a corrupted filesystem

func IsHostProcMounted

func IsHostProcMounted() (bool, error)

IsHostProcMounted checks if host's proc info `/proc` is mounted on `/host/proc`

func IsSupportedFileSystem

func IsSupportedFileSystem(fsType string) bool

IsSupportedFileSystem checks if the filesystem type is supported

func MakeExt4DiskFormatting

func MakeExt4DiskFormatting(devPath, uuid string) error

MakeExt4DiskFormatting formats the specified volume device to ext4 with the specified UUID return error if failed

func MatchesIgnoredCase

func MatchesIgnoredCase(s []string, k string) bool

MatchesIgnoredCase checks if the item of string slice fully match the key with case-insensitive

func MountDisk

func MountDisk(devPath, mountPoint string) error

MountDisk mounts the specified ext4 volume device to the specified path

func UmountDisk

func UmountDisk(path string) error

UmountDisk unmounts the specified volume device to the specified path

func XMLWriter added in v0.5.3

func XMLWriter(targetFilePath string, xmlData any) error

XMLWriter write XML to target file, make sure your xmlData should valid

Types

type Disk added in v0.5.3

type Disk struct {
	XMLName xml.Name `xml:"disk"`
	Type    string   `xml:"type,attr"`
	Device  string   `xml:"device,attr"`
	Driver  Driver   `xml:"driver"`
	Source  Source   `xml:"source"`
	Target  Target   `xml:"target"`
	WWN     string   `xml:"wwn"`
	VENDOR  string   `xml:"vendor"`
}

func DiskXMLReader added in v0.5.3

func DiskXMLReader(filePath string) (Disk, error)

DiskXMLReader can read the libvirt disk xml file and return a Disk struct

type Driver added in v0.5.3

type Driver struct {
	Name string `xml:"name,attr"`
	Type string `xml:"type,attr"`
}

type Executor added in v0.6.3

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

func NewExecutor added in v0.6.3

func NewExecutor() *Executor

func NewExecutorWithNS added in v0.6.3

func NewExecutorWithNS(ns string) (*Executor, error)

func (*Executor) Execute added in v0.6.3

func (exec *Executor) Execute(cmd string, args []string) (string, error)

func (*Executor) SetTimeout added in v0.6.3

func (exec *Executor) SetTimeout(timeout time.Duration)

type Source added in v0.5.3

type Source struct {
	File string `xml:"file,attr"`
}

type Target added in v0.5.3

type Target struct {
	Dev string `xml:"dev,attr"`
	Bus string `xml:"bus,attr"`
}

Jump to

Keyboard shortcuts

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