예제 #1
0
파일: etcd.go 프로젝트: RomainVabre/origin
// NewStorage returns a RESTStorage object that will work against security context constraints objects.
func NewStorage(s storage.Interface) *REST {
	store := &etcdgeneric.Etcd{
		NewFunc:     func() runtime.Object { return &api.SecurityContextConstraints{} },
		NewListFunc: func() runtime.Object { return &api.SecurityContextConstraintsList{} },
		KeyRootFunc: func(ctx api.Context) string {
			return Prefix
		},
		KeyFunc: func(ctx api.Context, name string) (string, error) {
			return path.Join(Prefix, name), nil
		},
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*api.SecurityContextConstraints).Name, nil
		},
		PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
			return securitycontextconstraints.Matcher(label, field)
		},
		QualifiedResource: api.Resource("securitycontextconstraints"),

		CreateStrategy:      securitycontextconstraints.Strategy,
		UpdateStrategy:      securitycontextconstraints.Strategy,
		ReturnDeletedObject: true,
		Storage:             s,
	}
	return &REST{store}
}
예제 #2
0
파일: etcd.go 프로젝트: Xmagicer/origin
// NewStorage returns a RESTStorage object that will work against security context constraints objects.
func NewStorage(opts generic.RESTOptions) *REST {

	newListFunc := func() runtime.Object { return &api.SecurityContextConstraintsList{} }

	storageInterface := opts.Decorator(opts.Storage, cachesize.GetWatchCacheSizeByResource(cachesize.SecurityContextConstraints), &api.SecurityContextConstraints{}, Prefix, securitycontextconstraints.Strategy, newListFunc)

	store := &registry.Store{
		NewFunc:     func() runtime.Object { return &api.SecurityContextConstraints{} },
		NewListFunc: newListFunc,
		KeyRootFunc: func(ctx api.Context) string {
			return Prefix
		},
		KeyFunc: func(ctx api.Context, name string) (string, error) {
			return path.Join(Prefix, name), nil
		},
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*api.SecurityContextConstraints).Name, nil
		},
		PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
			return securitycontextconstraints.Matcher(label, field)
		},
		QualifiedResource: api.Resource("securitycontextconstraints"),

		CreateStrategy:      securitycontextconstraints.Strategy,
		UpdateStrategy:      securitycontextconstraints.Strategy,
		ReturnDeletedObject: true,
		Storage:             storageInterface,
	}
	return &REST{store}
}