forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
etcd.go
52 lines (43 loc) · 1.74 KB
/
etcd.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
package etcd
import (
kapi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/generic"
"k8s.io/kubernetes/pkg/registry/generic/registry"
"k8s.io/kubernetes/pkg/runtime"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
"github.com/openshift/origin/pkg/authorization/registry/clusterpolicybinding"
"github.com/openshift/origin/pkg/util"
"github.com/openshift/origin/pkg/util/restoptions"
)
const ClusterPolicyBindingPath = "/authorization/cluster/policybindings"
type REST struct {
*registry.Store
}
// NewStorage returns a RESTStorage object that will work against nodes.
func NewStorage(optsGetter restoptions.Getter) (*REST, error) {
store := ®istry.Store{
NewFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyBinding{} },
NewListFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyBindingList{} },
QualifiedResource: authorizationapi.Resource("clusterpolicybindings"),
KeyRootFunc: func(ctx kapi.Context) string {
return ClusterPolicyBindingPath
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return util.NoNamespaceKeyFunc(ctx, ClusterPolicyBindingPath, id)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*authorizationapi.ClusterPolicyBinding).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return clusterpolicybinding.Matcher(label, field)
},
CreateStrategy: clusterpolicybinding.Strategy,
UpdateStrategy: clusterpolicybinding.Strategy,
}
if err := restoptions.ApplyOptions(optsGetter, store, ClusterPolicyBindingPath); err != nil {
return nil, err
}
return &REST{store}, nil
}