Refactored BPA controller code for better testing
[icn.git] / cmd / bpa-operator / vendor / k8s.io / client-go / kubernetes / typed / core / v1 / fake / fake_event_expansion.go
1 /*
2 Copyright 2014 The Kubernetes Authors.
3
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
7
8     http://www.apache.org/licenses/LICENSE-2.0
9
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.
15 */
16
17 package fake
18
19 import (
20         "k8s.io/api/core/v1"
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"
26 )
27
28 func (c *FakeEvents) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
29         action := core.NewRootCreateAction(eventsResource, event)
30         if c.ns != "" {
31                 action = core.NewCreateAction(eventsResource, c.ns, event)
32         }
33         obj, err := c.Fake.Invokes(action, event)
34         if obj == nil {
35                 return nil, err
36         }
37
38         return obj.(*v1.Event), err
39 }
40
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)
44         if c.ns != "" {
45                 action = core.NewUpdateAction(eventsResource, c.ns, event)
46         }
47         obj, err := c.Fake.Invokes(action, event)
48         if obj == nil {
49                 return nil, err
50         }
51
52         return obj.(*v1.Event), err
53 }
54
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)
61         if c.ns != "" {
62                 action = core.NewPatchAction(eventsResource, c.ns, event.Name, pt, data)
63         }
64         obj, err := c.Fake.Invokes(action, event)
65         if obj == nil {
66                 return nil, err
67         }
68
69         return obj.(*v1.Event), err
70 }
71
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{})
75         if c.ns != "" {
76                 action = core.NewListAction(eventsResource, eventsKind, c.ns, metav1.ListOptions{})
77         }
78         obj, err := c.Fake.Invokes(action, &v1.EventList{})
79         if obj == nil {
80                 return nil, err
81         }
82
83         return obj.(*v1.EventList), err
84 }
85
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
90
91         c.Fake.Invokes(action, nil)
92         return fields.Everything()
93 }