forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
role_bindings.go
51 lines (43 loc) · 1.85 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
package client
import (
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 {
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,
}
}
// 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
}