mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: add NFS volume type
This commit is contained in:
21
internal/modules/volumes/utils.go
Normal file
21
internal/modules/volumes/utils.go
Normal 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
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user