Add event client and easy creation library

This commit is contained in:
Daniel Smith
2014-10-10 17:46:38 -07:00
parent 434017fdf1
commit 95b855b8e6
5 changed files with 319 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ type Fake struct {
ServiceList api.ServiceList
EndpointsList api.EndpointsList
Minions api.MinionList
Events api.EventList
Err error
Watch watch.Interface
}
@@ -152,3 +153,27 @@ func (c *Fake) ListMinions() (*api.MinionList, error) {
c.Actions = append(c.Actions, FakeAction{Action: "list-minions", Value: nil})
return &c.Minions, nil
}
// CreateEvent makes a new event. Returns the copy of the event the server returns, or an error.
func (c *Fake) CreateEvent(event *api.Event) (*api.Event, error) {
c.Actions = append(c.Actions, FakeAction{Action: "get-event", Value: event.ID})
return &api.Event{}, nil
}
// ListEvents returns a list of events matching the selectors.
func (c *Fake) ListEvents(label, field labels.Selector) (*api.EventList, error) {
c.Actions = append(c.Actions, FakeAction{Action: "list-events"})
return &c.Events, nil
}
// GetEvent returns the given event, or an error.
func (c *Fake) GetEvent(id string) (*api.Event, error) {
c.Actions = append(c.Actions, FakeAction{Action: "get-event", Value: id})
return &api.Event{}, nil
}
// WatchEvents starts watching for events matching the given selectors.
func (c *Fake) WatchEvents(label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
c.Actions = append(c.Actions, FakeAction{Action: "watch-events", Value: resourceVersion})
return c.Watch, c.Err
}