forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_user.go
90 lines (72 loc) · 2.26 KB
/
fake_user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package fake
import (
v1 "github.com/openshift/origin/pkg/user/api/v1"
api "k8s.io/kubernetes/pkg/api"
unversioned "k8s.io/kubernetes/pkg/api/unversioned"
core "k8s.io/kubernetes/pkg/client/testing/core"
labels "k8s.io/kubernetes/pkg/labels"
watch "k8s.io/kubernetes/pkg/watch"
)
// FakeUsers implements UserInterface
type FakeUsers struct {
Fake *FakeCore
ns string
}
var usersResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "users"}
func (c *FakeUsers) Create(user *v1.User) (result *v1.User, err error) {
obj, err := c.Fake.
Invokes(core.NewCreateAction(usersResource, c.ns, user), &v1.User{})
if obj == nil {
return nil, err
}
return obj.(*v1.User), err
}
func (c *FakeUsers) Update(user *v1.User) (result *v1.User, err error) {
obj, err := c.Fake.
Invokes(core.NewUpdateAction(usersResource, c.ns, user), &v1.User{})
if obj == nil {
return nil, err
}
return obj.(*v1.User), err
}
func (c *FakeUsers) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(usersResource, c.ns, name), &v1.User{})
return err
}
func (c *FakeUsers) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
action := core.NewDeleteCollectionAction(usersResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1.UserList{})
return err
}
func (c *FakeUsers) Get(name string) (result *v1.User, err error) {
obj, err := c.Fake.
Invokes(core.NewGetAction(usersResource, c.ns, name), &v1.User{})
if obj == nil {
return nil, err
}
return obj.(*v1.User), err
}
func (c *FakeUsers) List(opts api.ListOptions) (result *v1.UserList, err error) {
obj, err := c.Fake.
Invokes(core.NewListAction(usersResource, c.ns, opts), &v1.UserList{})
if obj == nil {
return nil, err
}
label := opts.LabelSelector
if label == nil {
label = labels.Everything()
}
list := &v1.UserList{}
for _, item := range obj.(*v1.UserList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested users.
func (c *FakeUsers) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(core.NewWatchAction(usersResource, c.ns, opts))
}