Add handling empty index key that may cause panic issue
This commit is contained in:
3
pkg/client/cache/index.go
vendored
3
pkg/client/cache/index.go
vendored
@@ -55,6 +55,9 @@ func IndexFuncToKeyFuncAdapter(indexFunc IndexFunc) KeyFunc {
|
|||||||
if len(indexKeys) > 1 {
|
if len(indexKeys) > 1 {
|
||||||
return "", fmt.Errorf("too many keys: %v", indexKeys)
|
return "", fmt.Errorf("too many keys: %v", indexKeys)
|
||||||
}
|
}
|
||||||
|
if len(indexKeys) == 0 {
|
||||||
|
return "", fmt.Errorf("unexpected empty indexKeys")
|
||||||
|
}
|
||||||
return indexKeys[0], nil
|
return indexKeys[0], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user