Add client time to events

This commit is contained in:
Daniel Smith 2014-10-21 22:28:12 -07:00
parent 7d5ed53958
commit ad1212b9af
6 changed files with 22 additions and 3 deletions

View File

@ -694,6 +694,9 @@ type Event struct {
// Optional. The component reporting this event. Should be a short machine understandable string. // Optional. The component reporting this event. Should be a short machine understandable string.
// TODO: provide exact specification for format. // TODO: provide exact specification for format.
Source string `json:"source,omitempty" yaml:"source,omitempty"` Source string `json:"source,omitempty" yaml:"source,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp util.Time `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
} }
// EventList is a list of events. // EventList is a list of events.

View File

@ -710,6 +710,9 @@ type Event struct {
// Optional. The component reporting this event. Should be a short machine understandable string. // Optional. The component reporting this event. Should be a short machine understandable string.
// TODO: provide exact specification for format. // TODO: provide exact specification for format.
Source string `json:"source,omitempty" yaml:"source,omitempty"` Source string `json:"source,omitempty" yaml:"source,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp util.Time `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
} }
// EventList is a list of events. // EventList is a list of events.

View File

@ -685,6 +685,9 @@ type Event struct {
// Optional. The component reporting this event. Should be a short machine understandable string. // Optional. The component reporting this event. Should be a short machine understandable string.
// TODO: provide exact specification for format. // TODO: provide exact specification for format.
Source string `json:"source,omitempty" yaml:"source,omitempty"` Source string `json:"source,omitempty" yaml:"source,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp util.Time `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
} }
// EventList is a list of events. // EventList is a list of events.

View File

@ -912,6 +912,9 @@ type Event struct {
// Optional. The component reporting this event. Should be a short machine understandable string. // Optional. The component reporting this event. Should be a short machine understandable string.
// TODO: provide exact specification for format. // TODO: provide exact specification for format.
Source string `json:"source,omitempty" yaml:"source,omitempty"` Source string `json:"source,omitempty" yaml:"source,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp util.Time `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
} }
// EventList is a list of events. // EventList is a list of events.

View File

@ -108,6 +108,7 @@ func Event(object runtime.Object, fieldPath, status, reason, message string) {
Status: status, Status: status,
Reason: reason, Reason: reason,
Message: message, Message: message,
Timestamp: util.Now(),
} }
events.Action(watch.Added, e) events.Action(watch.Added, e)

View File

@ -84,12 +84,18 @@ func TestEventf(t *testing.T) {
for _, item := range table { for _, item := range table {
called := make(chan struct{}) called := make(chan struct{})
testEvents := testEventRecorder{ testEvents := testEventRecorder{
OnEvent: func(a *api.Event) (*api.Event, error) { OnEvent: func(event *api.Event) (*api.Event, error) {
if e := item.expect; !reflect.DeepEqual(e, a) { a := *event
// Just check that the timestamp was set.
if a.Timestamp.IsZero() {
t.Errorf("timestamp wasn't set")
}
a.Timestamp = item.expect.Timestamp
if e, a := item.expect, &a; !reflect.DeepEqual(e, a) {
t.Errorf("diff: %s", util.ObjectDiff(e, a)) t.Errorf("diff: %s", util.ObjectDiff(e, a))
} }
called <- struct{}{} called <- struct{}{}
return a, nil return event, nil
}, },
} }
recorder := record.StartRecording(&testEvents, "eventTest") recorder := record.StartRecording(&testEvents, "eventTest")