MCPcopy
hub / github.com/kubernetes/client-go / ByIndex

Method ByIndex

tools/cache/thread_safe_store.go:175–193  ·  view source on GitHub ↗

ByIndex returns a list of items that match an exact value on the index function

(indexName, indexKey string)

Source from the content-addressed store, hash-verified

173
174// ByIndex returns a list of items that match an exact value on the index function
175func (c *threadSafeMap) ByIndex(indexName, indexKey string) ([]interface{}, error) {
176 c.lock.RLock()
177 defer c.lock.RUnlock()
178
179 indexFunc := c.indexers[indexName]
180 if indexFunc == nil {
181 return nil, fmt.Errorf("Index with name %s does not exist", indexName)
182 }
183
184 index := c.indices[indexName]
185
186 set := index[indexKey]
187 list := make([]interface{}, 0, set.Len())
188 for key := range set {
189 list = append(list, c.items[key])
190 }
191
192 return list, nil
193}
194
195// IndexKeys returns a list of keys that match on the index function.
196// IndexKeys is thread-safe so long as you treat all items as immutable.

Callers

nothing calls this directly

Calls 2

ErrorfMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected