diff --git a/cmd/podman/images/history.go b/cmd/podman/images/history.go index c05d3475bf20..26a4b6c3b5b1 100644 --- a/cmd/podman/images/history.go +++ b/cmd/podman/images/history.go @@ -168,3 +168,11 @@ func (h historyReporter) ID() string { } return h.ImageHistoryLayer.ID } + +func (h historyReporter) CreatedAt() string { + return time.Unix(h.ImageHistoryLayer.Created.Unix(), 0).UTC().String() +} + +func (h historyReporter) CreatedSince() string { + return h.Created() +} diff --git a/docs/source/markdown/podman-history.1.md b/docs/source/markdown/podman-history.1.md index af35814c2209..16f1e48e609d 100644 --- a/docs/source/markdown/podman-history.1.md +++ b/docs/source/markdown/podman-history.1.md @@ -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*). diff --git a/test/system/110-history.bats b/test/system/110-history.bats index 0f6d75cb3a82..ad001e59e53c 100644 --- a/test/system/110-history.bats +++ b/test/system/110-history.bats @@ -55,4 +55,16 @@ size | -\\\?[0-9]\\\+ } +@test "podman image history Created" { + run_podman image list --format '{{.CreatedSince}}' $IMAGE + imageSince="$output" + run_podman image list --format '{{.CreatedAt}}' $IMAGE + 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 + assert "${lines[0]}" == "$imageAt" "History image list should match .CreatedAt" +} + # vim: filetype=sh