A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pkg.go.dev/github.com/terramate-io/terramate@v0.14.4/test/hclwrite below:

hclwrite package - github.com/terramate-io/terramate/test/hclwrite - Go Packages

Package hclwrite aims to provide some facilities making it easier/safer to generate HCL code for testing purposes. It aims at:

- Close to how HCL is written. - Provide formatted string representation. - Avoid issues when raw HCL strings are used on tests in general.

It is not a replacement to hclwrite: https://pkg.go.dev/github.com/hashicorp/hcl/v2/hclwrite It is just easier/nicer to use on tests + circumvents some limitations like:

- https://stackoverflow.com/questions/67945463/how-to-use-hcl-write-to-set-expressions-with

We are missing a way to build objects and lists with a similar syntax to blocks. For now we circumvent this with the AttributeValue function.

This section is empty.

This section is empty.

Format formats the given HCL code.

Block represents an HCL block.

BuildBlock builds a block with the given name and N block builders.

BuildHCL builds a root HCL document.

AddBlock adds a nested block on the block.

AddBoolean adds boolean on block.

AddExpr adds an expression to the block. The expressions are kept as is on the final document.

AddLabel adds a label to the block.

AddNumberInt adds a number to the block.

AddString adds string on block.

AttributesValues gets all attributes that are evaluated values. Added expressions are ignored.

Build builds the given parent block by adding itself on it.

HasExpressions returns true if block has any non-evaluated expressions.

String returns a string representation of the block that should always be formatted HCL code.

type BlockBuilder interface {
	Build(*Block)
}

BlockBuilder provides a general purpose way to build blocks.

AttributeValue accepts an expr as the attribute value, similar to Expression, but will evaluate the expr and store the resulting value so it will be available as an attribute value instead of as an expression. If evaluation fails the test caller will fail.

The evaluation is quite limited, only suitable for evaluating objects/lists/etc, but won't work with any references to namespaces except default Terraform function calls.

Boolean adds a boolean attribute to the block.

Expression adds the attribute with the given name with the given expression, the expression won't be evaluated and this won't affect the attribute values of the block.

The given expression will be added on the generated output verbatim.

Labels creates a block builder that adds labels to block.

NumberInt adds a number attribute to the block.

String adds a string attribute to the block.

type BlockBuilderFunc func(*Block)

BlockBuilderFunc is an adapter to allow the use of ordinary functions as BlockBuilders.

Build calls the underlying builder function to build the given block.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4