Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ var _ = Describe("Informer Cache with ReaderFailOnMissingInformer", func() {
var _ = Describe("Multi-Namespace Informer Cache", func() {
CacheTest(cache.New, cache.Options{
DefaultNamespaces: map[string]cache.Config{
testNamespaceOne: {},
testNamespaceTwo: {},
"default": {},
cache.AllNamespaces: {FieldSelector: fields.OneTermEqualSelector("metadata.namespace", testNamespaceOne)},
testNamespaceTwo: {},
"default": {},
},
})
NonBlockingGetTest(cache.New, cache.Options{
DefaultNamespaces: map[string]cache.Config{
testNamespaceOne: {},
testNamespaceTwo: {},
"default": {},
cache.AllNamespaces: {FieldSelector: fields.OneTermEqualSelector("metadata.namespace", testNamespaceOne)},
testNamespaceTwo: {},
"default": {},
},
})
})
Expand Down
3 changes: 3 additions & 0 deletions pkg/cache/multi_namespace_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ func (c *multiNamespaceCache) List(ctx context.Context, list client.ObjectList,
if listOpts.Namespace != corev1.NamespaceAll {
cache, ok := c.namespaceToCache[listOpts.Namespace]
if !ok {
if global, hasGlobal := c.namespaceToCache[AllNamespaces]; hasGlobal {
return global.List(ctx, list, opts...)
}
return fmt.Errorf("unable to list: %v because of unknown namespace for the cache", listOpts.Namespace)
}
return cache.List(ctx, list, opts...)
Expand Down