/
etcd.go
51 lines (42 loc) · 1.52 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
package rolebindingrestriction
import (
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/generic/registry"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
"github.com/openshift/origin/pkg/util/restoptions"
)
type REST struct {
*registry.Store
}
// NewStorage returns a RESTStorage object that will work against nodes.
func NewStorage(optsGetter restoptions.Getter) (*REST, error) {
store, err := makeStore(optsGetter)
if err != nil {
return nil, err
}
return &REST{Store: store}, nil
}
func makeStore(optsGetter restoptions.Getter) (*registry.Store, error) {
store := ®istry.Store{
NewFunc: func() runtime.Object { return &authorizationapi.RoleBindingRestriction{} },
NewListFunc: func() runtime.Object { return &authorizationapi.RoleBindingRestrictionList{} },
QualifiedResource: authorizationapi.Resource("rolebindingrestrictions"),
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*authorizationapi.RoleBindingRestriction).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
return Matcher(label, field)
},
CreateStrategy: Strategy,
UpdateStrategy: Strategy,
DeleteStrategy: Strategy,
ReturnDeletedObject: false,
}
if err := restoptions.ApplyOptions(optsGetter, store, true, storage.NoTriggerPublisher); err != nil {
return nil, err
}
return store, nil
}