Allow duration strings as --since/--until

Fixes #13107. This change enables Go duration strings
computed relative to the client machine’s time to be used
as input parameters to `docker events --since/--until`
and `docker logs --since` arguments.

Added unit tests for pkg/timeutils.GetTimestamp as well.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
Upstream-commit: 4e3b21f99e7fb7fac0075be2e7190d5f07c9ee66
Component: engine
This commit is contained in:
Ahmet Alp Balkan
2015-05-12 19:59:34 +00:00
parent 5edd0d62d2
commit add0a8eb5b
8 changed files with 65 additions and 12 deletions

View File

@ -28,9 +28,10 @@ func (s *DockerSuite) TestEventsTimestampFormats(c *check.C) {
// List of available time formats to --since
unixTs := func(t time.Time) string { return fmt.Sprintf("%v", t.Unix()) }
rfc3339 := func(t time.Time) string { return t.Format(time.RFC3339) }
duration := func(t time.Time) string { return time.Now().Sub(t).String() }
// --since=$start must contain only the 'untag' event
for _, f := range []func(time.Time) string{unixTs, rfc3339} {
for _, f := range []func(time.Time) string{unixTs, rfc3339, duration} {
since, until := f(start), f(end)
cmd := exec.Command(dockerBinary, "events", "--since="+since, "--until="+until)
out, _, err := runCommandWithOutput(cmd)