mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-16 10:57:49 +00:00
Add JSON output field for ps
the toolbox team needs a field in our ps json that represents a human readable time. Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
parent
73514b1465
commit
9ec0e10484
2 changed files with 8 additions and 1 deletions
|
|
@ -110,7 +110,12 @@ func checkFlags(c *cobra.Command) error {
|
|||
}
|
||||
|
||||
func jsonOut(responses []entities.ListContainer) error {
|
||||
b, err := json.MarshalIndent(responses, "", " ")
|
||||
r := make([]entities.ListContainer, 0)
|
||||
for _, con := range responses {
|
||||
con.CreatedAt = units.HumanDuration(time.Since(time.Unix(con.Created, 0))) + " ago"
|
||||
r = append(r, con)
|
||||
}
|
||||
b, err := json.MarshalIndent(r, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ type ListContainer struct {
|
|||
Command []string
|
||||
// Container creation time
|
||||
Created int64
|
||||
// Human readable container creation time.
|
||||
CreatedAt string
|
||||
// If container has exited/stopped
|
||||
Exited bool
|
||||
// Time container exited
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue