mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-19 08:54:44 +00:00
Add event client and easy creation library
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user