Merge pull request #109632 from weilaaa/recorrect_byindex_input_param

correct input params of ByIndex
This commit is contained in:
Kubernetes Prow Robot 2022-06-22 09:29:43 -07:00 committed by GitHub
commit e2fe430da7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View File

@ -47,7 +47,7 @@ type Indexer interface {
// ByIndex returns the stored objects whose set of indexed values // ByIndex returns the stored objects whose set of indexed values
// for the named index includes the given indexed value // for the named index includes the given indexed value
ByIndex(indexName, indexedValue string) ([]interface{}, error) ByIndex(indexName, indexedValue string) ([]interface{}, error)
// GetIndexer return the indexers // GetIndexers return the indexers
GetIndexers() Indexers GetIndexers() Indexers
// AddIndexers adds more indexers to this store. If you call this after you already have data // AddIndexers adds more indexers to this store. If you call this after you already have data

View File

@ -199,8 +199,11 @@ func (c *cache) Index(indexName string, obj interface{}) ([]interface{}, error)
return c.cacheStorage.Index(indexName, obj) return c.cacheStorage.Index(indexName, obj)
} }
func (c *cache) IndexKeys(indexName, indexKey string) ([]string, error) { // IndexKeys returns the storage keys of the stored objects whose set of
return c.cacheStorage.IndexKeys(indexName, indexKey) // indexed values for the named index includes the given indexed value.
// The returned keys are suitable to pass to GetByKey().
func (c *cache) IndexKeys(indexName, indexedValue string) ([]string, error) {
return c.cacheStorage.IndexKeys(indexName, indexedValue)
} }
// ListIndexFuncValues returns the list of generated values of an Index func // ListIndexFuncValues returns the list of generated values of an Index func
@ -208,8 +211,10 @@ func (c *cache) ListIndexFuncValues(indexName string) []string {
return c.cacheStorage.ListIndexFuncValues(indexName) return c.cacheStorage.ListIndexFuncValues(indexName)
} }
func (c *cache) ByIndex(indexName, indexKey string) ([]interface{}, error) { // ByIndex returns the stored objects whose set of indexed values
return c.cacheStorage.ByIndex(indexName, indexKey) // for the named index includes the given indexed value.
func (c *cache) ByIndex(indexName, indexedValue string) ([]interface{}, error) {
return c.cacheStorage.ByIndex(indexName, indexedValue)
} }
func (c *cache) AddIndexers(newIndexers Indexers) error { func (c *cache) AddIndexers(newIndexers Indexers) error {

View File

@ -47,9 +47,9 @@ type ThreadSafeStore interface {
ListKeys() []string ListKeys() []string
Replace(map[string]interface{}, string) Replace(map[string]interface{}, string)
Index(indexName string, obj interface{}) ([]interface{}, error) Index(indexName string, obj interface{}) ([]interface{}, error)
IndexKeys(indexName, indexKey string) ([]string, error) IndexKeys(indexName, indexedValue string) ([]string, error)
ListIndexFuncValues(name string) []string ListIndexFuncValues(name string) []string
ByIndex(indexName, indexKey string) ([]interface{}, error) ByIndex(indexName, indexedValue string) ([]interface{}, error)
GetIndexers() Indexers GetIndexers() Indexers
// AddIndexers adds more indexers to this store. If you call this after you already have data // AddIndexers adds more indexers to this store. If you call this after you already have data