mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 02:45:06 +00:00
Add nil checks in custom deep copy function (#2664)
Signed-off-by: Kumar Mallikarjuna <kumarmallikarjuna1@gmail.com>
This commit is contained in:
parent
57d32e4883
commit
8f6028701e
1 changed files with 11 additions and 3 deletions
|
@ -162,15 +162,23 @@ func jsonDeepCopy(in apiextensions.JSON) *apiextensions.JSON {
|
|||
out_tmp := make([]interface{}, len(in))
|
||||
|
||||
for i, v := range in {
|
||||
out_tmp[i] = *jsonDeepCopy(v)
|
||||
if v != nil {
|
||||
out_tmp[i] = *jsonDeepCopy(v)
|
||||
} else {
|
||||
out_tmp[i] = nil
|
||||
}
|
||||
}
|
||||
|
||||
*out = out_tmp
|
||||
case map[string]interface{}:
|
||||
out_tmp := make(map[string]interface{})
|
||||
|
||||
for i, v := range in {
|
||||
out_tmp[i] = *jsonDeepCopy(v)
|
||||
for k, v := range in {
|
||||
if v != nil {
|
||||
out_tmp[k] = *jsonDeepCopy(v)
|
||||
} else {
|
||||
out_tmp[k] = nil
|
||||
}
|
||||
}
|
||||
|
||||
*out = out_tmp
|
||||
|
|
Loading…
Add table
Reference in a new issue