mirror of https://github.com/k3s-io/k3s
Merge pull request #5404 from derekwaynecarr/delete_events
Client support to delete eventspull/6/head
commit
e3594dfe2f
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue