// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers. func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) { prefix := "/horizontalpodautoscalers" newListFunc := func() runtime.Object { return &extensions.HorizontalPodAutoscalerList{} } storageInterface := opts.Decorator( opts.Storage, cachesize.GetWatchCacheSizeByResource(cachesize.HorizontalPodAutoscalers), &extensions.HorizontalPodAutoscaler{}, prefix, horizontalpodautoscaler.Strategy, newListFunc) store := ®istry.Store{ NewFunc: func() runtime.Object { return &extensions.HorizontalPodAutoscaler{} }, // NewListFunc returns an object capable of storing results of an etcd list. NewListFunc: newListFunc, // Produces a path that etcd understands, to the root of the resource // by combining the namespace in the context with the given prefix KeyRootFunc: func(ctx api.Context) string { return registry.NamespaceKeyRootFunc(ctx, prefix) }, // Produces a path that etcd understands, to the resource by combining // the namespace in the context with the given prefix KeyFunc: func(ctx api.Context, name string) (string, error) { return registry.NamespaceKeyFunc(ctx, prefix, name) }, // Retrieve the name field of an autoscaler ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*extensions.HorizontalPodAutoscaler).Name, nil }, // Used to match objects based on labels/fields for list PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return horizontalpodautoscaler.MatchAutoscaler(label, field) }, QualifiedResource: extensions.Resource("horizontalpodautoscalers"), DeleteCollectionWorkers: opts.DeleteCollectionWorkers, // Used to validate autoscaler creation CreateStrategy: horizontalpodautoscaler.Strategy, // Used to validate autoscaler updates UpdateStrategy: horizontalpodautoscaler.Strategy, DeleteStrategy: horizontalpodautoscaler.Strategy, Storage: storageInterface, } statusStore := *store statusStore.UpdateStrategy = horizontalpodautoscaler.StatusStrategy return &REST{store}, &StatusREST{store: &statusStore} }
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers. func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator) (*REST, *StatusREST) { prefix := "/horizontalpodautoscalers" newListFunc := func() runtime.Object { return &extensions.HorizontalPodAutoscalerList{} } storageInterface := storageDecorator( s, 100, &extensions.HorizontalPodAutoscaler{}, prefix, false, newListFunc) store := &etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &extensions.HorizontalPodAutoscaler{} }, // NewListFunc returns an object capable of storing results of an etcd list. NewListFunc: newListFunc, // Produces a path that etcd understands, to the root of the resource // by combining the namespace in the context with the given prefix KeyRootFunc: func(ctx api.Context) string { return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix) }, // Produces a path that etcd understands, to the resource by combining // the namespace in the context with the given prefix KeyFunc: func(ctx api.Context, name string) (string, error) { return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name) }, // Retrieve the name field of an autoscaler ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*extensions.HorizontalPodAutoscaler).Name, nil }, // Used to match objects based on labels/fields for list PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return horizontalpodautoscaler.MatchAutoscaler(label, field) }, EndpointName: "horizontalPodAutoscalers", // Used to validate autoscaler creation CreateStrategy: horizontalpodautoscaler.Strategy, // Used to validate autoscaler updates UpdateStrategy: horizontalpodautoscaler.Strategy, Storage: storageInterface, } statusStore := *store statusStore.UpdateStrategy = horizontalpodautoscaler.StatusStrategy return &REST{store}, &StatusREST{store: &statusStore} }