// NewREST returns a registry which will store ThirdPartyResource in the given helper func NewREST(opts generic.RESTOptions) *REST { prefix := "/thirdpartyresources" // We explicitly do NOT do any decoration here yet. storageInterface := opts.Storage store := ®istry.Store{ NewFunc: func() runtime.Object { return &extensions.ThirdPartyResource{} }, NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceList{} }, KeyRootFunc: func(ctx api.Context) string { return prefix }, KeyFunc: func(ctx api.Context, id string) (string, error) { return registry.NoNamespaceKeyFunc(ctx, prefix, id) }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*extensions.ThirdPartyResource).Name, nil }, PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return thirdpartyresource.Matcher(label, field) }, QualifiedResource: extensions.Resource("thirdpartyresources"), DeleteCollectionWorkers: opts.DeleteCollectionWorkers, CreateStrategy: thirdpartyresource.Strategy, UpdateStrategy: thirdpartyresource.Strategy, DeleteStrategy: thirdpartyresource.Strategy, Storage: storageInterface, } return &REST{store} }
// NewREST returns a RESTStorage object that will work against nodes. func NewStorage(opts generic.RESTOptions, connection client.ConnectionInfoGetter, proxyTransport http.RoundTripper) NodeStorage { prefix := "/minions" newListFunc := func() runtime.Object { return &api.NodeList{} } storageInterface := opts.Decorator( opts.Storage, cachesize.GetWatchCacheSizeByResource(cachesize.Nodes), &api.Node{}, prefix, node.Strategy, newListFunc) store := ®istry.Store{ NewFunc: func() runtime.Object { return &api.Node{} }, NewListFunc: newListFunc, KeyRootFunc: func(ctx api.Context) string { return prefix }, KeyFunc: func(ctx api.Context, name string) (string, error) { return registry.NoNamespaceKeyFunc(ctx, prefix, name) }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.Node).Name, nil }, PredicateFunc: node.MatchNode, QualifiedResource: api.Resource("nodes"), DeleteCollectionWorkers: opts.DeleteCollectionWorkers, CreateStrategy: node.Strategy, UpdateStrategy: node.Strategy, DeleteStrategy: node.Strategy, ExportStrategy: node.Strategy, Storage: storageInterface, } statusStore := *store statusStore.UpdateStrategy = node.StatusStrategy nodeREST := &REST{store, connection, proxyTransport} return NodeStorage{ Node: nodeREST, Status: &StatusREST{store: &statusStore}, Proxy: &noderest.ProxyREST{Store: store, Connection: client.ConnectionInfoGetter(nodeREST), ProxyTransport: proxyTransport}, } }
// NewREST returns a RESTStorage object that will work against namespaces. func NewREST(opts generic.RESTOptions) (*REST, *StatusREST, *FinalizeREST) { prefix := "/namespaces" newListFunc := func() runtime.Object { return &api.NamespaceList{} } storageInterface := opts.Decorator( opts.Storage, cachesize.GetWatchCacheSizeByResource(cachesize.Namespaces), &api.Namespace{}, prefix, namespace.Strategy, newListFunc) store := ®istry.Store{ NewFunc: func() runtime.Object { return &api.Namespace{} }, NewListFunc: newListFunc, KeyRootFunc: func(ctx api.Context) string { return prefix }, KeyFunc: func(ctx api.Context, name string) (string, error) { return registry.NoNamespaceKeyFunc(ctx, prefix, name) }, 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) }, QualifiedResource: api.Resource("namespaces"), DeleteCollectionWorkers: opts.DeleteCollectionWorkers, CreateStrategy: namespace.Strategy, UpdateStrategy: namespace.Strategy, DeleteStrategy: namespace.Strategy, ReturnDeletedObject: true, Storage: storageInterface, } statusStore := *store statusStore.UpdateStrategy = namespace.StatusStrategy finalizeStore := *store finalizeStore.UpdateStrategy = namespace.FinalizeStrategy return &REST{Store: store, status: &statusStore}, &StatusREST{store: &statusStore}, &FinalizeREST{store: &finalizeStore} }
// NewREST returns a registry which will store CertificateSigningRequest in the given helper func NewREST(opts generic.RESTOptions) (*REST, *StatusREST, *ApprovalREST) { prefix := "/certificatesigningrequests" newListFunc := func() runtime.Object { return &certificates.CertificateSigningRequestList{} } storageInterface := opts.Decorator(opts.Storage, cachesize.GetWatchCacheSizeByResource(cachesize.CertificateSigningRequests), &certificates.CertificateSigningRequest{}, prefix, csrregistry.Strategy, newListFunc) store := ®istry.Store{ NewFunc: func() runtime.Object { return &certificates.CertificateSigningRequest{} }, NewListFunc: newListFunc, KeyRootFunc: func(ctx api.Context) string { return prefix }, KeyFunc: func(ctx api.Context, id string) (string, error) { return registry.NoNamespaceKeyFunc(ctx, prefix, id) }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*certificates.CertificateSigningRequest).Name, nil }, PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return csrregistry.Matcher(label, field) }, QualifiedResource: certificates.Resource("certificatesigningrequests"), DeleteCollectionWorkers: opts.DeleteCollectionWorkers, CreateStrategy: csrregistry.Strategy, UpdateStrategy: csrregistry.Strategy, Storage: storageInterface, } // Subresources use the same store and creation strategy, which only // allows empty subs. Updates to an existing subresource are handled by // dedicated strategies. statusStore := *store statusStore.UpdateStrategy = csrregistry.StatusStrategy approvalStore := *store approvalStore.UpdateStrategy = csrregistry.ApprovalStrategy return &REST{store}, &StatusREST{store: &statusStore}, &ApprovalREST{store: &approvalStore} }