diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2019-01-15 17:08:54 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2019-01-16 10:05:41 -0500 |
commit | 78fc4c67fdd1f8d8a3567ffd941c1f5b3e1b6ba5 (patch) | |
tree | 46e3eced8e0188d2979136ecbd87a833323f71fe /cmd/podman/mount.go | |
parent | d8683219d2ac5fd9a0aa271ef9d94cebe0c2adc0 (diff) | |
download | podman-78fc4c67fdd1f8d8a3567ffd941c1f5b3e1b6ba5.tar.gz podman-78fc4c67fdd1f8d8a3567ffd941c1f5b3e1b6ba5.tar.bz2 podman-78fc4c67fdd1f8d8a3567ffd941c1f5b3e1b6ba5.zip |
Add --latest and --all to podman mount/umount
I find these useful for playing around with containers.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/mount.go')
-rw-r--r-- | cmd/podman/mount.go | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/cmd/podman/mount.go b/cmd/podman/mount.go index c91115597..86a6b2ad1 100644 --- a/cmd/podman/mount.go +++ b/cmd/podman/mount.go @@ -24,13 +24,18 @@ var ( mountFlags = []cli.Flag{ cli.BoolFlag{ - Name: "notruncate", - Usage: "do not truncate output", + Name: "all, a", + Usage: "Mount all containers", }, cli.StringFlag{ Name: "format", Usage: "Change the output format to Go template", }, + cli.BoolFlag{ + Name: "notruncate", + Usage: "do not truncate output", + }, + LatestFlag, } mountCommand = cli.Command{ Name: "mount", @@ -80,20 +85,31 @@ func mountCmd(c *cli.Context) error { } } + if c.Bool("all") && c.Bool("latest") { + return errors.Errorf("--all and --latest cannot be used together") + } + + mountContainers, err := getAllOrLatestContainers(c, runtime, -1, "all") + if err != nil { + if len(mountContainers) == 0 { + return err + } + fmt.Println(err.Error()) + } + formats := map[string]bool{ "": true, of.JSONString: true, } - args := c.Args() json := c.String("format") == of.JSONString if !formats[c.String("format")] { return errors.Errorf("%q is not a supported format", c.String("format")) } var lastError error - if len(args) > 0 { - for _, name := range args { + if len(mountContainers) > 0 { + for _, ctr := range mountContainers { if json { if lastError != nil { logrus.Error(lastError) @@ -101,14 +117,6 @@ func mountCmd(c *cli.Context) error { lastError = errors.Wrapf(err, "json option cannot be used with a container id") continue } - ctr, err := runtime.LookupContainer(name) - if err != nil { - if lastError != nil { - logrus.Error(lastError) - } - lastError = errors.Wrapf(err, "error looking up container %q", name) - continue - } mountPoint, err := ctr.Mount() if err != nil { if lastError != nil { |