forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
role_bindings.go
69 lines (58 loc) · 2.67 KB
/
role_bindings.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
package client
import (
kapi "k8s.io/kubernetes/pkg/api"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
)
// RoleBindingsNamespacer has methods to work with RoleBinding resources in a namespace
type RoleBindingsNamespacer interface {
RoleBindings(namespace string) RoleBindingInterface
}
// RoleBindingInterface exposes methods on RoleBinding resources.
type RoleBindingInterface interface {
List(opts kapi.ListOptions) (*authorizationapi.RoleBindingList, error)
Get(name string) (*authorizationapi.RoleBinding, error)
Create(roleBinding *authorizationapi.RoleBinding) (*authorizationapi.RoleBinding, error)
Update(roleBinding *authorizationapi.RoleBinding) (*authorizationapi.RoleBinding, error)
Delete(name string) error
}
// roleBindings implements RoleBindingsNamespacer interface
type roleBindings struct {
r *Client
ns string
}
// newRoleBindings returns a roleBindings
func newRoleBindings(c *Client, namespace string) *roleBindings {
return &roleBindings{
r: c,
ns: namespace,
}
}
// List returns a list of roleBindings that match the label and field selectors.
func (c *roleBindings) List(opts kapi.ListOptions) (result *authorizationapi.RoleBindingList, err error) {
result = &authorizationapi.RoleBindingList{}
err = c.r.Get().Namespace(c.ns).Resource("roleBindings").VersionedParams(&opts, kapi.ParameterCodec).Do().Into(result)
return
}
// Get returns information about a particular roleBinding and error if one occurs.
func (c *roleBindings) Get(name string) (result *authorizationapi.RoleBinding, err error) {
result = &authorizationapi.RoleBinding{}
err = c.r.Get().Namespace(c.ns).Resource("roleBindings").Name(name).Do().Into(result)
return
}
// Create creates new roleBinding. Returns the server's representation of the roleBinding and error if one occurs.
func (c *roleBindings) Create(roleBinding *authorizationapi.RoleBinding) (result *authorizationapi.RoleBinding, err error) {
result = &authorizationapi.RoleBinding{}
err = c.r.Post().Namespace(c.ns).Resource("roleBindings").Body(roleBinding).Do().Into(result)
return
}
// Update updates the roleBinding on server. Returns the server's representation of the roleBinding and error if one occurs.
func (c *roleBindings) Update(roleBinding *authorizationapi.RoleBinding) (result *authorizationapi.RoleBinding, err error) {
result = &authorizationapi.RoleBinding{}
err = c.r.Put().Namespace(c.ns).Resource("roleBindings").Name(roleBinding.Name).Body(roleBinding).Do().Into(result)
return
}
// Delete deletes a roleBinding, returns error if one occurs.
func (c *roleBindings) Delete(name string) (err error) {
err = c.r.Delete().Namespace(c.ns).Resource("roleBindings").Name(name).Do().Error()
return
}