diff options
Diffstat (limited to 'cmd/podman/diff.go')
-rw-r--r-- | cmd/podman/diff.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/cmd/podman/diff.go b/cmd/podman/diff.go index 9543113d8..f052b510d 100644 --- a/cmd/podman/diff.go +++ b/cmd/podman/diff.go @@ -60,8 +60,9 @@ 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.MarkHidden("archive") + flags.BoolVarP(&diffCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of") + markFlagHidden(flags, "archive") + markFlagHiddenForRemoteClient("latest", flags) } @@ -83,7 +84,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") } @@ -91,9 +92,18 @@ func diffCmd(c *cliconfig.DiffValues) error { if err != nil { return errors.Wrapf(err, "could not get runtime") } - defer runtime.Shutdown(false) + defer runtime.DeferredShutdown(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) @@ -126,7 +136,5 @@ func diffCmd(c *cliconfig.DiffValues) error { } else { out = stdoutStruct{output: diffOutput} } - formats.Writer(out).Out() - - return nil + return out.Out() } |