fix: allow family inside a block
This commit is contained in:
parent
b3acb51625
commit
2245638a8d
3 changed files with 28 additions and 1 deletions
|
|
@ -115,8 +115,12 @@ class RougailOutputHcl(RougailOutputJson):
|
|||
parent_obj[name] = []
|
||||
block_to_insert = parent_obj[name]
|
||||
block_to_insert.extend(child_obj)
|
||||
elif parent_is_block:
|
||||
elif parent_is_block and child_obj.get("__is_block__", False):
|
||||
parent_obj.append({name: child_obj})
|
||||
elif parent_is_block:
|
||||
if not parent_obj:
|
||||
parent_obj.append({})
|
||||
parent_obj[-1][name] = child_obj
|
||||
else:
|
||||
parent_obj[name] = child_obj
|
||||
|
||||
|
|
|
|||
8
tests/results/10-doc_family_inside_a_block.yaml.hcl
Normal file
8
tests/results/10-doc_family_inside_a_block.yaml.hcl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
stack {
|
||||
a_family_1 = {
|
||||
a_variable = "a value"
|
||||
}
|
||||
a_family_2 = {
|
||||
a_variable = "a value"
|
||||
}
|
||||
}
|
||||
15
tests/structures/10-doc_family_inside_a_block.yaml
Normal file
15
tests/structures/10-doc_family_inside_a_block.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
stack:
|
||||
hcl_type: block
|
||||
|
||||
a_family_1: # a family 1
|
||||
|
||||
a_variable: a value
|
||||
|
||||
a_family_2: # a family 2
|
||||
|
||||
a_variable: a value
|
||||
...
|
||||
Loading…
Reference in a new issue