forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
policybindings.go
81 lines (69 loc) · 3.22 KB
/
policybindings.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
package client
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch"
kapi "k8s.io/kubernetes/pkg/api"
authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization"
)
// PolicyBindingsNamespacer has methods to work with PolicyBinding resources in a namespace
type PolicyBindingsNamespacer interface {
PolicyBindings(namespace string) PolicyBindingInterface
}
// PolicyBindingInterface exposes methods on PolicyBinding resources.
type PolicyBindingInterface interface {
List(opts metav1.ListOptions) (*authorizationapi.PolicyBindingList, error)
Get(name string, options metav1.GetOptions) (*authorizationapi.PolicyBinding, error)
Create(policyBinding *authorizationapi.PolicyBinding) (*authorizationapi.PolicyBinding, error)
Delete(name string) error
Watch(opts metav1.ListOptions) (watch.Interface, error)
}
type PolicyBindingsListerNamespacer interface {
PolicyBindings(namespace string) PolicyBindingLister
}
type SyncedPolicyBindingsListerNamespacer interface {
PolicyBindingsListerNamespacer
LastSyncResourceVersion() string
}
type PolicyBindingLister interface {
List(options metav1.ListOptions) (*authorizationapi.PolicyBindingList, error)
Get(name string, options metav1.GetOptions) (*authorizationapi.PolicyBinding, error)
}
// policyBindings implements PolicyBindingsNamespacer interface
type policyBindings struct {
r *Client
ns string
}
// newPolicyBindings returns a policyBindings
func newPolicyBindings(c *Client, namespace string) *policyBindings {
return &policyBindings{
r: c,
ns: namespace,
}
}
// List returns a list of policyBindings that match the label and field selectors.
func (c *policyBindings) List(opts metav1.ListOptions) (result *authorizationapi.PolicyBindingList, err error) {
result = &authorizationapi.PolicyBindingList{}
err = c.r.Get().Namespace(c.ns).Resource("policyBindings").VersionedParams(&opts, kapi.ParameterCodec).Do().Into(result)
return
}
// Get returns information about a particular policyBinding and error if one occurs.
func (c *policyBindings) Get(name string, options metav1.GetOptions) (result *authorizationapi.PolicyBinding, err error) {
result = &authorizationapi.PolicyBinding{}
err = c.r.Get().Namespace(c.ns).Resource("policyBindings").Name(name).VersionedParams(&options, kapi.ParameterCodec).Do().Into(result)
return
}
// Create creates new policyBinding. Returns the server's representation of the policyBinding and error if one occurs.
func (c *policyBindings) Create(policyBinding *authorizationapi.PolicyBinding) (result *authorizationapi.PolicyBinding, err error) {
result = &authorizationapi.PolicyBinding{}
err = c.r.Post().Namespace(c.ns).Resource("policyBindings").Body(policyBinding).Do().Into(result)
return
}
// Delete deletes a policyBinding, returns error if one occurs.
func (c *policyBindings) Delete(name string) (err error) {
err = c.r.Delete().Namespace(c.ns).Resource("policyBindings").Name(name).Do().Error()
return
}
// Watch returns a watch.Interface that watches the requested policyBindings
func (c *policyBindings) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return c.r.Get().Prefix("watch").Namespace(c.ns).Resource("policyBindings").VersionedParams(&opts, kapi.ParameterCodec).Watch()
}