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 { if !ok {
return nil, nil, fmt.Errorf("invalid object type") return nil, nil, fmt.Errorf("invalid object type")
} }
// TODO: internal version leaks through here. This should be versioned.
return labels.Set{}, labels.Set{ return labels.Set{}, labels.Set{
"involvedObject.kind": event.InvolvedObject.Kind, "involvedObject.kind": event.InvolvedObject.Kind,
"involvedObject.namespace": event.InvolvedObject.Namespace,
"involvedObject.name": event.InvolvedObject.Name, "involvedObject.name": event.InvolvedObject.Name,
"involvedObject.uid": event.InvolvedObject.UID, "involvedObject.uid": event.InvolvedObject.UID,
"involvedObject.apiVersion": event.InvolvedObject.APIVersion, "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, "involvedObject.fieldPath": event.InvolvedObject.FieldPath,
"status": event.Status, "status": event.Status,
"reason": event.Reason, "reason": event.Reason,
"source": event.Source,
}, nil }, nil
} }

View File

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