mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-13 19:28:55 +00:00
fix: add type conversion error judgment to avoid program panic (#6526)
fix: add type conversion error judgment to avoid program panic Signed-off-by: wangshuai <wangshuai31@xiaomi.com> Co-authored-by: wangshuai <wangshuai31@xiaomi.com> Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Co-authored-by: Chip Zoller <chipzoller@gmail.com>
This commit is contained in:
parent
d3db3bc342
commit
ee1e7a7add
1 changed files with 11 additions and 2 deletions
|
@ -115,7 +115,10 @@ func getValueAsStringMap(key string, data interface{}) (string, map[string]strin
|
|||
return "", nil
|
||||
}
|
||||
|
||||
dataMap := data.(map[string]interface{})
|
||||
dataMap, ok := data.(map[string]interface{})
|
||||
if !ok {
|
||||
return "", nil
|
||||
}
|
||||
patternKey, val := getPatternValue(key, dataMap)
|
||||
|
||||
if val == nil {
|
||||
|
@ -123,7 +126,13 @@ func getValueAsStringMap(key string, data interface{}) (string, map[string]strin
|
|||
}
|
||||
|
||||
result := map[string]string{}
|
||||
for k, v := range val.(map[string]interface{}) {
|
||||
|
||||
valMap, ok := val.(map[string]interface{})
|
||||
if !ok {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
for k, v := range valMap {
|
||||
result[k] = v.(string)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue