summaryrefslogtreecommitdiff
path: root/pkg/jsonmessage
diff options
context:
space:
mode:
authorDavid Calavera <david.calavera@gmail.com>2015-12-15 14:49:41 -0500
committerDavid Calavera <david.calavera@gmail.com>2015-12-15 14:56:14 -0500
commit27220ecc6b1eedf650ca9cf94965cb0dc2054efd (patch)
tree6532a18a56caa66664cd59ea81e86e1108dec45a /pkg/jsonmessage
parent2180dd6cf0258dee45a11ce6bf597448b8157984 (diff)
downloaddocker-27220ecc6b1eedf650ca9cf94965cb0dc2054efd.tar.gz
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>
Diffstat (limited to 'pkg/jsonmessage')
-rw-r--r--pkg/jsonmessage/jsonmessage.go6
-rw-r--r--pkg/jsonmessage/jsonmessage_test.go14
2 files changed, 10 insertions, 10 deletions
diff --git a/pkg/jsonmessage/jsonmessage.go b/pkg/jsonmessage/jsonmessage.go
index c234ff6804..419a47d9c9 100644
--- a/pkg/jsonmessage/jsonmessage.go
+++ b/pkg/jsonmessage/jsonmessage.go
@@ -7,8 +7,8 @@ import (
"strings"
"time"
+ "github.com/docker/docker/pkg/jsonlog"
"github.com/docker/docker/pkg/term"
- "github.com/docker/docker/pkg/timeutils"
"github.com/docker/docker/pkg/units"
)
@@ -123,9 +123,9 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
return nil
}
if jm.TimeNano != 0 {
- fmt.Fprintf(out, "%s ", time.Unix(0, jm.TimeNano).Format(timeutils.RFC3339NanoFixed))
+ fmt.Fprintf(out, "%s ", time.Unix(0, jm.TimeNano).Format(jsonlog.RFC3339NanoFixed))
} else if jm.Time != 0 {
- fmt.Fprintf(out, "%s ", time.Unix(jm.Time, 0).Format(timeutils.RFC3339NanoFixed))
+ fmt.Fprintf(out, "%s ", time.Unix(jm.Time, 0).Format(jsonlog.RFC3339NanoFixed))
}
if jm.ID != "" {
fmt.Fprintf(out, "%s: ", jm.ID)
diff --git a/pkg/jsonmessage/jsonmessage_test.go b/pkg/jsonmessage/jsonmessage_test.go
index 7f46a8f63e..b81b656994 100644
--- a/pkg/jsonmessage/jsonmessage_test.go
+++ b/pkg/jsonmessage/jsonmessage_test.go
@@ -7,8 +7,8 @@ import (
"testing"
"time"
+ "github.com/docker/docker/pkg/jsonlog"
"github.com/docker/docker/pkg/term"
- "github.com/docker/docker/pkg/timeutils"
)
func TestError(t *testing.T) {
@@ -71,8 +71,8 @@ func TestJSONMessageDisplay(t *testing.T) {
From: "From",
Status: "status",
}: {
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(now.Unix(), 0).Format(timeutils.RFC3339NanoFixed)),
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(now.Unix(), 0).Format(timeutils.RFC3339NanoFixed)),
+ fmt.Sprintf("%v ID: (from From) status\n", time.Unix(now.Unix(), 0).Format(jsonlog.RFC3339NanoFixed)),
+ fmt.Sprintf("%v ID: (from From) status\n", time.Unix(now.Unix(), 0).Format(jsonlog.RFC3339NanoFixed)),
},
// General, with nano precision time
JSONMessage{
@@ -81,8 +81,8 @@ func TestJSONMessageDisplay(t *testing.T) {
From: "From",
Status: "status",
}: {
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(timeutils.RFC3339NanoFixed)),
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(timeutils.RFC3339NanoFixed)),
+ fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(jsonlog.RFC3339NanoFixed)),
+ fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(jsonlog.RFC3339NanoFixed)),
},
// General, with both times Nano is preferred
JSONMessage{
@@ -92,8 +92,8 @@ func TestJSONMessageDisplay(t *testing.T) {
From: "From",
Status: "status",
}: {
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(timeutils.RFC3339NanoFixed)),
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(timeutils.RFC3339NanoFixed)),
+ fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(jsonlog.RFC3339NanoFixed)),
+ fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(jsonlog.RFC3339NanoFixed)),
},
// Stream over status
JSONMessage{