// NewREST returns a RESTStorage object that will work against access tokens func NewREST(h tools.EtcdHelper) *REST { store := &etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &api.OAuthAccessToken{} }, NewListFunc: func() runtime.Object { return &api.OAuthAccessTokenList{} }, KeyRootFunc: func(ctx kapi.Context) string { return EtcdPrefix }, KeyFunc: func(ctx kapi.Context, name string) (string, error) { return etcdgeneric.NoNamespaceKeyFunc(ctx, EtcdPrefix, name) }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.OAuthAccessToken).Name, nil }, PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return oauthaccesstoken.Matcher(label, field) }, TTLFunc: func(obj runtime.Object, existing uint64, update bool) (uint64, error) { token := obj.(*api.OAuthAccessToken) expires := uint64(token.ExpiresIn) return expires, nil }, EndpointName: "oauthaccesstokens", Helper: h, } store.CreateStrategy = oauthaccesstoken.Strategy return &REST{store} }
// NewREST returns a RESTStorage object that will work against identites func NewREST(h tools.EtcdHelper) *REST { store := &etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &api.Identity{} }, NewListFunc: func() runtime.Object { return &api.IdentityList{} }, KeyRootFunc: func(ctx kapi.Context) string { // TODO: JTL: switch to NoNamespaceKeyRootFunc after rebase return EtcdPrefix }, KeyFunc: func(ctx kapi.Context, name string) (string, error) { return etcdgeneric.NoNamespaceKeyFunc(ctx, EtcdPrefix, name) }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.Identity).Name, nil }, PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return identity.MatchIdentity(label, field) }, EndpointName: "identities", Helper: h, } store.CreateStrategy = identity.Strategy store.UpdateStrategy = identity.Strategy return &REST{*store} }
// NewStorage returns a RESTStorage object that will work against nodes. func NewStorage(h tools.EtcdHelper) *REST { store := &etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &authorizationapi.ClusterPolicy{} }, NewListFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyList{} }, EndpointName: "clusterpolicy", KeyRootFunc: func(ctx kapi.Context) string { return ClusterPolicyPath }, KeyFunc: func(ctx kapi.Context, id string) (string, error) { return etcdgeneric.NoNamespaceKeyFunc(ctx, ClusterPolicyPath, id) }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*authorizationapi.ClusterPolicy).Name, nil }, PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return clusterpolicy.Matcher(label, field) }, CreateStrategy: clusterpolicy.Strategy, UpdateStrategy: clusterpolicy.Strategy, Helper: h, } return &REST{store} }