// NewStorage returns a RESTStorage object that will work against namespaces func NewStorage(h tools.EtcdHelper) (*REST, *StatusREST, *FinalizeREST) { prefix := "/namespaces" store := &etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &api.Namespace{} }, NewListFunc: func() runtime.Object { return &api.NamespaceList{} }, 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.Namespace).Name, nil }, PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return namespace.MatchNamespace(label, field) }, EndpointName: "namespaces", Helper: h, } store.CreateStrategy = namespace.Strategy store.UpdateStrategy = namespace.Strategy store.ReturnDeletedObject = true statusStore := *store statusStore.UpdateStrategy = namespace.StatusStrategy finalizeStore := *store finalizeStore.UpdateStrategy = namespace.FinalizeStrategy return &REST{Etcd: store, status: &statusStore}, &StatusREST{store: &statusStore}, &FinalizeREST{store: &finalizeStore} }
// NewREST returns a RESTStorage object that will work against namespaces func NewREST(h tools.EtcdHelper) *REST { store := &etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &api.Namespace{} }, NewListFunc: func() runtime.Object { return &api.NamespaceList{} }, KeyRootFunc: func(ctx api.Context) string { return "/registry/namespaces" }, KeyFunc: func(ctx api.Context, name string) (string, error) { return "/registry/namespaces/" + name, nil }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.Namespace).Name, nil }, PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return namespace.MatchNamespace(label, field) }, EndpointName: "namespaces", Helper: h, } store.CreateStrategy = namespace.Strategy store.UpdateStrategy = namespace.Strategy store.ReturnDeletedObject = true return &REST{Etcd: store} }