Extract ephemeral dir path to function so it can be mocked
@@ -80,6 +80,14 @@ import (
const (
PCI_RESOURCE_PREFIX = "PCI_RESOURCE"
MDEV_RESOURCE_PREFIX = "MDEV_PCI_RESOURCE"
+
+ baseEphemeralDiskDir = "/var/run/kubevirt-ephemeral-disks/"
+)
+
+var (
+ getEphemeralDiskBaseDir = func() string {
+ return baseEphemeralDiskDir
+ }
)
type contextStore struct {
@@ -344,7 +352,7 @@ func (l *LibvirtDomainManager) GuestPing(domainName string) error {
}
func getVMIEphemeralDisksTotalSize() *resource.Quantity {
- var baseDir = "/var/run/kubevirt-ephemeral-disks/"
+ baseDir := getEphemeralDiskBaseDir()
totalSize := int64(0)
err := filepath.Walk(baseDir, func(path string, f os.FileInfo, err error) error {
if !f.IsDir() {
