Skip to content

Commit

Permalink
Merge pull request #10021 from zhangguanzhang/invalid-save-expression
Browse files Browse the repository at this point in the history
Fix invalid expression in save command
  • Loading branch information
openshift-merge-robot authored Apr 16, 2021
2 parents b82ae19 + 6bec101 commit 4c88035
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/podman/images/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 4c88035

Please sign in to comment.