diff --git a/decoder.go b/decoder.go index 2534f47..24e81da 100644 --- a/decoder.go +++ b/decoder.go @@ -199,6 +199,7 @@ func (d *decoder) decodeMap(name string, o *hcl.Object, result reflect.Value) er current := o for current != nil { if current.Value == nil { + current = current.Next continue } diff --git a/decoder_test.go b/decoder_test.go index aa3c4a6..446cd99 100644 --- a/decoder_test.go +++ b/decoder_test.go @@ -20,6 +20,17 @@ func TestDecode_interface(t *testing.T) { "foo": "bar", }, }, + { + "empty.hcl", + false, + map[string]interface{}{ + "resource": map[string]interface{}{ + "aws_instance": map[string]interface{}{ + "db": map[string]interface{}{}, + }, + }, + }, + }, /* { "structure.hcl", @@ -67,10 +78,10 @@ func TestDecode_equal(t *testing.T) { "basic.json", }, /* - { - "structure.hcl", - "structure.json", - }, + { + "structure.hcl", + "structure.json", + }, */ { "structure.hcl", diff --git a/test-fixtures/empty.hcl b/test-fixtures/empty.hcl new file mode 100644 index 0000000..8553eeb --- /dev/null +++ b/test-fixtures/empty.hcl @@ -0,0 +1 @@ +resource "aws_instance" "db" {}