fix watch of single object

This commit is contained in:
Daniel Smith
2015-04-23 16:02:22 -07:00
parent 67b5b080b8
commit 2fa3ae9f15
6 changed files with 129 additions and 15 deletions

View File

@@ -117,7 +117,12 @@ func (rs *REST) getAttrs(obj runtime.Object) (objLabels labels.Set, objFields fi
if !ok {
return nil, nil, fmt.Errorf("invalid object type")
}
return labels.Set{}, fields.Set{
l := event.Labels
if l == nil {
l = labels.Set{}
}
return l, fields.Set{
"metadata.name": event.Name,
"involvedObject.kind": event.InvolvedObject.Kind,
"involvedObject.namespace": event.InvolvedObject.Namespace,
"involvedObject.name": event.InvolvedObject.Name,

View File

@@ -162,6 +162,7 @@ func TestRESTGet(t *testing.T) {
func TestRESTgetAttrs(t *testing.T) {
_, rest := NewTestREST()
eventA := &api.Event{
ObjectMeta: api.ObjectMeta{Name: "f0118"},
InvolvedObject: api.ObjectReference{
Kind: "Pod",
Name: "foo",
@@ -182,6 +183,7 @@ func TestRESTgetAttrs(t *testing.T) {
t.Errorf("diff: %s", util.ObjectDiff(e, a))
}
expect := fields.Set{
"metadata.name": "f0118",
"involvedObject.kind": "Pod",
"involvedObject.name": "foo",
"involvedObject.namespace": "baz",