summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-03-06 10:42:13 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-07 20:59:11 +0000
commit4344639508ccd16041d1ec7fd531b6427f930374 (patch)
tree4b28256bae65377bdf4f4900461f3f5379869bf1
parentf57b7bbf43fe7fc7ada8055911c7ac55e53fa698 (diff)
downloadpodman-4344639508ccd16041d1ec7fd531b6427f930374.tar.gz
podman-4344639508ccd16041d1ec7fd531b6427f930374.tar.bz2
podman-4344639508ccd16041d1ec7fd531b6427f930374.zip
podman import, load, and commit are too verbose
The progress should not be show for import, load, and commit. It makes machine parsing of the output much more difficult. Also, each command should output an image ID or name for the user. Added a --verbose flag for users that still want to see progress. Resolves issue #450 Signed-off-by: baude <bbaude@redhat.com> Closes: #456 Approved by: rhatdan
-rw-r--r--cmd/podman/commit.go18
-rw-r--r--cmd/podman/import.go15
-rw-r--r--completions/bash/podman10
-rw-r--r--docs/podman-commit.1.md38
-rw-r--r--docs/podman-import.1.md17
-rw-r--r--libpod/container_api.go11
-rw-r--r--libpod/runtime_img.go24
7 files changed, 80 insertions, 53 deletions
diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go
index 5d37458ea..59ced293f 100644
--- a/cmd/podman/commit.go
+++ b/cmd/podman/commit.go
@@ -1,6 +1,9 @@
package main
import (
+ "fmt"
+ "os"
+
"github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/projectatomic/libpod/libpod"
@@ -25,6 +28,10 @@ var (
Name: "pause, p",
Usage: "Pause container during commit",
},
+ cli.BoolFlag{
+ Name: "quiet, q",
+ Usage: "Suppress output",
+ },
}
commitDescription = `Create an image from a container's changes.
Optionally tag the image created, set the author with the --author flag,
@@ -84,10 +91,19 @@ func commitCmd(c *cli.Context) error {
Author: c.String("author"),
}
opts.ImageConfig = config
+ opts.Writer = nil
+
+ if !c.Bool("quiet") {
+ opts.Writer = os.Stderr
+ }
ctr, err := runtime.LookupContainer(container)
if err != nil {
return errors.Wrapf(err, "error looking up container %q", container)
}
- return ctr.Commit(c.BoolT("pause"), opts)
+ img, err := ctr.Commit(c.BoolT("pause"), opts)
+ if err == nil {
+ fmt.Println(img.ID)
+ }
+ return nil
}
diff --git a/cmd/podman/import.go b/cmd/podman/import.go
index 7b380b500..d3c497d9d 100644
--- a/cmd/podman/import.go
+++ b/cmd/podman/import.go
@@ -25,6 +25,10 @@ var (
Name: "message, m",
Usage: "Set commit message for imported image",
},
+ cli.BoolFlag{
+ Name: "quiet, q",
+ Usage: "Suppress output",
+ },
}
importDescription = `Create a container image from the contents of the specified tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz).
Note remote tar balls can be specified, via web address.
@@ -84,6 +88,11 @@ func importCmd(c *cli.Context) error {
}
opts.ImageConfig = config
+ opts.Writer = nil
+
+ if !c.Bool("quiet") {
+ opts.Writer = os.Stderr
+ }
// if source is a url, download it and save to a temp file
u, err := url.ParseRequestURI(source)
@@ -96,7 +105,11 @@ func importCmd(c *cli.Context) error {
source = file
}
- return runtime.ImportImage(source, opts)
+ img, err := runtime.ImportImage(source, opts)
+ if err == nil {
+ fmt.Println(img.ID)
+ }
+ return err
}
// donwloadFromURL downloads an image in the format "https:/example.com/myimage.tar"
diff --git a/completions/bash/podman b/completions/bash/podman
index 6d9098fc9..7e60d1e81 100644
--- a/completions/bash/podman
+++ b/completions/bash/podman
@@ -672,6 +672,8 @@ _podman_commit() {
-h
--pause
-p
+ --quiet
+ -q
"
_complete_ "$options_with_args" "$boolean_options"
@@ -816,6 +818,8 @@ _podman_import() {
local boolean_options="
--help
-h
+ --quiet
+ -q
"
_complete_ "$options_with_args" "$boolean_options"
@@ -1409,7 +1413,8 @@ _podman_save() {
"
local boolean_options="
--compress
- --quiet -q
+ -q
+ --quiet
"
_complete_ "$options_with_args" "$boolean_options"
}
@@ -1529,7 +1534,8 @@ _podman_load() {
--signature-policy
"
local boolean_options="
- --quiet -q
+ --quiet
+ -q
"
_complete_ "$options_with_args" "$boolean_options"
}
diff --git a/docs/podman-commit.1.md b/docs/podman-commit.1.md
index 2eee4fe3d..31eb8800a 100644
--- a/docs/podman-commit.1.md
+++ b/docs/podman-commit.1.md
@@ -12,6 +12,7 @@ podman commit - Create new image based on the changed container
[**--change**|**-c**]
[**--message**|**-m**]
[**--help**|**-h**]
+[**--verbose**]
## DESCRIPTION
**podman commit** creates an image based on a changed container. The author of the
@@ -19,7 +20,8 @@ image can be set using the **--author** flag. Various image instructions can be
configured with the **--change** flag and a commit message can be set using the
**--message** flag. The container and its processes are paused while the image is
committed. This minimizes the likelihood of data corruption when creating the new
-image. If this is not desired, the **--pause** flag can be set to false.
+image. If this is not desired, the **--pause** flag can be set to false. When the commit
+is complete, podman will print out the ID of the new image.
**podman [GLOBAL OPTIONS]**
@@ -43,6 +45,9 @@ Set commit message for committed image
**--pause, -p**
Pause the container when creating an image
+**--quiet, -q**
+Suppress output
+
## EXAMPLES
```
@@ -54,39 +59,22 @@ Copying config sha256:c16a6d30f3782288ec4e7521c754acc29d37155629cb39149756f486da
448 B / 448 B [============================================================] 0s
Writing manifest to image destination
Storing signatures
+e3ce4d93051ceea088d1c242624d659be32cf1667ef62f1d16d6b60193e2c7a8
```
```
-# podman commit --message "committing container to image" reverent_golick image-commited
-Getting image source signatures
-Copying blob sha256:b41deda5a2feb1f03a5c1bb38c598cbc12c9ccd675f438edc6acd815f7585b86
- 25.80 MB / 25.80 MB [======================================================] 0s
-Copying config sha256:af376cdda5c0ac1d9592bf56567253d203f8de6a8edf356c683a645d75221540
- 376 B / 376 B [============================================================] 0s
-Writing manifest to image destination
-Storing signatures
+# podman commit -q --message "committing container to image" reverent_golick image-commited
+e3ce4d93051ceea088d1c242624d659be32cf1667ef62f1d16d6b60193e2c7a8
```
```
-# podman commit --author "firstName lastName" reverent_golick
-Getting image source signatures
-Copying blob sha256:b41deda5a2feb1f03a5c1bb38c598cbc12c9ccd675f438edc6acd815f7585b86
- 25.80 MB / 25.80 MB [======================================================] 0s
-Copying config sha256:d61387b4d5edf65edee5353e2340783703074ffeaaac529cde97a8357eea7645
- 378 B / 378 B [============================================================] 0s
-Writing manifest to image destination
-Storing signatures
+# podman commit -q --author "firstName lastName" reverent_golick
+e3ce4d93051ceea088d1c242624d659be32cf1667ef62f1d16d6b60193e2c7a8
```
```
-# podman commit --pause=false reverent_golick image-commited
-Getting image source signatures
-Copying blob sha256:b41deda5a2feb1f03a5c1bb38c598cbc12c9ccd675f438edc6acd815f7585b86
- 25.80 MB / 25.80 MB [======================================================] 0s
-Copying config sha256:5813fe8a3b18696089fd09957a12e88bda43dc1745b5240879ffffe93240d29a
- 419 B / 419 B [============================================================] 0s
-Writing manifest to image destination
-Storing signatures
+# podman commit -q --pause=false reverent_golick image-commited
+e3ce4d93051ceea088d1c242624d659be32cf1667ef62f1d16d6b60193e2c7a8
```
## SEE ALSO
diff --git a/docs/podman-import.1.md b/docs/podman-import.1.md
index a789bdbfc..8ace15f83 100644
--- a/docs/podman-import.1.md
+++ b/docs/podman-import.1.md
@@ -11,6 +11,7 @@ podman import - Import a tarball and save it as a filesystem image
[**--change**|**-c**]
[**--message**|**-m**]
[**--help**|**-h**]
+[**-verbose**]
## DESCRIPTION
**podman import** imports a tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz)
@@ -34,6 +35,9 @@ Can be set multiple times
**--message, -m**
Set commit message for imported image
+**--quiet, -q**
+Shows progress on the import
+
## EXAMPLES
```
@@ -45,17 +49,12 @@ Copying config sha256:c16a6d30f3782288ec4e7521c754acc29d37155629cb39149756f486da
448 B / 448 B [============================================================] 0s
Writing manifest to image destination
Storing signatures
+db65d991f3bbf7f31ed1064db9a6ced7652e3f8166c4736aa9133dadd3c7acb3
```
```
-# cat ctr.tar | podman import --message "importing the ctr.tar tarball" - image-imported
-Getting image source signatures
-Copying blob sha256:b41deda5a2feb1f03a5c1bb38c598cbc12c9ccd675f438edc6acd815f7585b86
- 25.80 MB / 25.80 MB [======================================================] 0s
-Copying config sha256:af376cdda5c0ac1d9592bf56567253d203f8de6a8edf356c683a645d75221540
- 376 B / 376 B [============================================================] 0s
-Writing manifest to image destination
-Storing signatures
+# cat ctr.tar | podman -q import --message "importing the ctr.tar tarball" - image-imported
+db65d991f3bbf7f31ed1064db9a6ced7652e3f8166c4736aa9133dadd3c7acb3
```
```
@@ -67,6 +66,7 @@ Copying config sha256:d61387b4d5edf65edee5353e2340783703074ffeaaac529cde97a8357e
378 B / 378 B [============================================================] 0s
Writing manifest to image destination
Storing signatures
+db65d991f3bbf7f31ed1064db9a6ced7652e3f8166c4736aa9133dadd3c7acb3
```
```
@@ -79,6 +79,7 @@ Copying config sha256:5813fe8a3b18696089fd09957a12e88bda43dc1745b5240879ffffe932
419 B / 419 B [============================================================] 0s
Writing manifest to image destination
Storing signatures
+db65d991f3bbf7f31ed1064db9a6ced7652e3f8166c4736aa9133dadd3c7acb3
```
## SEE ALSO
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 38c3faeef..253428256 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -9,6 +9,7 @@ import (
"strconv"
"time"
+ "github.com/containers/storage"
"github.com/docker/docker/daemon/caps"
"github.com/docker/docker/pkg/signal"
"github.com/docker/docker/pkg/stringid"
@@ -588,19 +589,19 @@ func (c *Container) Inspect(size bool) (*inspect.ContainerInspectData, error) {
// Commit commits the changes between a container and its image, creating a new
// image
-func (c *Container) Commit(pause bool, options CopyOptions) error {
+func (c *Container) Commit(pause bool, options CopyOptions) (*storage.Image, error) {
if !c.locked {
c.lock.Lock()
defer c.lock.Unlock()
if err := c.syncContainer(); err != nil {
- return err
+ return nil, err
}
}
if c.state.State == ContainerStateRunning && pause {
if err := c.runtime.ociRuntime.pauseContainer(c); err != nil {
- return errors.Wrapf(err, "error pausing container %q", c.ID())
+ return nil, errors.Wrapf(err, "error pausing container %q", c.ID())
}
defer func() {
if err := c.runtime.ociRuntime.unpauseContainer(c); err != nil {
@@ -611,13 +612,13 @@ func (c *Container) Commit(pause bool, options CopyOptions) error {
tempFile, err := ioutil.TempFile(c.runtime.config.TmpDir, "podman-commit")
if err != nil {
- return errors.Wrapf(err, "error creating temp file")
+ return nil, errors.Wrapf(err, "error creating temp file")
}
defer os.Remove(tempFile.Name())
defer tempFile.Close()
if err := c.export(tempFile.Name()); err != nil {
- return err
+ return nil, err
}
return c.runtime.ImportImage(tempFile.Name(), options)
}
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index 8a21785bf..bc328d5b9 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -1032,30 +1032,30 @@ func (r *Runtime) GetHistory(image string) ([]ociv1.History, []types.BlobInfo, s
}
// ImportImage imports an OCI format image archive into storage as an image
-func (r *Runtime) ImportImage(path string, options CopyOptions) error {
+func (r *Runtime) ImportImage(path string, options CopyOptions) (*storage.Image, error) {
r.lock.RLock()
defer r.lock.RUnlock()
if !r.valid {
- return ErrRuntimeStopped
+ return nil, ErrRuntimeStopped
}
file := TarballTransport + ":" + path
src, err := alltransports.ParseImageName(file)
if err != nil {
- return errors.Wrapf(err, "error parsing image name %q", path)
+ return nil, errors.Wrapf(err, "error parsing image name %q", path)
}
updater, ok := src.(tarball.ConfigUpdater)
if !ok {
- return errors.Wrapf(err, "unexpected type, a tarball reference should implement tarball.ConfigUpdater")
+ return nil, errors.Wrapf(err, "unexpected type, a tarball reference should implement tarball.ConfigUpdater")
}
annotations := make(map[string]string)
err = updater.ConfigUpdate(options.ImageConfig, annotations)
if err != nil {
- return errors.Wrapf(err, "error updating image config")
+ return nil, errors.Wrapf(err, "error updating image config")
}
var reference = options.Reference
@@ -1065,24 +1065,26 @@ func (r *Runtime) ImportImage(path string, options CopyOptions) error {
if reference == "" {
reference, err = getImageDigest(src, sc)
if err != nil {
- return err
+ return nil, err
}
}
policyContext, err := getPolicyContext(sc)
if err != nil {
- return err
+ return nil, err
}
defer policyContext.Destroy()
-
- copyOptions := common.GetCopyOptions(os.Stdout, "", nil, nil, common.SigningOptions{}, "", "", false)
+ copyOptions := common.GetCopyOptions(options.Writer, "", nil, nil, common.SigningOptions{}, "", "", false)
dest, err := is.Transport.ParseStoreReference(r.store, reference)
if err != nil {
errors.Wrapf(err, "error getting image reference for %q", options.Reference)
}
-
- return cp.Image(policyContext, dest, src, copyOptions)
+ if err = cp.Image(policyContext, dest, src, copyOptions); err != nil {
+ return nil, err
+ }
+ // Use no lock version of GetImage
+ return r.getImage(reference)
}
// GetImageInspectInfo returns the inspect information of an image