mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 17:38:50 +00:00
Fixing Volumes on Windows
This commit is contained in:
committed by
Paulo Pires
parent
a659ac99b6
commit
66a1ef25e0
@@ -20,10 +20,11 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
filepath "path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
@@ -211,7 +212,7 @@ func (err deletedVolumeInUseError) Error() string {
|
||||
}
|
||||
|
||||
func RenameDirectory(oldPath, newName string) (string, error) {
|
||||
newPath, err := ioutil.TempDir(path.Dir(oldPath), newName)
|
||||
newPath, err := ioutil.TempDir(filepath.Dir(oldPath), newName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -221,6 +222,7 @@ func RenameDirectory(oldPath, newName string) (string, error) {
|
||||
if runtime.GOOS == "windows" {
|
||||
err = copyFolder(oldPath, newPath)
|
||||
if err != nil {
|
||||
glog.Errorf("Error copying folder from: %s to: %s with error: %v", oldPath, newPath, err)
|
||||
return "", err
|
||||
}
|
||||
os.RemoveAll(oldPath)
|
||||
@@ -235,12 +237,31 @@ func RenameDirectory(oldPath, newName string) (string, error) {
|
||||
}
|
||||
|
||||
func copyFolder(source string, dest string) (err error) {
|
||||
fi, err := os.Lstat(source)
|
||||
if err != nil {
|
||||
glog.Errorf("Error getting stats for %s. %v", source, err)
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.MkdirAll(dest, fi.Mode())
|
||||
if err != nil {
|
||||
glog.Errorf("Unable to create %s directory %v", dest, err)
|
||||
}
|
||||
|
||||
directory, _ := os.Open(source)
|
||||
|
||||
defer directory.Close()
|
||||
|
||||
objects, err := directory.Readdir(-1)
|
||||
|
||||
for _, obj := range objects {
|
||||
sourcefilepointer := source + "/" + obj.Name()
|
||||
destinationfilepointer := dest + "/" + obj.Name()
|
||||
if obj.Mode()&os.ModeSymlink != 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
sourcefilepointer := source + "\\" + obj.Name()
|
||||
destinationfilepointer := dest + "\\" + obj.Name()
|
||||
|
||||
if obj.IsDir() {
|
||||
err = copyFolder(sourcefilepointer, destinationfilepointer)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user