Documentation ¶
Overview ¶
Package genhcl implements generate_hcl code generation.
Index ¶
Constants ¶
const ( // Header is the current header string used by generate_hcl code generation. Header = "// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT" // HeaderV0 is the deprecated header string used by generate_hcl code generation. HeaderV0 = "// GENERATED BY TERRAMATE: DO NOT EDIT" )
const ( // ErrParsing indicates the failure of parsing the generate_hcl block. ErrParsing errors.Kind = "parsing generate_hcl block" // ErrContentEval indicates the failure to evaluate the content block. ErrContentEval errors.Kind = "evaluating content block" // ErrConditionEval indicates the failure to evaluate the condition attribute. ErrConditionEval errors.Kind = "evaluating condition attribute" // ErrInvalidConditionType indicates the condition attribute // has an invalid type. ErrInvalidConditionType errors.Kind = "invalid condition type" // ErrInvalidDynamicIterator indicates that the iterator of a tm_dynamic block // is invalid. ErrInvalidDynamicIterator errors.Kind = "invalid tm_dynamic.iterator" // ErrInvalidDynamicLabels indicates that the labels of a tm_dynamic block is invalid. ErrInvalidDynamicLabels errors.Kind = "invalid tm_dynamic.labels" // ErrDynamicAttrsEval indicates that the attributes of a tm_dynamic cant be evaluated. ErrDynamicAttrsEval errors.Kind = "evaluating tm_dynamic.attributes" // ErrDynamicConditionEval indicates that the condition of a tm_dynamic cant be evaluated. ErrDynamicConditionEval errors.Kind = "evaluating tm_dynamic.condition" // ErrDynamicAttrsConflict indicates fields of tm_dynamic conflicts. ErrDynamicAttrsConflict errors.Kind = "tm_dynamic.attributes and tm_dynamic.content have conflicting fields" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HCL ¶
type HCL struct {
// contains filtered or unexported fields
}
HCL represents generated HCL code from a single block. Is contains parsed and evaluated code on it and information about the origin of the generated code.
func Load ¶
func Load( root *config.Root, st *config.Stack, globals *eval.Object, vendorDir project.Path, vendorRequests chan<- event.VendorRequest, ) ([]HCL, error)
Load loads from the file system all generate_hcl for a given stack. It will navigate the file system from the stack dir until it reaches rootdir, loading generate_hcl and merging them appropriately.
All generate_file blocks must have unique labels, even ones at different directories. Any conflicts will be reported as an error.
Metadata and globals for the stack are used on the evaluation of the generate_hcl blocks.
The rootdir MUST be an absolute path.
func (HCL) Asserts ¶
Asserts returns all (if any) of the evaluated assert configs of the generate_hcl block. If HCL.Condition returns false then assert configs will always be empty since they are not evaluated at all in that case.
func (HCL) Body ¶
Body returns a string representation of the HCL code or an empty string if the config itself is empty.