summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-24 16:53:48 +0000
committerGitHub <noreply@github.com>2020-09-24 16:53:48 +0000
commit0f5f8dcdd3684955c4fde3d25be4bb8b8a64b24a (patch)
treea8f7ead5a109433d51e308fd3f1e3672770c77c4
parentc191466bd929e85a4862b48c9b3688bf407b9c42 (diff)
parent1f66a827e892e0133cee6485095e129f0e5047f0 (diff)
downloadpodman-0f5f8dcdd3684955c4fde3d25be4bb8b8a64b24a.tar.gz
podman-0f5f8dcdd3684955c4fde3d25be4bb8b8a64b24a.tar.bz2
podman-0f5f8dcdd3684955c4fde3d25be4bb8b8a64b24a.zip
Merge pull request #7741 from vrothberg/remote-load-dir-check
remote load: check if input is directory
-rw-r--r--docs/source/markdown/podman-load.1.md4
-rw-r--r--pkg/domain/infra/tunnel/images.go7
-rw-r--r--test/e2e/load_test.go18
3 files changed, 27 insertions, 2 deletions
diff --git a/docs/source/markdown/podman-load.1.md b/docs/source/markdown/podman-load.1.md
index 917f102f6..308a3493b 100644
--- a/docs/source/markdown/podman-load.1.md
+++ b/docs/source/markdown/podman-load.1.md
@@ -9,9 +9,11 @@ podman\-load - Load an image from a container image archive into container stora
**podman image load** [*options*] [*name*[:*tag*]]
## DESCRIPTION
-**podman load** loads an image from either an **oci-archive** or **docker-archive** stored on the local machine into container storage. **podman load** reads from stdin by default or a file if the **input** option is set.
+**podman load** loads an image from either an **oci-archive** or a **docker-archive** stored on the local machine into container storage. **podman load** reads from stdin by default or a file if the **input** option is set.
You can also specify a name for the image if the archive does not contain a named reference, of if you want an additional name for the local image.
+The local client further supports loading an **oci-dir** or a **docker-dir** as created with **podman save** (1).
+
The **quiet** option suppresses the progress output when set.
Note: `:` is a restricted character and cannot be part of the file name.
diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go
index 332a7c2eb..981884109 100644
--- a/pkg/domain/infra/tunnel/images.go
+++ b/pkg/domain/infra/tunnel/images.go
@@ -199,6 +199,13 @@ func (ir *ImageEngine) Load(ctx context.Context, opts entities.ImageLoadOptions)
return nil, err
}
defer f.Close()
+ fInfo, err := f.Stat()
+ if err != nil {
+ return nil, err
+ }
+ if fInfo.IsDir() {
+ return nil, errors.Errorf("remote client supports archives only but %q is a directory", opts.Input)
+ }
ref := opts.Name
if len(opts.Tag) > 0 {
ref += ":" + opts.Tag
diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go
index c517c90d8..ddffadac0 100644
--- a/test/e2e/load_test.go
+++ b/test/e2e/load_test.go
@@ -123,7 +123,7 @@ var _ = Describe("Podman load", func() {
})
It("podman load directory", func() {
- SkipIfRemote("FIXME: Remote Load is broken.")
+ SkipIfRemote("Remote does not support loading directories")
outdir := filepath.Join(podmanTest.TempDir, "alpine")
save := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE})
@@ -139,6 +139,22 @@ var _ = Describe("Podman load", func() {
Expect(result.ExitCode()).To(Equal(0))
})
+ It("podman-remote load directory", func() {
+ // Remote-only test looking for the specific remote error
+ // message when trying to load a directory.
+ if !IsRemote() {
+ Skip("Remote only test")
+ }
+
+ result := podmanTest.Podman([]string{"load", "-i", podmanTest.TempDir})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(125))
+
+ errMsg := fmt.Sprintf("remote client supports archives only but %q is a directory", podmanTest.TempDir)
+ found, _ := result.ErrorGrepString(errMsg)
+ Expect(found).Should(BeTrue())
+ })
+
It("podman load bogus file", func() {
save := podmanTest.PodmanNoCache([]string{"load", "-i", "foobar.tar"})
save.WaitWithDefaultTimeout()