From 841e997e336f75f0c2c0f5f479db8c5861013e40 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Fri, 19 Apr 2024 17:58:02 +0200 Subject: [PATCH] Improve the lister function documentation In particular, document that ListAllByNamespace delegates to ListAll if no namespace is specified. Signed-off-by: Stephen Kitt Kubernetes-commit: 54e899317ef46e3b70827cacee244717022db0ad --- tools/cache/listers.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/cache/listers.go b/tools/cache/listers.go index 420ca7b2..a60f4494 100644 --- a/tools/cache/listers.go +++ b/tools/cache/listers.go @@ -30,7 +30,7 @@ import ( // AppendFunc is used to add a matching item to whatever list the caller is using type AppendFunc func(interface{}) -// ListAll calls appendFn with each value retrieved from store which matches the selector. +// ListAll lists items in the store matching the given selector, calling appendFn on each one. func ListAll(store Store, selector labels.Selector, appendFn AppendFunc) error { selectAll := selector.Empty() for _, m := range store.List() { @@ -51,7 +51,9 @@ func ListAll(store Store, selector labels.Selector, appendFn AppendFunc) error { return nil } -// ListAllByNamespace used to list items belongs to namespace from Indexer. +// ListAllByNamespace lists items in the given namespace in the store matching the given selector, +// calling appendFn on each one. +// If a blank namespace (NamespaceAll) is specified, this delegates to ListAll(). func ListAllByNamespace(indexer Indexer, namespace string, selector labels.Selector, appendFn AppendFunc) error { if namespace == metav1.NamespaceAll { return ListAll(indexer, selector, appendFn)