tfhcl

package
v0.52.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2024 License: MPL-2.0, MPL-2.0, MPL-2.0 Imports: 8 Imported by: 0

README

Forked hcl/ext/dynblock package

This package is a fork of github.com/hashicorp/hcl/ext/dynblock. TFLint maintains its own dynblock implementation to support not only dynamic blocks, but also count/for_each meta-arguments in the HCL layer.

Documentation

Overview

Package tfhcl is a fork of hcl/ext/dynblock. Like dynblock, it supports dynamic block expansion, but also resource expansion via count/for_each meta-arguments. This package is defined separately from hclext because meta-arguments are a Terraform concern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(body hcl.Body, ctx *hcl.EvalContext) hcl.Body

Expand "dynamic" blocks and count/for_for_each meta-arguments resources in the given body, returning a new body that has those blocks expanded.

The given EvalContext is used when evaluating attributes within the given body. If the body has a dynamic block or an expandable resource, its contents are evaluated immediately.

Expand returns no diagnostics because no blocks are actually expanded until a call to Content or PartialContent on the returned body, which will then expand only the blocks selected by the schema.

func ExpandExpressionsHCLExt added in v0.51.0

func ExpandExpressionsHCLExt(body hcl.Body, schema *hclext.BodySchema) []hcl.Expression

ExpandExpressionsHCLExt is ExpandVariablesHCLExt which returns []hcl.Expression instead of []hcl.Traversal.

func ExpandVariablesHCLExt

func ExpandVariablesHCLExt(body hcl.Body, schema *hclext.BodySchema) []hcl.Traversal

ExpandVariablesHCLExt is a wrapper around dynblock.WalkVariables that uses the given hclext.BodySchema to automatically drive the recursive walk through nested blocks in the given body.

Note that it's a wrapper around ExpandVariables, not WalkExpandVariables. This package evaluates expressions immediately on expansion, so we always need all variables to expand. It also implicitly walks count/for_each to support expansion by meta-arguments.

func MakeCountIteration

func MakeCountIteration(index cty.Value) *metaArgIteration

func MakeForEachIteration

func MakeForEachIteration(key, value cty.Value) *metaArgIteration

Types

type WalkExpressionsChild added in v0.51.0

type WalkExpressionsChild struct {
	BlockTypeName string
	Node          WalkExpressionsNode
}

type WalkExpressionsNode added in v0.51.0

type WalkExpressionsNode struct {
	// contains filtered or unexported fields
}

func WalkExpandExpressions added in v0.51.0

func WalkExpandExpressions(body hcl.Body) WalkExpressionsNode

WalkExpandExpressions is dynblock.WalkExpandVariables for expressions.

func (WalkExpressionsNode) Visit added in v0.51.0

func (n WalkExpressionsNode) Visit(schema *hcl.BodySchema) (exprs []hcl.Expression, children []WalkExpressionsChild)

Visit returns the expressions required for any "dynamic" blocks directly in the body associated with this node, and also returns any child nodes that must be visited in order to continue the walk.

Each child node has its associated block type name given in its BlockTypeName field, which the calling application should use to determine the appropriate schema for the content of each child node and pass it to the child node's own Visit method to continue the walk recursively.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL