Skip to content

Commit 2c34df6

Browse files
fix reconstruction of null (#198)
this fixes #195
1 parent a7b43db commit 2c34df6

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

hcl2/reconstructor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,12 @@ def _transform_value_to_expr_term(self, value, level) -> Union[Token, Tree]:
540540
)
541541
return Tree(Token("RULE", "expr_term"), [tuple_tree])
542542

543+
if value is None:
544+
return Tree(
545+
Token("RULE", "expr_term"),
546+
[Tree(Token("RULE", "identifier"), [Token("NAME", "null")])],
547+
)
548+
543549
# for dicts, recursively turn the child k/v pairs into object elements
544550
# and store within an object
545551
if isinstance(value, dict):

test/helpers/terraform-config-json/locals_embedded_condition.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
{
44
"terraform": {
55
"channels": "${local.running_in_ci ? local.ci_channels : local.local_channels}",
6-
"authentication": []
6+
"authentication": [],
7+
"foo": null
78
}
89
}
910
]

test/helpers/terraform-config/locals_embedded_condition.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ locals {
22
terraform = {
33
channels = (local.running_in_ci ? local.ci_channels : local.local_channels),
44
authentication = [],
5+
foo = null,
56
}
67
}

test/unit/test_builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def test_locals_embdedded_condition_tf(self):
4444
terraform={
4545
"channels": "${local.running_in_ci ? local.ci_channels : local.local_channels}",
4646
"authentication": [],
47+
"foo": None,
4748
},
4849
)
4950

0 commit comments

Comments
 (0)