Add 'source' to events field selector.

This commit is contained in:
Daniel Smith 2014-11-10 17:46:40 -08:00
parent d6d6229fea
commit f1b0b64a75
2 changed files with 7 additions and 0 deletions

View File

@ -88,8 +88,10 @@ func (rs *REST) getAttrs(obj runtime.Object) (objLabels, objFields labels.Set, e
if !ok {
return nil, nil, fmt.Errorf("invalid object type")
}
// TODO: internal version leaks through here. This should be versioned.
return labels.Set{}, labels.Set{
"involvedObject.kind": event.InvolvedObject.Kind,
"involvedObject.namespace": event.InvolvedObject.Namespace,
"involvedObject.name": event.InvolvedObject.Name,
"involvedObject.uid": event.InvolvedObject.UID,
"involvedObject.apiVersion": event.InvolvedObject.APIVersion,
@ -97,6 +99,7 @@ func (rs *REST) getAttrs(obj runtime.Object) (objLabels, objFields labels.Set, e
"involvedObject.fieldPath": event.InvolvedObject.FieldPath,
"status": event.Status,
"reason": event.Reason,
"source": event.Source,
}, nil
}

View File

@ -98,6 +98,7 @@ func TestRESTgetAttrs(t *testing.T) {
InvolvedObject: api.ObjectReference{
Kind: "Pod",
Name: "foo",
Namespace: "baz",
UID: "long uid string",
APIVersion: testapi.Version(),
ResourceVersion: "0",
@ -105,6 +106,7 @@ func TestRESTgetAttrs(t *testing.T) {
},
Status: "tested",
Reason: "forTesting",
Source: "test",
}
label, field, err := rest.getAttrs(eventA)
if err != nil {
@ -116,12 +118,14 @@ func TestRESTgetAttrs(t *testing.T) {
expect := labels.Set{
"involvedObject.kind": "Pod",
"involvedObject.name": "foo",
"involvedObject.namespace": "baz",
"involvedObject.uid": "long uid string",
"involvedObject.apiVersion": testapi.Version(),
"involvedObject.resourceVersion": "0",
"involvedObject.fieldPath": "",
"status": "tested",
"reason": "forTesting",
"source": "test",
}
if e, a := expect, field; !reflect.DeepEqual(e, a) {
t.Errorf("diff: %s", util.ObjectDiff(e, a))