forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
registry.go
31 lines (25 loc) · 892 Bytes
/
registry.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
package localsubjectaccessreview
import (
api "github.com/openshift/origin/pkg/authorization/apis/authorization"
"k8s.io/apimachinery/pkg/runtime"
apirequest "k8s.io/apiserver/pkg/endpoints/request"
)
type Registry interface {
CreateLocalSubjectAccessReview(ctx apirequest.Context, subjectAccessReview *api.LocalSubjectAccessReview) (*api.SubjectAccessReviewResponse, error)
}
type Storage interface {
Create(ctx apirequest.Context, obj runtime.Object) (runtime.Object, error)
}
type storage struct {
Storage
}
func NewRegistry(s Storage) Registry {
return &storage{s}
}
func (s *storage) CreateLocalSubjectAccessReview(ctx apirequest.Context, subjectAccessReview *api.LocalSubjectAccessReview) (*api.SubjectAccessReviewResponse, error) {
obj, err := s.Create(ctx, subjectAccessReview)
if err != nil {
return nil, err
}
return obj.(*api.SubjectAccessReviewResponse), nil
}