forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
registry.go
32 lines (26 loc) · 952 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
32
package subjectaccessreview
import (
api "github.com/openshift/origin/pkg/authorization/apis/authorization"
"k8s.io/apimachinery/pkg/runtime"
apirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest"
)
type Registry interface {
CreateSubjectAccessReview(ctx apirequest.Context, subjectAccessReview *api.SubjectAccessReview) (*api.SubjectAccessReviewResponse, error)
}
type Storage interface {
Create(ctx apirequest.Context, obj runtime.Object, _ rest.ValidateObjectFunc, _ bool) (runtime.Object, error)
}
type storage struct {
Storage
}
func NewRegistry(s Storage) Registry {
return &storage{s}
}
func (s *storage) CreateSubjectAccessReview(ctx apirequest.Context, subjectAccessReview *api.SubjectAccessReview) (*api.SubjectAccessReviewResponse, error) {
obj, err := s.Create(ctx, subjectAccessReview, nil, false)
if err != nil {
return nil, err
}
return obj.(*api.SubjectAccessReviewResponse), nil
}