mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Merge pull request #112803 from pohly/pod-io-rename
e2e storage: add Rename to PodIO
This commit is contained in:
commit
c5ab06f4c7
@ -71,6 +71,9 @@ type DirIO interface {
|
||||
Mkdir(path string) error
|
||||
// RemoveAll removes the path and everything contained inside it. It's not an error if the path does not exist.
|
||||
RemoveAll(path string) error
|
||||
// Rename changes the name of a file or directory. The parent directory
|
||||
// of newPath must exist.
|
||||
Rename(oldPath, newPath string) error
|
||||
}
|
||||
|
||||
type OSDirIO struct{}
|
||||
@ -97,6 +100,10 @@ func (o OSDirIO) RemoveAll(path string) error {
|
||||
return os.RemoveAll(path)
|
||||
}
|
||||
|
||||
func (o OSDirIO) Rename(oldPath, newPath string) error {
|
||||
return os.Rename(oldPath, newPath)
|
||||
}
|
||||
|
||||
// Service is the CSI Mock service provider.
|
||||
type Service interface {
|
||||
csi.ControllerServer
|
||||
|
@ -70,6 +70,14 @@ func (p PodDirIO) CreateFile(path string, content io.Reader) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p PodDirIO) Rename(oldPath, newPath string) error {
|
||||
_, stderr, err := p.execute([]string{"mv", oldPath, newPath}, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("rename %q -> %q: stderr=%q, %v", oldPath, newPath, stderr, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p PodDirIO) RemoveAll(path string) error {
|
||||
_, stderr, err := p.execute([]string{"rm", "-rf", path}, nil)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user