summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-02-15 10:33:18 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-15 17:18:08 +0000
commit409ed259c6b3ea9122c697e9e20b4b1572f485d1 (patch)
tree61c2c2107799eb542beb9f294796510bf1803578
parentce7a0171d156709bc8bbf2ac1138b8022bb08054 (diff)
downloadpodman-409ed259c6b3ea9122c697e9e20b4b1572f485d1.tar.gz
podman-409ed259c6b3ea9122c697e9e20b4b1572f485d1.tar.bz2
podman-409ed259c6b3ea9122c697e9e20b4b1572f485d1.zip
Return imageid from podman pull
When using podman to pull an image, print the image id after the image is pulled. Resolves issue #329 Signed-off-by: baude <bbaude@redhat.com> Closes: #342 Approved by: rhatdan
-rw-r--r--cmd/podman/pull.go9
-rw-r--r--docs/podman-pull.1.md7
-rw-r--r--test/e2e/pull_test.go19
3 files changed, 34 insertions, 1 deletions
diff --git a/cmd/podman/pull.go b/cmd/podman/pull.go
index c19e6715b..886f82dd5 100644
--- a/cmd/podman/pull.go
+++ b/cmd/podman/pull.go
@@ -4,6 +4,7 @@ import (
"io"
"os"
+ "fmt"
"github.com/containers/image/types"
"github.com/pkg/errors"
"github.com/projectatomic/libpod/libpod"
@@ -106,5 +107,13 @@ func pullCmd(c *cli.Context) error {
if _, err := runtime.PullImage(image, options); err != nil {
return errors.Wrapf(err, "error pulling image %q", image)
}
+
+ newImage := runtime.NewImage(image)
+ iid, err := newImage.GetImageID()
+ // Intentially choosing to ignore if there is an error because
+ // outputting the image ID is a NTH and not integral to the pull
+ if err == nil {
+ fmt.Println(iid)
+ }
return nil
}
diff --git a/docs/podman-pull.1.md b/docs/podman-pull.1.md
index 1a1611fd0..f7b24995a 100644
--- a/docs/podman-pull.1.md
+++ b/docs/podman-pull.1.md
@@ -14,7 +14,8 @@ podman pull - Pull an image from a registry
Copies an image from a registry onto the local machine. **podman pull** pulls an
image from Docker Hub if a registry is not specified in the command line argument.
If an image tag is not specified, **podman pull** defaults to the image with the
-**latest** tag (if it exists) and pulls it. **podman pull** can also pull an image
+**latest** tag (if it exists) and pulls it. After the image is pulled, podman will
+print the full image ID. **podman pull** can also pull an image
using its digest **podman pull [image]@[digest]**. **podman pull** can be used to pull
images from archives and local storage using different transports.
@@ -97,6 +98,7 @@ Copying config sha256:76da55c8019d7a47c347c0dceb7a6591144d232a7dd616242a367b8bed
1.48 KB / 1.48 KB [========================================================] 0s
Writing manifest to image destination
Storing signatures
+04660052281190168dbb2362eb15bf7067a8dc642d2498055e0e72efa961a4b6
```
```
@@ -108,6 +110,7 @@ Copying config sha256:ad4686094d8f0186ec8249fc4917b71faa2c1030d7b5a025c29f26e19d
1.41 KB / 1.41 KB [========================================================] 0s
Writing manifest to image destination
Storing signatures
+03290064078cb797f3e0a530e78c20c13dd22a3dd3adf84a5da2127b48df0438
```
```
@@ -119,6 +122,7 @@ Copying config sha256:ad4686094d8f0186ec8249fc4917b71faa2c1030d7b5a025c29f26e19d
1.41 KB / 1.41 KB [========================================================] 0s
Writing manifest to image destination
Storing signatures
+03290064078cb797f3e0a530e78c20c13dd22a3dd3adf84a5da2127b48df0438
```
```
@@ -130,6 +134,7 @@ Copying config sha256:ad4686094d8f0186ec8249fc4917b71faa2c1030d7b5a025c29f26e19d
1.41 KB / 1.41 KB [========================================================] 0s
Writing manifest to image destination
Storing signatures
+03290064078cb797f3e0a530e78c20c13dd22a3dd3adf84a5da2127b48df0438
```
## SEE ALSO
diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go
index e24d8a5a7..25e33240e 100644
--- a/test/e2e/pull_test.go
+++ b/test/e2e/pull_test.go
@@ -5,6 +5,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
+ "strings"
)
var _ = Describe("Podman pull", func() {
@@ -138,4 +139,22 @@ var _ = Describe("Podman pull", func() {
clean := podmanTest.SystemExec("rm", []string{"-fr", "/tmp/podmantestdir"})
clean.WaitWithDefaultTimeout()
})
+
+ It("podman pull from local directory", func() {
+ podmanTest.RestoreArtifact(ALPINE)
+ setup := podmanTest.Podman([]string{"images", ALPINE, "-q", "--no-trunc"})
+ setup.WaitWithDefaultTimeout()
+ Expect(setup.ExitCode()).To(Equal(0))
+ shortImageId := strings.Split(setup.OutputToString(), ":")[1]
+
+ rmi := podmanTest.Podman([]string{"rmi", ALPINE})
+ rmi.WaitWithDefaultTimeout()
+ Expect(rmi.ExitCode()).To(Equal(0))
+
+ pull := podmanTest.Podman([]string{"pull", "-q", ALPINE})
+ pull.WaitWithDefaultTimeout()
+ Expect(pull.ExitCode()).To(Equal(0))
+
+ Expect(pull.OutputToString()).To(ContainSubstring(shortImageId))
+ })
})