Skip to content

Commit 8458363

Browse files
committed
Add .Cluster and .Namespace
Signed-off-by: Nelo-T. Wallus <[email protected]>
1 parent 5457a0f commit 8458363

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

third_party/k8s.io/client-go/listers/generic_helpers.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ func NewCluster[T runtime.Object](indexer cache.Indexer, resource schema.GroupRe
4141
return ResourceClusterIndexer[T]{indexer: indexer, resource: resource}
4242
}
4343

44+
func (l ResourceClusterIndexer[T]) Cluster(cluster logicalcluster.Name) ResourceIndexer[T] {
45+
return ResourceIndexer[T]{indexer: l.indexer, cluster: cluster, resource: l.resource}
46+
}
47+
4448
// List lists all resources in the indexer matching the given selector.
4549
func (l ResourceClusterIndexer[T]) List(selector labels.Selector) (ret []T, err error) {
4650
err = cache.ListAll(l.indexer, selector, func(m interface{}) {
@@ -64,8 +68,17 @@ func New[T runtime.Object](indexer cache.Indexer, cluster logicalcluster.Name, r
6468
return ResourceIndexer[T]{indexer: indexer, cluster: cluster, resource: resource}
6569
}
6670

71+
func (l ResourceIndexer[T]) Cluster(cluster logicalcluster.Name) ResourceIndexer[T] {
72+
return ResourceIndexer[T]{indexer: l.indexer, cluster: cluster, resource: l.resource, namespace: l.namespace}
73+
}
74+
75+
func (l ResourceIndexer[T]) Namespace(namespace string) ResourceIndexer[T] {
76+
return ResourceIndexer[T]{indexer: l.indexer, cluster: l.cluster, resource: l.resource, namespace: namespace}
77+
}
78+
6779
// NewNamespaced returns a new instance of a namespaced lister (resource indexer) wrapping the given parent and namespace for the specified type.
6880
// This is intended for use by listers (generated by lister-gen) only.
81+
// Deprecrated: use ResourceIndexer.Namespace instead.
6982
func NewNamespaced[T runtime.Object](parent ResourceIndexer[T], namespace string) ResourceIndexer[T] {
7083
return ResourceIndexer[T]{indexer: parent.indexer, resource: parent.resource, namespace: namespace}
7184
}

0 commit comments

Comments
 (0)