Skip to content

Commit

Permalink
Fix slices
Browse files Browse the repository at this point in the history
  • Loading branch information
aruiz14 authored and manno committed Oct 31, 2023
1 parent d51189d commit 54a0095
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/apis/fleet.cattle.io/v1alpha1/generic_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,29 @@ func deepCopyMap(src, dest map[string]interface{}) {
destValue := make(map[string]interface{}, len(value))
deepCopyMap(value, destValue)
dest[key] = destValue
case []any:
destValue := make([]any, len(value))
deepCopySlice(value, destValue)
dest[key] = destValue
default:
dest[key] = value
}
}
}

func deepCopySlice(src, dest []any) {
for i := range src {
switch value := src[i].(type) {
case map[string]interface{}:
destValue := make(map[string]interface{}, len(value))
deepCopyMap(value, destValue)
dest[i] = destValue
case []any:
destValue := make([]any, len(value))
deepCopySlice(value, destValue)
dest[i] = destValue
default:
dest[i] = value
}
}
}

0 comments on commit 54a0095

Please sign in to comment.