2 Copyright 2014 The Kubernetes Authors.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22 "k8s.io/apimachinery/pkg/fields"
23 "k8s.io/apimachinery/pkg/runtime"
24 types "k8s.io/apimachinery/pkg/types"
25 core "k8s.io/client-go/testing"
28 func (c *FakeEvents) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
29 action := core.NewRootCreateAction(eventsResource, event)
31 action = core.NewCreateAction(eventsResource, c.ns, event)
33 obj, err := c.Fake.Invokes(action, event)
38 return obj.(*v1.Event), err
41 // Update replaces an existing event. Returns the copy of the event the server returns, or an error.
42 func (c *FakeEvents) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
43 action := core.NewRootUpdateAction(eventsResource, event)
45 action = core.NewUpdateAction(eventsResource, c.ns, event)
47 obj, err := c.Fake.Invokes(action, event)
52 return obj.(*v1.Event), err
55 // PatchWithEventNamespace patches an existing event. Returns the copy of the event the server returns, or an error.
56 // TODO: Should take a PatchType as an argument probably.
57 func (c *FakeEvents) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.Event, error) {
58 // TODO: Should be configurable to support additional patch strategies.
59 pt := types.StrategicMergePatchType
60 action := core.NewRootPatchAction(eventsResource, event.Name, pt, data)
62 action = core.NewPatchAction(eventsResource, c.ns, event.Name, pt, data)
64 obj, err := c.Fake.Invokes(action, event)
69 return obj.(*v1.Event), err
72 // Search returns a list of events matching the specified object.
73 func (c *FakeEvents) Search(scheme *runtime.Scheme, objOrRef runtime.Object) (*v1.EventList, error) {
74 action := core.NewRootListAction(eventsResource, eventsKind, metav1.ListOptions{})
76 action = core.NewListAction(eventsResource, eventsKind, c.ns, metav1.ListOptions{})
78 obj, err := c.Fake.Invokes(action, &v1.EventList{})
83 return obj.(*v1.EventList), err
86 func (c *FakeEvents) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector {
87 action := core.GenericActionImpl{}
88 action.Verb = "get-field-selector"
89 action.Resource = eventsResource
91 c.Fake.Invokes(action, nil)
92 return fields.Everything()