mirror of
https://github.com/containers/podman.git
synced 2025-12-09 23:27:09 +08:00
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
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user