summaryrefslogtreecommitdiff
path: root/hclwrite/examples_test.go
AgeCommit message (Collapse)Author
2023-02-28[COMPLIANCE] Add Copyright and License Headers (#586)hashicorp-copywrite[bot]
* [COMPLIANCE] Add Copyright and License Headers * add copywrite file and revert headers in testdata --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Liam Cervante <liam.cervante@hashicorp.com>
2020-05-06hclwrite: Generate multi-line objects and mapsAlisdair McDiarmid
The previous syntax for object and map values was a single line of key-value pairs. For example: object = { bar = 5, baz = true, foo = "foo" } This is very compact, but in practice for many HCL values, less readable and less common than a multi-line object format. This commit changes the generated output from hclwrite to one line per attribute. Examples of the new format: // Empty object/map is a single line a = {} // Single-value object/map has the attribute on a separate line b = { bar = 5 } // Multi-value object/map has one line per attribute c = { bar = 5 baz = true }
2019-09-09Unfold the "hcl" directory up into the rootMartin Atkins
The main HCL package is more visible this way, and so it's easier than having to pick it out from dozens of other package directories.
2019-09-09Change module path to github.com/hashicorp/hcl/v2Martin Atkins
This is in preparation for the first v2 release from the main HCL repository.
2018-12-14hcl/hclsyntax: Accept single-line block definitionsMartin Atkins
This relaxes our previous spec to include a special form from HCL 1: foo { bar = baz } Although we normally require each argument to be on a line of its own, as a special case we allow a block to be defined with a single nested argument all on one line. Only one nested argument definition is allowed, and a nested block definition like "foo { bar {} }" is also disallowed in order to force the more-readable split of bar {} onto a line of its own. This is a pragmatic addition for broader compatibility with HCL 1-oriented input. This single-line usage is not considered idiomatic HCL 2 and may in future be undone by the formatter, though for now it is left as-is aside from the spacing around the braces. This also changes the behavior of the source code formatter to include spaces on both sides of braces. This mimicks the formatting behavior of HCL 1 for this situation, and (subjectively) reads better even for other one-line braced expressions like object constructors and object for expressions.
2018-11-04hclwrite: Expression.RenameVariablePrefixMartin Atkins
This function serves the use-case of surgically renaming references to variables in an existing file without disturbing other tokens.
2018-11-04hclwrite: Implement Body.SetAttributeTraversalMartin Atkins
2018-11-03hclwrite: Recast TestRoundupCreate as an exampleMartin Atkins
Since the goal of this is to be somewhat realistic of what a caller might do, we might as well also include it in the godoc examples.