Skip to content

Commit

Permalink
cmd/list: Handle API change of Podman 2.1 in podman images
Browse files Browse the repository at this point in the history
Since Podman 2.1 the field 'Created' of `podman images --format json` no
longer holds a string with human-readable string in format "5 minutes
ago" but holds a Unix time integer[0].

[0] containers/podman#6815

#503
  • Loading branch information
HarryMichal committed Jul 24, 2020
1 parent 5629ed1 commit f0fd5df
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (i *toolboxImage) UnmarshalJSON(data []byte) error {
var raw struct {
ID string
Names []string
Created string
Created interface{}
}

if err := json.Unmarshal(data, &raw); err != nil {
Expand All @@ -312,7 +312,15 @@ func (i *toolboxImage) UnmarshalJSON(data []byte) error {

i.ID = raw.ID
i.Names = raw.Names
i.Created = raw.Created
// Until Podman 2.0.x the field 'Created' held a human-readable string in
// format "5 minutes ago". Since Podman 2.1 the field holds an integer with
// Unix time. Go interprets numbers in JSON as float64.
switch value := raw.Created.(type) {
case string:
i.Created = value
case float64:
i.Created = utils.HumanDuration(int64(value))
}

return nil
}
Expand Down

0 comments on commit f0fd5df

Please sign in to comment.