Move timeutils functions to the only places where they are used.

- Move time json marshaling to the jsonlog package: this is a docker
  internal hack that we should not promote as a library.
- Move Timestamp encoding/decoding functions to the API types: This is
  only used there. It could be a standalone library but I don't this
it's worth having a separated repo for this. It could introduce more
complexity than it solves.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera
2015-12-15 14:49:41 -05:00
parent 2180dd6cf0
commit 27220ecc6b
15 changed files with 44 additions and 50 deletions

View File

@@ -6,8 +6,8 @@ import (
"time"
"github.com/docker/docker/api/types"
timetypes "github.com/docker/docker/api/types/time"
"github.com/docker/docker/pkg/parsers/filters"
"github.com/docker/docker/pkg/timeutils"
)
// Events returns a stream of events in the daemon in a ReadCloser.
@@ -17,14 +17,14 @@ func (cli *Client) Events(options types.EventsOptions) (io.ReadCloser, error) {
ref := time.Now()
if options.Since != "" {
ts, err := timeutils.GetTimestamp(options.Since, ref)
ts, err := timetypes.GetTimestamp(options.Since, ref)
if err != nil {
return nil, err
}
query.Set("since", ts)
}
if options.Until != "" {
ts, err := timeutils.GetTimestamp(options.Until, ref)
ts, err := timetypes.GetTimestamp(options.Until, ref)
if err != nil {
return nil, err
}

View File

@@ -6,7 +6,7 @@ import (
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/timeutils"
timetypes "github.com/docker/docker/api/types/time"
)
// ContainerLogs returns the logs generated by a container in an io.ReadCloser.
@@ -22,7 +22,7 @@ func (cli *Client) ContainerLogs(options types.ContainerLogsOptions) (io.ReadClo
}
if options.Since != "" {
ts, err := timeutils.GetTimestamp(options.Since, time.Now())
ts, err := timetypes.GetTimestamp(options.Since, time.Now())
if err != nil {
return nil, err
}