// NewREST returns a RESTStorage object that will work against services. func NewREST(s storage.Interface, storageFactory storage.StorageFactory) *REST { prefix := "/services/specs" newListFunc := func() runtime.Object { return &api.ServiceList{} } storageInterface := storageFactory( s, 100, nil, &api.Service{}, prefix, false, newListFunc) store := &etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &api.Service{} }, NewListFunc: newListFunc, KeyRootFunc: func(ctx api.Context) string { return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix) }, KeyFunc: func(ctx api.Context, name string) (string, error) { return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name) }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.Service).Name, nil }, PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return service.MatchServices(label, field) }, EndpointName: "services", CreateStrategy: service.Strategy, UpdateStrategy: service.Strategy, Storage: storageInterface, } return &REST{store} }
// NewREST returns a RESTStorage object that will work against services. func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) { prefix := "/services/specs" newListFunc := func() runtime.Object { return &api.ServiceList{} } storageInterface := opts.Decorator( opts.Storage, cachesize.GetWatchCacheSizeByResource(cachesize.Services), &api.Service{}, prefix, service.Strategy, newListFunc) store := &etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &api.Service{} }, NewListFunc: newListFunc, KeyRootFunc: func(ctx api.Context) string { return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix) }, KeyFunc: func(ctx api.Context, name string) (string, error) { return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name) }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.Service).Name, nil }, PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return service.MatchServices(label, field) }, QualifiedResource: api.Resource("services"), DeleteCollectionWorkers: opts.DeleteCollectionWorkers, CreateStrategy: service.Strategy, UpdateStrategy: service.Strategy, Storage: storageInterface, } statusStore := *store statusStore.UpdateStrategy = service.StatusStrategy return &REST{store}, &StatusREST{store: &statusStore} }