From ad7a234ea8da660b660ec92dad98ffc147ce33ab Mon Sep 17 00:00:00 2001 From: Wojciech Tyczynski Date: Wed, 16 Nov 2016 10:19:55 +0100 Subject: [PATCH] Cache fields for filtering in watchCache. --- apiserver/rest/reststorage.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apiserver/rest/reststorage.go b/apiserver/rest/reststorage.go index f2a7bd85..d68d7278 100644 --- a/apiserver/rest/reststorage.go +++ b/apiserver/rest/reststorage.go @@ -40,8 +40,15 @@ func NewREST(config *storagebackend.Config, storageDecorator generic.StorageDeco newListFunc := func() runtime.Object { return &testgroup.TestTypeList{} } // Usually you should reuse your RESTCreateStrategy. strategy := &NotNamespaceScoped{} + getAttrs := func(obj runtime.Object) (labels.Set, fields.Set, error) { + testObj, ok := obj.(*testgroup.TestType) + if !ok { + return nil, nil, fmt.Errorf("not a TestType") + } + return labels.Set(testObj.Labels), nil, nil + } storageInterface, _ := storageDecorator( - config, 100, &testgroup.TestType{}, prefix, strategy, newListFunc, storage.NoTriggerPublisher) + config, 100, &testgroup.TestType{}, prefix, strategy, newListFunc, getAttrs, storage.NoTriggerPublisher) store := ®istry.Store{ NewFunc: func() runtime.Object { return &testgroup.TestType{} }, // NewListFunc returns an object capable of storing results of an etcd list.