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>
This commit is contained in:
Ahmet Alp Balkan
2015-06-02 21:02:47 +00:00
parent e4855eebf2
commit 4e3b21f99e
8 changed files with 65 additions and 12 deletions
+4 -2
View File
@@ -2,6 +2,7 @@ package client
import (
"net/url"
"time"
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
@@ -36,11 +37,12 @@ func (cli *DockerCli) CmdEvents(args ...string) error {
return err
}
}
ref := time.Now()
if *since != "" {
v.Set("since", timeutils.GetTimestamp(*since))
v.Set("since", timeutils.GetTimestamp(*since, ref))
}
if *until != "" {
v.Set("until", timeutils.GetTimestamp(*until))
v.Set("until", timeutils.GetTimestamp(*until, ref))
}
if len(eventFilterArgs) > 0 {
filterJSON, err := filters.ToParam(eventFilterArgs)
+2 -1
View File
@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/url"
"time"
"github.com/docker/docker/api/types"
flag "github.com/docker/docker/pkg/mflag"
@@ -46,7 +47,7 @@ func (cli *DockerCli) CmdLogs(args ...string) error {
v.Set("stderr", "1")
if *since != "" {
v.Set("since", timeutils.GetTimestamp(*since))
v.Set("since", timeutils.GetTimestamp(*since, time.Now()))
}
if *times {