Support Elem on lists

This commit is contained in:
Mitchell Hashimoto 2014-08-11 21:33:44 -07:00
parent bf89042e7b
commit 1a9d040ea4
2 changed files with 11 additions and 5 deletions

View File

@ -198,6 +198,10 @@ func (d *decoder) decodeMap(name string, o *hcl.Object, result reflect.Value) er
// Go through each element and decode it.
current := o
for current != nil {
if current.Value == nil {
continue
}
m := current.Value.([]*hcl.Object)
for _, o := range m {
// Make the field name

View File

@ -69,12 +69,14 @@ func (o *Object) Elem(expand bool) []*Object {
return result
}
switch o.Type {
case ValueTypeObject:
if o.Value == nil {
return nil
}
switch o.Type {
case ValueTypeList:
return o.Value.([]*Object)
case ValueTypeObject:
return o.Value.([]*Object)
}