From 6bec101041abba77329a7e04a329ab9792f7e1aa Mon Sep 17 00:00:00 2001 From: zhangguanzhang Date: Wed, 14 Apr 2021 12:55:45 +0800 Subject: [PATCH] Fixes invalid expression in save command Signed-off-by: zhangguanzhang --- cmd/podman/images/save.go | 2 +- test/e2e/save_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cmd/podman/images/save.go b/cmd/podman/images/save.go index 6c03fc3c65..f1f7e8b2e7 100644 --- a/cmd/podman/images/save.go +++ b/cmd/podman/images/save.go @@ -102,7 +102,7 @@ func save(cmd *cobra.Command, args []string) (finalErr error) { tags []string succeeded = false ) - if cmd.Flag("compress").Changed && (saveOpts.Format != define.OCIManifestDir && saveOpts.Format != define.V2s2ManifestDir && saveOpts.Format == "") { + if cmd.Flag("compress").Changed && (saveOpts.Format != define.OCIManifestDir && saveOpts.Format != define.V2s2ManifestDir) { return errors.Errorf("--compress can only be set when --format is either 'oci-dir' or 'docker-dir'") } if len(saveOpts.Output) == 0 { diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index 5ddd5efc8a..42ee7440b5 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -111,6 +111,24 @@ var _ = Describe("Podman save", func() { Expect(save.ExitCode()).To(Equal(0)) }) + It("podman save to directory with --compress but not use docker-dir and oci-dir", func() { + if rootless.IsRootless() && podmanTest.RemoteTest { + Skip("Requires a fix in containers image for chown/lchown") + } + outdir := filepath.Join(podmanTest.TempDir, "save") + + save := podmanTest.Podman([]string{"save", "--compress", "--format", "docker-archive", "-o", outdir, ALPINE}) + save.WaitWithDefaultTimeout() + // should not be 0 + Expect(save.ExitCode()).ToNot(Equal(0)) + + save = podmanTest.Podman([]string{"save", "--compress", "--format", "oci-archive", "-o", outdir, ALPINE}) + save.WaitWithDefaultTimeout() + // should not be 0 + Expect(save.ExitCode()).ToNot(Equal(0)) + + }) + It("podman save bad filename", func() { outdir := filepath.Join(podmanTest.TempDir, "save:colon")