From e58fb21ced99db634a38c9e8fbfd04044efe3131 Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen Date: Fri, 4 Dec 2020 14:43:34 +0800 Subject: Support Unix timestamps for `podman logs --since` To match what podman-logs(1) describes --since Signed-off-by: Chih-Hsuan Yen --- pkg/util/utils.go | 5 +++++ test/system/035-logs.bats | 3 +++ 2 files changed, 8 insertions(+) diff --git a/pkg/util/utils.go b/pkg/util/utils.go index f6a084c00..e0f631eb4 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -530,6 +530,11 @@ func ParseInputTime(inputTime string) (time.Time, error) { } } + unix_timestamp, err := strconv.ParseInt(inputTime, 10, 64) + if err == nil { + return time.Unix(unix_timestamp, 0), nil + } + // input might be a duration duration, err := time.ParseDuration(inputTime) if err != nil { diff --git a/test/system/035-logs.bats b/test/system/035-logs.bats index a3d6a5800..a081a7ce1 100644 --- a/test/system/035-logs.bats +++ b/test/system/035-logs.bats @@ -21,6 +21,9 @@ load helpers run_podman logs $cid is "$output" "$rand_string" "output from podman-logs after container is run" + # test --since with Unix timestamps + run_podman logs --since 1000 $cid + run_podman rm $cid } -- cgit v1.2.3-54-g00ecf