Skip to content

Commit 34979e8

Browse files
committed
Address comments
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
1 parent 6a7c677 commit 34979e8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

pkg/cache/internal/cache_reader.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ func (c *CacheReader) List(ctx context.Context, out client.ObjectList, opts ...c
132132

133133
_, isClusterAware := c.indexer.GetIndexers()[kcpcache.ClusterAndNamespaceIndexName]
134134
clusterName, _ := kontext.ClusterFrom(ctx)
135-
if isClusterAware && clusterName.Empty() {
136-
return fmt.Errorf("cluster-aware cache requires a cluster in context")
137-
}
138135

139136
switch {
140137
case listOpts.FieldSelector != nil:
@@ -147,13 +144,13 @@ func (c *CacheReader) List(ctx context.Context, out client.ObjectList, opts ...c
147144
// namespace.
148145
objs, err = byIndexes(c.indexer, listOpts.FieldSelector.Requirements(), clusterName, listOpts.Namespace)
149146
case listOpts.Namespace != "":
150-
if isClusterAware {
147+
if isClusterAware && !clusterName.Empty() {
151148
objs, err = c.indexer.ByIndex(kcpcache.ClusterAndNamespaceIndexName, kcpcache.ClusterAndNamespaceIndexKey(clusterName, listOpts.Namespace))
152149
} else {
153150
objs, err = c.indexer.ByIndex(cache.NamespaceIndex, listOpts.Namespace)
154151
}
155152
default:
156-
if isClusterAware {
153+
if isClusterAware && !clusterName.Empty() {
157154
objs, err = c.indexer.ByIndex(kcpcache.ClusterIndexName, kcpcache.ClusterIndexKey(clusterName))
158155
} else {
159156
objs = c.indexer.List()

0 commit comments

Comments
 (0)