Commit Graph

6 Commits

Author SHA1 Message Date
Antti Kupila
f7764c6954 hclpack: Fix name range for unsupported attribute
Fixes an issue where the name range may be incorrect in case there are
multiple attributes and one of them is wrong. Another attribute's name
range could overwrite the previous one as the attr variable is
overwritten in the for loop.
2019-04-18 07:51:23 -07:00
Antti Kupila
d5b12e1c08 hclpack: fix missing range on remaining body
Fixes setting the MissingItemRange on the remaining body when a
*hclpack.Body is partially decoded. Otherwise when the remaining body is
decoded with missing fields, the diagnostic cannot point to where they
should be set.
2019-01-10 11:09:24 -08:00
Antti Kupila
b12d28fd16 hclpack: fix hclpack decoding nested body
Fixes an issue where a nested block would be decoded incorrectly, the
body of the last decoded block overwrites the previously decoded ones.

This was caused by the block being assigned on the stack in the for
loop; when the block is converted to a *hcl.Block, the pointer to Body
will always point to the same block. This caused decoding a new block to
overwrite the bodies of any previously decoded blocks.
2019-01-10 10:55:29 -08:00
Martin Atkins
309e278914 hclpack: Implement JSON marshaling (but not unmarshaling, yet) 2018-11-11 03:25:19 +00:00
Martin Atkins
ed7453e277 hclpack: PackNativeFile to get a packed version of a native syntax file
This is a straightforward way to get a hclpack.Body in the common case
where the input is already native syntax source code. Since the native
syntax is unambiguous about structure, the whole structure can be packed
in a single pass with no further information.
2018-11-11 00:40:31 +00:00
Martin Atkins
5e07d8e1f9 hclpack: New package for wire representations of hcl bodies
In most applications it's possible to fully evaluate configuration at the
beginning and work only with resolved values after that, but in some
unusual cases it's necessary to split parsing and decoding between two
separate processes connected by a pipe or network connection.

hclpack is intended to provide compact wire formats for sending bodies
over the network such that they can be decoded and evaluated and get the
same results. This is not something that can happen fully automatically
because a hcl.Body is an abstract node rather than a physical construct,
and so access to the original source code is required to construct such
a representation, and to interpret any source ranges that emerged from
the final evaluation.
2018-11-10 09:36:26 -08:00