From 5f999b6bcda79538cb1033503acd4c25615bd43b Mon Sep 17 00:00:00 2001 From: baude Date: Thu, 11 Feb 2021 09:23:49 -0600 Subject: container ps json format miscue when printing out json format, we mistakenly changed the Created field output to be a time.time in a different commit. This allows for override of the Created field to be a unix ts as type int64. Fixes: #9315 Signed-off-by: baude --- cmd/podman/containers/ps.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 31f44d92f..c9dda4db6 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -142,11 +142,19 @@ func checkFlags(c *cobra.Command) error { } func jsonOut(responses []entities.ListContainer) error { - r := make([]entities.ListContainer, 0) + type jsonFormat struct { + entities.ListContainer + Created int64 + } + r := make([]jsonFormat, 0) for _, con := range responses { con.CreatedAt = units.HumanDuration(time.Since(con.Created)) + " ago" con.Status = psReporter{con}.Status() - r = append(r, con) + jf := jsonFormat{ + ListContainer: con, + Created: con.Created.UnixNano(), + } + r = append(r, jf) } b, err := json.MarshalIndent(r, "", " ") if err != nil { -- cgit v1.2.3-54-g00ecf