diff options
author | Matej Vasek <mvasek@redhat.com> | 2020-10-23 17:56:22 +0200 |
---|---|---|
committer | Matej Vasek <mvasek@redhat.com> | 2020-10-25 15:58:36 +0100 |
commit | 97d47ef3d5efce16571ae62c3d14ed540e538a24 (patch) | |
tree | 9fa1febfbc6734da529540061eb9bdff3d830255 | |
parent | bce8331528c186ef2234a3cfe6c7d0e09da79bdd (diff) | |
download | podman-97d47ef3d5efce16571ae62c3d14ed540e538a24.tar.gz podman-97d47ef3d5efce16571ae62c3d14ed540e538a24.tar.bz2 podman-97d47ef3d5efce16571ae62c3d14ed540e538a24.zip |
fix: podman-cp respects "--extract" flag
Signed-off-by: Matej Vasek <mvasek@redhat.com>
-rw-r--r-- | pkg/domain/infra/abi/cp.go | 2 | ||||
-rw-r--r-- | test/e2e/cp_test.go | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/cp.go b/pkg/domain/infra/abi/cp.go index a0bfcc90c..ab90c8183 100644 --- a/pkg/domain/infra/abi/cp.go +++ b/pkg/domain/infra/abi/cp.go @@ -26,7 +26,7 @@ import ( ) func (ic *ContainerEngine) ContainerCp(ctx context.Context, source, dest string, options entities.ContainerCpOptions) (*entities.ContainerCpReport, error) { - var extract bool + extract := options.Extract srcCtr, srcPath := parsePath(ic.Libpod, source) destCtr, destPath := parsePath(ic.Libpod, dest) diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go index 0a9fa990c..6d349ba5b 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -204,6 +204,42 @@ var _ = Describe("Podman cp", func() { os.Remove("file.tar") }) + It("podman cp tar --extract", func() { + testctr := "testctr" + setup := podmanTest.RunTopContainer(testctr) + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"exec", testctr, "mkdir", "/foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + path, err := os.Getwd() + Expect(err).To(BeNil()) + testDirPath := filepath.Join(path, "TestDir4") + err = os.Mkdir(testDirPath, 0777) + Expect(err).To(BeNil()) + defer os.RemoveAll(testDirPath) + f, err := os.Create(filepath.Join(testDirPath, "a.txt")) + Expect(err).To(BeNil()) + _, err = f.Write([]byte("Hello World!!!\n")) + f.Close() + cmd := exec.Command("tar", "-cvf", "file.tar", "TestDir4") + exec.Command("tar", "-cvf", "/home/mvasek/file.tar", testDirPath) + _, err = cmd.Output() + Expect(err).To(BeNil()) + defer os.Remove("file.tar") + + session = podmanTest.Podman([]string{"cp", "--extract", "file.tar", "testctr:/foo/"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"exec", testctr, "cat", "/foo/TestDir4/a.txt"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("Hello World!!!")) + }) + It("podman cp symlink", func() { session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top"}) session.WaitWithDefaultTimeout() |