Categorygithub.com/yoanm/go-tfsig
modulepackage
0.2.3
Repository: https://github.com/yoanm/go-tfsig.git
Documentation: pkg.go.dev

# README

go-tfsig - hclwrite wrapper

License Code size Go Reference

Dependabot Status Last commit

Codacy Badge Go Report Card

CI codecov

GitHub go.mod Go version

Wrapper for Terraform HCL language (hclwrite)

Generate block signatures which are easier to manipulate and alter than hclwrite tokens

Documentation

Package documentation available there

# Packages

No description provided by the author
Package tokens provides an easy way to create common hclwrite tokens (such as new line, comma, equal sign, ident) It also provides an easy way to encapsulate hclwrite tokens into a cty.Value and a function (`Generate()`) to manage those type of value */.

# Functions

AppendAttributeIfNotNil appends the provided attribute to the signature only if not nil It simply avoids an `if` in your code.
AppendBlockIfNotNil appends the provided block to the provided body only if block is not nil It simply avoids an `if` in your code.
AppendChildIfNotNil appends the provided child to the signature only if not nil.
AppendNewLineAndBlockIfNotNil appends an empty line followed by provided block to the provided body only if block is not nil It simply avoids an `if` in your code.
NewBodyAttribute returns an Attribute BodyElement.
NewBodyBlock returns a Block BodyElement.
NewBodyEmptyLine returns an empty line BodyElement.
NewIdentTokenMatcher returns an instance of IdentTokenMatcher with provided list of prefix to consider as 'ident' tokens `local.`, `var.` and `data.` tokens will be considered as 'ident' tokens by default.
NewResource returns a BlockSignature pointer with "resource" type and filled with provided labels.
NewSignature returns a BlockSignature pointer filled with provided type and labels.
NewValueGenerator returns a new ValueGenerator with the default 'ident' tokens matcher augmented with provided list of token to consider as 'ident' tokens.
NewValueGeneratorWith returns a new ValueGenerator with the provided matcher.
ToTerraformIdentifier converts a string to a terraform identifier, by converting not allowed characters to `-` And if provided value starts with a character not allowed as first character, it replaces it by `_`.

# Structs

BlockSignature is basically a wrapper to HCL blocks It holds a type, the block labels and its elements.
BodyElement is a wrapper for more or less anything that can be appended to a BlockSignature.
IdentTokenMatcher is a simple implementation for IdentTokenMatcherInterface.
LifecycleCondition is used for Precondition and Postcondition property of LifecycleConfig It's basically a wrapper for terraform lifecycle pre- and post-conditions.
LifecycleConfig is used as argument for `Lifecycle()` method It's basically a wrapper for terraform `lifecycle` directive.
ValueGenerator is able to detect "ident" tokens and convert them into a special cty capsule.

# Interfaces

IdentTokenMatcherInterface is a simple interface declaring required method to detect an 'ident' token.

# Type aliases

BodyElements is a simple wrapper for a list of BodyElement.