Skip to content

Commit

Permalink
Add CreatedSince & CreatedAt format fields to podman image history
Browse files Browse the repository at this point in the history
Fixes: containers#14012

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Apr 27, 2022
1 parent e4be261 commit 2f40234
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 8 additions & 0 deletions cmd/podman/images/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,11 @@ func (h historyReporter) ID() string {
}
return h.ImageHistoryLayer.ID
}

func (h historyReporter) CreatedAt() string {
return h.ImageHistoryLayer.Created.UTC().String()
}

func (h historyReporter) CreatedSince() string {
return h.Created()
}
9 changes: 5 additions & 4 deletions docs/source/markdown/podman-history.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ Valid placeholders for the Go template are listed below:
| --------------- | ----------------------------------------------------------------------------- |
| .ID | Image ID |
| .Created | if --human, time elapsed since creation, otherwise time stamp of creation |
| .CreatedBy | Command used to create the layer |
| .Size | Size of layer on disk |
| .Comment | Comment for the layer |

| .CreatedAt | Time when the image layer was created |
| .CreatedBy | Command used to create the layer |
| .CreatedSince | Elapsed time since the image layer was created |
| .Size | Size of layer on disk |
| .Comment | Comment for the layer |
## OPTIONS

Print the numeric IDs only (default *false*).
Expand Down
15 changes: 15 additions & 0 deletions test/system/010-images.bats
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,19 @@ Deleted: $pauseID"
is "$output" ""
}

@test "podman image history" {
run_podman image list --format '{{.CreatedSince}}' $IMAGE
imageSince="$output"
run_podman image list --format '{{.CreatedAt}}' $IMAGE
run cut -f1 -d'.' <<< "$output"
imageAt="$output"
run_podman image history $IMAGE
run_podman image history --format '{{.CreatedSince}}' $IMAGE
is "${lines[0]}" "$imageSince" "History image list should match .CreatedSince"
run_podman image history --format '{{.CreatedAt}}' $IMAGE
line="$lines[0]"
run cut -f1 -d'.' <<< "$line"
assert "${output}" == "$imageAt" "History image list should match .CreatedAt"
}

# vim: filetype=sh

0 comments on commit 2f40234

Please sign in to comment.