summaryrefslogtreecommitdiff
path: root/cmd/podman/diff.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-06-21 16:15:00 +0200
committerGitHub <noreply@github.com>2019-06-21 16:15:00 +0200
commitc0bc768ff131d014638a151f7725921a87ddbdb1 (patch)
tree0605613ba5fa6f128abb9c75887e3c7831630736 /cmd/podman/diff.go
parent7d8aba924820447a9f07b78dbaf795f94c4e906d (diff)
parent1e706a021dde7566bc04a27b29411d4cd940ac17 (diff)
downloadpodman-c0bc768ff131d014638a151f7725921a87ddbdb1.tar.gz
podman-c0bc768ff131d014638a151f7725921a87ddbdb1.tar.bz2
podman-c0bc768ff131d014638a151f7725921a87ddbdb1.zip
Merge pull request #3395 from adrianreber/diff
Add --latest, -l to 'podman diff'
Diffstat (limited to 'cmd/podman/diff.go')
-rw-r--r--cmd/podman/diff.go15
1 files changed, 13 insertions, 2 deletions
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)