1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/pkg/resourcecache/gvrcache_test.go
shuting c692263177
Refactor resourceCache; Reduce throttling requests (background controller) (#1500)
* skip sending API request for filtered resource

* fix PR comment

Signed-off-by: Shuting Zhao <shutting06@gmail.com>

* fixes https://github.com/kyverno/kyverno/issues/1490

Signed-off-by: Shuting Zhao <shutting06@gmail.com>

* fix bug - namespace is not returned properly

Signed-off-by: Shuting Zhao <shutting06@gmail.com>

* reduce throttling - list resource using lister

* refactor resource cache

* fix test

Signed-off-by: Shuting Zhao <shutting06@gmail.com>

* fix label selector

Signed-off-by: Shuting Zhao <shutting06@gmail.com>

* fix build failure

Signed-off-by: Shuting Zhao <shutting06@gmail.com>
2021-01-29 17:38:23 -08:00

45 lines
912 B
Go

package resourcecache
import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/cache"
)
// TODO :- Implementation for mocking
type TestGVRCache struct {
}
func NewTestGVRCache() GenericCache {
return &genericCache{}
}
func (tg *TestGVRCache) StopInformer() {
}
func (tg *TestGVRCache) IsNamespaced() bool {
return true
}
func (tg *TestGVRCache) GetLister() cache.GenericLister {
return &TestLister{}
}
func (tg *TestGVRCache) GetNamespacedLister(namespace string) cache.GenericNamespaceLister {
return &TestLister{}
}
type TestLister struct {
}
func (tl *TestLister) List(selector labels.Selector) ([]runtime.Object, error) {
return []runtime.Object{}, nil
}
func (tl *TestLister) Get(name string) (runtime.Object, error) {
return nil, nil
}
func (tl *TestLister) ByNamespace(namespace string) cache.GenericNamespaceLister {
return &TestLister{}
}