Merge pull request #5404 from derekwaynecarr/delete_events

Client support to delete events
pull/6/head
Daniel Smith 2015-03-13 12:36:43 -07:00
commit e3594dfe2f
3 changed files with 26 additions and 0 deletions

View File

@ -40,6 +40,7 @@ type EventInterface interface {
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
// Search finds events about the specified object
Search(objOrRef runtime.Object) (*api.EventList, error)
Delete(name string) error
}
// events implements Events interface
@ -161,3 +162,13 @@ func (e *events) Search(objOrRef runtime.Object) (*api.EventList, error) {
}
return e.List(labels.Everything(), fields.AsSelector())
}
// Delete deletes an existing event.
func (e *events) Delete(name string) error {
return e.client.Delete().
NamespaceIfScoped(e.namespace, len(e.namespace) > 0).
Resource("events").
Name(name).
Do().
Error()
}

View File

@ -175,3 +175,13 @@ func TestEventList(t *testing.T) {
t.Errorf("%#v != %#v.", e, r)
}
}
func TestEventDelete(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: "/events/foo"},
Response: Response{StatusCode: 200},
}
err := c.Setup().Events(ns).Delete("foo")
c.Validate(t, nil, err)
}

View File

@ -64,3 +64,8 @@ func (c *FakeEvents) Search(objOrRef runtime.Object) (*api.EventList, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "search-events"})
return &c.Fake.EventsList, nil
}
func (c *FakeEvents) Delete(name string) error {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "delete-event", Value: name})
return nil
}