summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorAdrian Reber <areber@redhat.com>2019-06-21 11:31:38 +0000
committerAdrian Reber <areber@redhat.com>2019-06-21 13:37:04 +0200
commit1e706a021dde7566bc04a27b29411d4cd940ac17 (patch)
tree7b5b04bd4b7eaa57749210eca5aaabb42881c656 /cmd/podman
parentf446ccf0b050f5577328e5ba3efcdb5cafaae254 (diff)
downloadpodman-1e706a021dde7566bc04a27b29411d4cd940ac17.tar.gz
podman-1e706a021dde7566bc04a27b29411d4cd940ac17.tar.bz2
podman-1e706a021dde7566bc04a27b29411d4cd940ac17.zip
Add --latest, -l to 'podman diff'
The man page of 'podman diff' claims that the diff sub-command knows about --latest, -l. This adds support, as described in the man-page, to the diff sub-command for --latest, -l. Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/cliconfig/config.go1
-rw-r--r--cmd/podman/diff.go15
2 files changed, 14 insertions, 2 deletions
diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go
index 4a4c839cc..e3e2edb95 100644
--- a/cmd/podman/cliconfig/config.go
+++ b/cmd/podman/cliconfig/config.go
@@ -113,6 +113,7 @@ type DiffValues struct {
PodmanCommand
Archive bool
Format string
+ Latest bool
}
type ExecValues struct {
diff --git a/cmd/podman/diff.go b/cmd/podman/diff.go
index 9543113d8..032c0f2c0 100644
--- a/cmd/podman/diff.go
+++ b/cmd/podman/diff.go
@@ -60,8 +60,10 @@ func init() {
flags.BoolVar(&diffCommand.Archive, "archive", true, "Save the diff as a tar archive")
flags.StringVar(&diffCommand.Format, "format", "", "Change the output format")
+ flags.BoolVarP(&diffCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.MarkHidden("archive")
+ markFlagHiddenForRemoteClient("latest", flags)
}
@@ -83,7 +85,7 @@ func formatJSON(output []diffOutputParams) (diffJSONOutput, error) {
}
func diffCmd(c *cliconfig.DiffValues) error {
- if len(c.InputArgs) != 1 {
+ if len(c.InputArgs) != 1 && !c.Latest {
return errors.Errorf("container, image, or layer name must be specified: podman diff [options [...]] ID-NAME")
}
@@ -93,7 +95,16 @@ func diffCmd(c *cliconfig.DiffValues) error {
}
defer runtime.Shutdown(false)
- to := c.InputArgs[0]
+ var to string
+ if c.Latest {
+ ctr, err := runtime.GetLatestContainer()
+ if err != nil {
+ return errors.Wrapf(err, "unable to get latest container")
+ }
+ to = ctr.ID()
+ } else {
+ to = c.InputArgs[0]
+ }
changes, err := runtime.Diff(c, to)
if err != nil {
return errors.Wrapf(err, "could not get changes for %q", to)