Use a local constant

This constant is going to be removed from jsonlog package.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-09-22 17:59:46 -04:00
parent 10e292dbab
commit 32612058cb
1 changed files with 6 additions and 3 deletions

View File

@ -15,7 +15,6 @@ import (
"github.com/docker/cli/templates" "github.com/docker/cli/templates"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
eventtypes "github.com/docker/docker/api/types/events" eventtypes "github.com/docker/docker/api/types/events"
"github.com/docker/docker/pkg/jsonlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -104,14 +103,18 @@ func makeTemplate(format string) (*template.Template, error) {
return tmpl, tmpl.Execute(ioutil.Discard, &eventtypes.Message{}) return tmpl, tmpl.Execute(ioutil.Discard, &eventtypes.Message{})
} }
// rfc3339NanoFixed is similar to time.RFC3339Nano, except it pads nanoseconds
// zeros to maintain a fixed number of characters
const rfc3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
// prettyPrintEvent prints all types of event information. // prettyPrintEvent prints all types of event information.
// Each output includes the event type, actor id, name and action. // Each output includes the event type, actor id, name and action.
// Actor attributes are printed at the end if the actor has any. // Actor attributes are printed at the end if the actor has any.
func prettyPrintEvent(out io.Writer, event eventtypes.Message) error { func prettyPrintEvent(out io.Writer, event eventtypes.Message) error {
if event.TimeNano != 0 { if event.TimeNano != 0 {
fmt.Fprintf(out, "%s ", time.Unix(0, event.TimeNano).Format(jsonlog.RFC3339NanoFixed)) fmt.Fprintf(out, "%s ", time.Unix(0, event.TimeNano).Format(rfc3339NanoFixed))
} else if event.Time != 0 { } else if event.Time != 0 {
fmt.Fprintf(out, "%s ", time.Unix(event.Time, 0).Format(jsonlog.RFC3339NanoFixed)) fmt.Fprintf(out, "%s ", time.Unix(event.Time, 0).Format(rfc3339NanoFixed))
} }
fmt.Fprintf(out, "%s %s %s", event.Type, event.Action, event.Actor.ID) fmt.Fprintf(out, "%s %s %s", event.Type, event.Action, event.Actor.ID)