mirror of
https://github.com/containers/podman.git
synced 2025-07-02 00:30:00 +08:00
Merge pull request #6731 from baude/toolboxjson
Add JSON output field for ps
This commit is contained in:
@ -110,7 +110,12 @@ func checkFlags(c *cobra.Command) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func jsonOut(responses []entities.ListContainer) 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ type ListContainer struct {
|
|||||||
Command []string
|
Command []string
|
||||||
// Container creation time
|
// Container creation time
|
||||||
Created int64
|
Created int64
|
||||||
|
// Human readable container creation time.
|
||||||
|
CreatedAt string
|
||||||
// If container has exited/stopped
|
// If container has exited/stopped
|
||||||
Exited bool
|
Exited bool
|
||||||
// Time container exited
|
// Time container exited
|
||||||
|
Reference in New Issue
Block a user