forked from owulveryck/toscalib
-
Notifications
You must be signed in to change notification settings - Fork 4
/
reflector.go
40 lines (36 loc) · 1006 Bytes
/
reflector.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
package toscalib
func reflectAssignmentProps(src map[string]PropertyAssignment, dest map[string]AttributeAssignment) *map[string]AttributeAssignment {
for name, def := range src {
if len(dest) == 0 {
dest = make(map[string]AttributeAssignment)
}
_, ok := dest[name]
if !ok {
a := new(AttributeAssignment)
a.Value = def.Value
a.Function = def.Function
a.Args = def.Args
a.Expression = def.Expression
dest[name] = *a // dereference pointer
}
}
return &dest
}
func reflectDefinitionProps(src map[string]PropertyDefinition, dest map[string]AttributeDefinition) *map[string]AttributeDefinition {
for name, def := range src {
if len(dest) == 0 {
dest = make(map[string]AttributeDefinition)
}
_, ok := dest[name]
if !ok {
a := new(AttributeDefinition)
a.Type = def.Type
a.Description = def.Description
a.Default = def.Default
a.Status = def.Status
a.EntrySchema = def.EntrySchema
dest[name] = *a // dereference pointer
}
}
return &dest
}