feat: add NFS volume type

This commit is contained in:
Nicolas Meienberger
2025-08-20 21:15:30 +02:00
parent d13763995e
commit 83b4296cfc
12 changed files with 310 additions and 31 deletions

View File

@@ -0,0 +1,21 @@
package volumes
import (
"fmt"
"strings"
"k8s.io/utils/mount"
)
func UnmountVolume(path string) error {
mounter := mount.New("")
if err := mounter.Unmount(path); err != nil {
if strings.Contains(err.Error(), "not mounted") || strings.Contains(err.Error(), "No such file or directory") || strings.Contains(err.Error(), "Invalid argument") {
// Volume is not mounted
return nil
}
return fmt.Errorf("failed to unmount volume at %s: %w", path, err)
}
return nil
}