Skip to content

Commit

Permalink
Client support to delete events
Browse files Browse the repository at this point in the history
  • Loading branch information
derekwaynecarr committed Mar 12, 2015
1 parent 07c2035 commit 703d2a8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/client/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
10 changes: 10 additions & 0 deletions pkg/client/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
5 changes: 5 additions & 0 deletions pkg/client/fake_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 703d2a8

Please sign in to comment.