Commit e3594dfe authored by Daniel Smith's avatar Daniel Smith

Merge pull request #5404 from derekwaynecarr/delete_events

Client support to delete events
parents 5326baed 703d2a87
...@@ -40,6 +40,7 @@ type EventInterface interface { ...@@ -40,6 +40,7 @@ type EventInterface interface {
Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
// Search finds events about the specified object // Search finds events about the specified object
Search(objOrRef runtime.Object) (*api.EventList, error) Search(objOrRef runtime.Object) (*api.EventList, error)
Delete(name string) error
} }
// events implements Events interface // events implements Events interface
...@@ -161,3 +162,13 @@ func (e *events) Search(objOrRef runtime.Object) (*api.EventList, error) { ...@@ -161,3 +162,13 @@ func (e *events) Search(objOrRef runtime.Object) (*api.EventList, error) {
} }
return e.List(labels.Everything(), fields.AsSelector()) 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()
}
...@@ -175,3 +175,13 @@ func TestEventList(t *testing.T) { ...@@ -175,3 +175,13 @@ func TestEventList(t *testing.T) {
t.Errorf("%#v != %#v.", e, r) 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)
}
...@@ -64,3 +64,8 @@ func (c *FakeEvents) Search(objOrRef runtime.Object) (*api.EventList, error) { ...@@ -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"}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "search-events"})
return &c.Fake.EventsList, nil 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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment