Modify Event struct to allow compressing multiple recurring events in to a single event.

# *** ERROR: *** Some API files are missing the required field descriptions
# Add description tags to all non-inline fields in the following files:
#   pkg/api/v1beta1/types.go
#   pkg/api/v1beta2/types.go
#
# Your commit will be aborted unless you fix these.
#   COMMIT_BLOCKED_ON_DESCRIPTION
This commit is contained in:
saadali
2015-02-05 18:21:01 -08:00
parent ff4c23d803
commit 79cbcf918e
16 changed files with 148 additions and 44 deletions

View File

@@ -170,7 +170,9 @@ func Event(object runtime.Object, reason, message string) {
InvolvedObject: *ref,
Reason: reason,
Message: message,
Timestamp: t,
FirstTimestamp: t,
LastTimestamp: t,
Count: 1,
}
events.Action(watch.Added, e)

View File

@@ -93,6 +93,7 @@ func TestEventf(t *testing.T) {
Reason: "Started",
Message: "some verbose message: 1",
Source: api.EventSource{Component: "eventTest"},
Count: 1,
},
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): reason: 'Started' some verbose message: 1`,
},
@@ -116,6 +117,7 @@ func TestEventf(t *testing.T) {
Reason: "Started",
Message: "some verbose message: 1",
Source: api.EventSource{Component: "eventTest"},
Count: 1,
},
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:""}): reason: 'Started' some verbose message: 1`,
},
@@ -127,10 +129,11 @@ func TestEventf(t *testing.T) {
OnEvent: func(event *api.Event) (*api.Event, error) {
a := *event
// Just check that the timestamp was set.
if a.Timestamp.IsZero() {
if a.FirstTimestamp.IsZero() || a.LastTimestamp.IsZero() {
t.Errorf("timestamp wasn't set")
}
a.Timestamp = item.expect.Timestamp
a.FirstTimestamp = item.expect.FirstTimestamp
a.LastTimestamp = item.expect.LastTimestamp
// Check that name has the right prefix.
if n, en := a.Name, item.expect.Name; !strings.HasPrefix(n, en) {
t.Errorf("Name '%v' does not contain prefix '%v'", n, en)