mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
fix kubectl cp command error.
it happens when copy directory to pod and the directory path ends with '/'. for example: kubectl cp /XX/XX/ XX-POD:/XX/XX modified: pkg/kubectl/cmd/cp.go modified: pkg/kubectl/cmd/cp_test.go
This commit is contained in:
parent
4457e43e7b
commit
c00f9bc140
@ -195,6 +195,8 @@ func makeTar(filepath string, writer io.Writer) error {
|
|||||||
// TODO: use compression here?
|
// TODO: use compression here?
|
||||||
tarWriter := tar.NewWriter(writer)
|
tarWriter := tar.NewWriter(writer)
|
||||||
defer tarWriter.Close()
|
defer tarWriter.Close()
|
||||||
|
|
||||||
|
filepath = path.Clean(filepath)
|
||||||
return recursiveTar(path.Dir(filepath), path.Base(filepath), tarWriter)
|
return recursiveTar(path.Dir(filepath), path.Base(filepath), tarWriter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ func TestTarUntar(t *testing.T) {
|
|||||||
t.Errorf("unexpected error: %v | %v", err, err2)
|
t.Errorf("unexpected error: %v | %v", err, err2)
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
dir = dir + "/"
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := os.RemoveAll(dir); err != nil {
|
if err := os.RemoveAll(dir); err != nil {
|
||||||
t.Errorf("Unexpected error cleaning up: %v", err)
|
t.Errorf("Unexpected error cleaning up: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user