-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathaws_manual.deepcopy.go
50 lines (43 loc) · 1.08 KB
/
aws_manual.deepcopy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package v1
// DeepCopy is a deepcopy function, copying the receiver, creating a new IAMPolicyCondition.
func (in *IAMPolicyCondition) DeepCopy() *IAMPolicyCondition {
if in == nil {
return nil
}
out := new(IAMPolicyCondition)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is a deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *IAMPolicyCondition) DeepCopyInto(out *IAMPolicyCondition) {
if *in == nil {
return
}
*out = make(IAMPolicyCondition, len(*in))
tgt := *out
for key, val := range *in {
if val != nil {
tgt[key] = make(IAMPolicyConditionKeyValue, len(val))
for subKey, subVal := range val {
tgt[key][subKey] = copyStringOrStringSlice(subVal)
}
}
}
}
func copyStringOrStringSlice(from interface{}) interface{} {
var to interface{}
switch v := from.(type) {
case string:
// simple assignment creates copy
to = from
case []string:
toSlice := make([]string, len(v))
copy(toSlice, v)
to = toSlice
default:
// unexpected type, this could mean we're not
// doing a deepcopy
to = from
}
return to
}