summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMartin Atkins <mart@degeneration.co.uk>2024-05-08 17:55:39 -0700
committerMartin Atkins <mart@degeneration.co.uk>2024-05-09 11:32:15 -0700
commit318bbfebb5e1eeea09765b1edb1aec303f75a268 (patch)
tree01a33e63c36b7d2f54482c1cd87bcd136096a4dd /ext
parent9a64c17c75059d9c8f5d94f2265c00026ac48781 (diff)
hcldec: Allow body-derived values to be marked
Similar to the previously-added UnknownBody, the new optional interface MarkedBody allows hcl.Body implementations to suggest a set of marks that ought to be applied to any value that's generated to represent the content of that body. The dynblock extension then uses this to get hcldec to mark the whole object representing any block that was generated by a dynamic block whose for_each was marked, for a better representation of the fact that a block's existence was decided based on a marked value.
Diffstat (limited to 'ext')
-rw-r--r--ext/dynblock/expand_body.go5
-rw-r--r--ext/dynblock/expand_body_test.go2
2 files changed, 6 insertions, 1 deletions
diff --git a/ext/dynblock/expand_body.go b/ext/dynblock/expand_body.go
index e630f18..2cafae5 100644
--- a/ext/dynblock/expand_body.go
+++ b/ext/dynblock/expand_body.go
@@ -270,3 +270,8 @@ func (b *expandBody) JustAttributes() (hcl.Attributes, hcl.Diagnostics) {
func (b *expandBody) MissingItemRange() hcl.Range {
return b.original.MissingItemRange()
}
+
+// hcldec.MarkedBody impl
+func (b *expandBody) BodyValueMarks() cty.ValueMarks {
+ return b.valueMarks
+}
diff --git a/ext/dynblock/expand_body_test.go b/ext/dynblock/expand_body_test.go
index 3b245ee..0941f29 100644
--- a/ext/dynblock/expand_body_test.go
+++ b/ext/dynblock/expand_body_test.go
@@ -762,7 +762,7 @@ func TestExpandMarkedForEach(t *testing.T) {
cty.ObjectVal(map[string]cty.Value{
"val0": cty.StringVal("static c 1").Mark("boop"),
"val1": cty.StringVal("hey").Mark("boop"),
- }),
+ }).Mark("boop"),
})
got, diags := hcldec.Decode(dynBody, decSpec, nil)
if diags.HasErrors() {