Skip to content

Commit

Permalink
returned objects of reference type should be unchangeable
Browse files Browse the repository at this point in the history
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
  • Loading branch information
mars1024 committed Mar 29, 2022
1 parent c46b410 commit 5c78ed8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/cache/informer_cache.go
Expand Up @@ -193,8 +193,8 @@ func indexByField(indexer Informer, field string, extractor client.IndexerFunc)
rawVals := extractor(obj)
var vals []string
if ns == "" {
// if we're not doubling the keys for the namespaced case, just re-use what was returned to us
vals = rawVals
// if we're not doubling the keys for the namespaced case, just create a new slice with same length
vals = make([]string, len(rawVals))
} else {
// if we need to add non-namespaced versions too, double the length
vals = make([]string, len(rawVals)*2)
Expand Down

0 comments on commit 5c78ed8

Please sign in to comment.