Files
ironmount/go/internal/modules/volumes/utils.go
Nicolas Meienberger a0be690eb9 chore: move to go folder
2025-08-20 22:15:43 +02:00

22 lines
483 B
Go

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
}