Documentation ¶
Overview ¶
Package genfile implements generate_file code generation.
Index ¶
Constants ¶
const ( // ErrInvalidContentType indicates the content attribute // has an invalid type. ErrInvalidContentType errors.Kind = "invalid content type" // ErrInvalidConditionType indicates the condition attribute // has an invalid type. ErrInvalidConditionType errors.Kind = "invalid condition type" // ErrContentEval indicates an error when evaluating the content attribute. ErrContentEval errors.Kind = "evaluating content" // ErrConditionEval indicates an error when evaluating the condition attribute. ErrConditionEval errors.Kind = "evaluating condition" // ErrLabelConflict indicates the two generate_file blocks // have the same label. ErrLabelConflict errors.Kind = "label conflict detected" )
const ( // StackContext is the stack context name. StackContext = "stack" // RootContext is the root context name. RootContext = "root" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents generated file from a single generate_file block.
func Load ¶
func Load( root *config.Root, st *config.Stack, globals *eval.Object, vendorDir project.Path, vendorRequests chan<- event.VendorRequest, ) ([]File, error)
Load loads and parses from the file system all generate_file blocks for a given stack. It will navigate the file system from the stack dir until it reaches rootdir, loading generate_file blocks found on Terramate configuration files.
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_file blocks.
The rootdir MUST be an absolute path.
func (File) Asserts ¶
Asserts returns all (if any) of the evaluated assert configs of the generate_file block. If File.Condition returns false then assert configs will always be empty since they are not evaluated at all in that case.
func (File) Condition ¶
Condition returns the result of the evaluation of the condition attribute for the generated code.