forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clusterroles.go
67 lines (56 loc) · 2.53 KB
/
clusterroles.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
package client
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
)
// ClusterRolesInterface has methods to work with ClusterRoles resources in a namespace
type ClusterRolesInterface interface {
ClusterRoles() ClusterRoleInterface
}
// ClusterRoleInterface exposes methods on ClusterRoles resources
type ClusterRoleInterface interface {
List(label labels.Selector, field fields.Selector) (*authorizationapi.ClusterRoleList, error)
Get(name string) (*authorizationapi.ClusterRole, error)
Create(role *authorizationapi.ClusterRole) (*authorizationapi.ClusterRole, error)
Update(role *authorizationapi.ClusterRole) (*authorizationapi.ClusterRole, error)
Delete(name string) error
}
type clusterRoles struct {
r *Client
}
// newClusterRoles returns a clusterRoles
func newClusterRoles(c *Client) *clusterRoles {
return &clusterRoles{
r: c,
}
}
// List returns a list of clusterRoles that match the label and field selectors.
func (c *clusterRoles) List(label labels.Selector, field fields.Selector) (result *authorizationapi.ClusterRoleList, err error) {
result = &authorizationapi.ClusterRoleList{}
err = c.r.Get().Resource("clusterRoles").LabelsSelectorParam(label).FieldsSelectorParam(field).Do().Into(result)
return
}
// Get returns information about a particular role and error if one occurs.
func (c *clusterRoles) Get(name string) (result *authorizationapi.ClusterRole, err error) {
result = &authorizationapi.ClusterRole{}
err = c.r.Get().Resource("clusterRoles").Name(name).Do().Into(result)
return
}
// Create creates new role. Returns the server's representation of the role and error if one occurs.
func (c *clusterRoles) Create(role *authorizationapi.ClusterRole) (result *authorizationapi.ClusterRole, err error) {
result = &authorizationapi.ClusterRole{}
err = c.r.Post().Resource("clusterRoles").Body(role).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 *clusterRoles) Update(role *authorizationapi.ClusterRole) (result *authorizationapi.ClusterRole, err error) {
result = &authorizationapi.ClusterRole{}
err = c.r.Put().Resource("clusterRoles").Name(role.Name).Body(role).Do().Into(result)
return
}
// Delete deletes a role, returns error if one occurs.
func (c *clusterRoles) Delete(name string) (err error) {
err = c.r.Delete().Resource("clusterRoles").Name(name).Do().Error()
return
}