Documentation
¶
Overview ¶
Package hcl provides parsing functionality for Terramate HCL configuration. It also provides printing and formatting for Terramate configuration.
Index ¶
- Constants
- func MatchAnyGlob(globs []glob.Glob, s string) bool
- func PrintConfig(w io.Writer, cfg Config) error
- func PrintImports(w io.Writer, imports []string) error
- func ValueAsStringList(val cty.Value) ([]string, error)
- type AssertBlockParser
- type AssertConfig
- type ChangeDetectionConfig
- type CloudConfig
- type Command
- type Commands
- type Config
- type Evaluator
- type GenFileBlock
- type GenHCLBlock
- type GenerateConfig
- type GenerateFileBlockParser
- type GenerateHCLBlockParser
- type GenerateRootConfig
- type GitChangeDetectionConfig
- type GitConfig
- type GlobalsBlockParser
- type Input
- type InputBlockParser
- type Inputs
- type ManifestConfig
- type ManifestDesc
- type MergedBlockHandler
- type MergedBlockHandlerConstructor
- type MergedLabelsBlockHandler
- type MergedLabelsBlockHandlerConstructor
- type Option
- func WithExperiments(experiments ...string) Option
- func WithMergedBlockHandlers(specs ...MergedBlockHandlerConstructor) Option
- func WithMergedLabelsBlockHandlers(specs ...MergedLabelsBlockHandlerConstructor) Option
- func WithStrictMode() Option
- func WithUniqueBlockHandlers(specs ...UniqueBlockHandlerConstructor) Option
- func WithUnmergedBlockHandlers(specs ...UnmergedBlockHandlerConstructor) Option
- type OptionalCheck
- type Output
- type OutputBlockParser
- type Outputs
- type RawConfig
- type RootConfig
- type RunConfig
- type RunEnv
- type Script
- type ScriptBlockParser
- type ScriptJob
- type SharingBackend
- type SharingBackendBlockParser
- type SharingBackendType
- type SharingBackends
- type Stack
- type StackBlockSpec
- type StackFilterConfig
- type TargetsConfig
- type TelemetryConfig
- type TerragruntChangeDetectionConfig
- type TerragruntChangeDetectionEnabledOption
- type Terramate
- type TerramateBlockParser
- type TerramateParser
- func (p *TerramateParser) AddDir(dir string) error
- func (p *TerramateParser) AddFile(path string) error
- func (p *TerramateParser) AddFileContent(name string, data []byte) error
- func (p *TerramateParser) Imports() (ast.Blocks, error)
- func (p *TerramateParser) IsRootConfig() (bool, error)
- func (p *TerramateParser) ParseConfig() (*Config, error)
- func (p *TerramateParser) ParseHCL() error
- func (p *TerramateParser) ParsedBodies() map[string]*hclsyntax.Body
- type UniqueBlockHandler
- type UniqueBlockHandlerConstructor
- type UnmergedBlockHandler
- type UnmergedBlockHandlerConstructor
- type VendorBlockParser
- type VendorConfig
Constants ¶
const ( ErrScriptNoLabels errors.Kind = "terramate schema error: (script): must provide at least one label" ErrScriptRedeclared errors.Kind = "terramate schema error: (script): multiple script blocks with same labels in the same directory" ErrScriptUnrecognizedAttr errors.Kind = "terramate schema error: (script): unrecognized attribute" ErrScriptJobUnrecognizedAttr errors.Kind = "terramate schema error: (script.job): unrecognized attribute" ErrScriptUnrecognizedBlock errors.Kind = "terramate schema error: (script): unrecognized block" ErrScriptNoCmds errors.Kind = "terramate schema error: (script): missing command or commands" ErrScriptMissingOrInvalidJob errors.Kind = "terramate schema error: (script): missing or invalid job" ErrScriptCmdConflict errors.Kind = "terramate schema error: (script): conflicting attribute already set" )
Errors returned during the HCL parsing of script block
const ( ErrHCLSyntax errors.Kind = "HCL syntax error" ErrTerramateSchema errors.Kind = "terramate schema error" ErrUnrecognizedBlock errors.Kind = "terramate schema error: unrecognized block" ErrImport errors.Kind = "import error" )
Errors returned during the HCL parsing.
const SharingIsCaringExperimentName = "outputs-sharing"
SharingIsCaringExperimentName is the name of the outputs-sharing experiment.
Variables ¶
This section is empty.
Functions ¶
func MatchAnyGlob ¶ added in v0.4.5
MatchAnyGlob is a helper function to test if s matches any of the given patterns.
func PrintConfig ¶
PrintConfig will print the given config as HCL on the given writer.
func PrintImports ¶
PrintImports will print the given imports list as import blocks.
Types ¶
type AssertBlockParser ¶ added in v0.13.1
type AssertBlockParser struct {
// contains filtered or unexported fields
}
AssertBlockParser is the parser for the "assert" block.
func NewCustomAssertBlockParser ¶ added in v0.13.1
func NewCustomAssertBlockParser(assertsStorage *[]AssertConfig) *AssertBlockParser
NewCustomAssertBlockParser returns a new parser specification for the scoped "assert" blocks.
func NewTopLevelAssertBlockParser ¶ added in v0.13.1
func NewTopLevelAssertBlockParser() *AssertBlockParser
NewTopLevelAssertBlockParser returns a new parser specification for the top-level "assert" block.
func (*AssertBlockParser) Name ¶ added in v0.13.1
func (*AssertBlockParser) Name() string
Name returns the type of the block.
func (*AssertBlockParser) Parse ¶ added in v0.13.1
func (a *AssertBlockParser) Parse(p *TerramateParser, block *ast.Block) error
Parse parses the "assert" block.
type AssertConfig ¶
type AssertConfig struct {
Range info.Range
Warning hcl.Expression
Assertion hcl.Expression
Message hcl.Expression
}
AssertConfig represents Terramate assert configuration block.
type ChangeDetectionConfig ¶ added in v0.6.5
type ChangeDetectionConfig struct {
Terragrunt *TerragruntChangeDetectionConfig
Git *GitChangeDetectionConfig
}
ChangeDetectionConfig is the `terramate.config.change_detection` config.
type CloudConfig ¶ added in v0.4.3
type CloudConfig struct {
// Organization is the name of the cloud organization
Organization string
Targets *TargetsConfig
Location cloud.Region
}
CloudConfig represents Terramate cloud configuration.
type Command ¶ added in v0.4.4
Command represents an executable command
func NewScriptCommand ¶ added in v0.4.4
NewScriptCommand returns a *Command encapsulating an ast.Attribute
type Commands ¶ added in v0.4.4
Commands represents a list of executable commands
func NewScriptCommands ¶ added in v0.4.4
NewScriptCommands returns *Commands encapsulating an ast.Attribute
type Config ¶
type Config struct {
Terramate *Terramate
Stack *Stack
Globals ast.MergedLabelBlocks
Vendor *VendorConfig
Asserts []AssertConfig
Generate GenerateConfig
Scripts []*Script
SharingBackends SharingBackends
Inputs Inputs
Outputs Outputs
Imported RawConfig
// External are parsed configuration from library clients.
External any
// contains filtered or unexported fields
}
Config represents a Terramate configuration.
func ParseDir ¶
ParseDir will parse Terramate configuration from a given directory, using root as project workspace, parsing all files with the suffixes .tm and .tm.hcl. It parses in non-strict mode for compatibility with older versions. Note: it does not recurse into child directories.
func (Config) Experiments ¶ added in v0.4.4
Experiments returns the config enabled experiments, if any.
func (Config) HasGlobals ¶
HasGlobals tells if the configuration has any globals defined.
func (Config) HasRunEnv ¶
HasRunEnv returns true if the config has a terramate.config.run.env block defined
func (Config) IsRootConfig ¶ added in v0.9.1
IsRootConfig tells if the Config is a root configuration.
type Evaluator ¶
type Evaluator interface {
// Eval evaluates the given expression returning a value.
Eval(hcl.Expression) (cty.Value, error)
// PartialEval partially evaluates the given expression returning the
// tokens that form the result of the partial evaluation. Any unknown
// namespace access are ignored and left as is, while known namespaces
// are substituted by its value.
// If any unknowns are found, the method returns hasUnknowns as true.
PartialEval(hcl.Expression) (expr hcl.Expression, hasUnknowns bool, err error)
// SetNamespace adds a new namespace, replacing any with the same name.
SetNamespace(name string, values map[string]cty.Value)
// DeleteNamespace deletes a namespace.
DeleteNamespace(name string)
}
Evaluator represents a Terramate evaluator
type GenFileBlock ¶
type GenFileBlock struct {
// Dir where the block is declared.
Dir project.Path
// Range is the range of the entire block definition.
Range info.Range
// Label of the block
Label string
// Lets is a block of local variables.
Lets *ast.MergedBlock
// Condition attribute of the block, if any.
Condition *hclsyntax.Attribute
// Represents all stack_filter blocks
StackFilters []StackFilterConfig
// Content attribute of the block
Content *hclsyntax.Attribute
// Context of the generation (stack by default).
Context string
// Asserts represents all assert blocks
Asserts []AssertConfig
// Inherit tells if the block is inherited in child directories.
Inherit *hclsyntax.Attribute
}
GenFileBlock represents a parsed generate_file block
type GenHCLBlock ¶
type GenHCLBlock struct {
// Dir where the block is declared.
Dir project.Path
// Range is the range of the entire block definition.
Range info.Range
// Label of the block.
Label string
// Lets is a block of local variables.
Lets *ast.MergedBlock
// Condition attribute of the block, if any.
Condition *hclsyntax.Attribute
// Represents all stack_filter blocks
StackFilters []StackFilterConfig
// Content block.
Content *hcl.Block
// Asserts represents all assert blocks
Asserts []AssertConfig
// Inherit tells if the block is inherited in child directories.
Inherit *hclsyntax.Attribute
// IsImplicitBlock tells if the block is implicit (does not have a real generate_hcl block).
// This is the case for the "tmgen" feature.
IsImplicitBlock bool
}
GenHCLBlock represents a parsed generate_hcl block.
type GenerateConfig ¶
type GenerateConfig struct {
Files []GenFileBlock
HCLs []GenHCLBlock
}
GenerateConfig includes code generation related configurations, like generate_file and generate_hcl.
type GenerateFileBlockParser ¶ added in v0.13.1
type GenerateFileBlockParser struct{}
GenerateFileBlockParser is the parser for the "generate_file" block.
func NewGenerateFileBlockParser ¶ added in v0.13.1
func NewGenerateFileBlockParser() *GenerateFileBlockParser
NewGenerateFileBlockParser returns a new parser specification for the "generate_file" block.
func (*GenerateFileBlockParser) Name ¶ added in v0.13.1
func (*GenerateFileBlockParser) Name() string
Name returns the type of the block.
func (*GenerateFileBlockParser) Parse ¶ added in v0.13.1
func (*GenerateFileBlockParser) Parse(p *TerramateParser, block *ast.Block) error
Parse parses the "generate_file" block.
type GenerateHCLBlockParser ¶ added in v0.13.1
type GenerateHCLBlockParser struct{}
GenerateHCLBlockParser is the parser for the "generate_hcl" block.
func (*GenerateHCLBlockParser) Name ¶ added in v0.13.1
func (*GenerateHCLBlockParser) Name() string
Name returns the type of the block.
func (*GenerateHCLBlockParser) Parse ¶ added in v0.13.1
func (*GenerateHCLBlockParser) Parse(p *TerramateParser, block *ast.Block) error
Parse parses the "generate_hcl" block.
type GenerateRootConfig ¶ added in v0.5.0
type GenerateRootConfig struct {
HCLMagicHeaderCommentStyle *string
}
GenerateRootConfig represents the AST node for the `terramate.config.generate` block.
type GitChangeDetectionConfig ¶ added in v0.11.0
GitChangeDetectionConfig is the `terramate.config.change_detection.git` config.
type GitConfig ¶
type GitConfig struct {
// DefaultBranch is the default branch.
DefaultBranch string
// DefaultRemote is the default remote.
DefaultRemote string
// CheckUntracked enables untracked files checking.
CheckUntracked bool
// CheckUncommitted enables uncommitted files checking.
CheckUncommitted bool
// CheckRemote enables checking if local default branch is updated with remote.
CheckRemote OptionalCheck
}
GitConfig represents Terramate Git configuration.
func NewGitConfig ¶
func NewGitConfig() *GitConfig
NewGitConfig creates a git configuration with proper default values.
type GlobalsBlockParser ¶ added in v0.13.1
type GlobalsBlockParser struct{}
GlobalsBlockParser is the parser for the globals block.
func NewGlobalsBlockParser ¶ added in v0.13.1
func NewGlobalsBlockParser() *GlobalsBlockParser
NewGlobalsBlockParser creates a new globals block parser.
func (*GlobalsBlockParser) Name ¶ added in v0.13.1
func (g *GlobalsBlockParser) Name() string
Name returns the name of the block.
func (*GlobalsBlockParser) Parse ¶ added in v0.13.1
func (g *GlobalsBlockParser) Parse(p *TerramateParser, label ast.LabelBlockType, block *ast.MergedBlock) error
Parse parses the globals block.
func (*GlobalsBlockParser) Validate ¶ added in v0.14.6
func (*GlobalsBlockParser) Validate(*TerramateParser) error
Validate postconditions after parsing.
type Input ¶ added in v0.10.1
type Input struct {
info.Range
Name string
Backend hcl.Expression
FromStackID hcl.Expression
Value hcl.Expression
Sensitive hcl.Expression
Mock hcl.Expression
}
Input holds the parsed values for the `input` block.
type InputBlockParser ¶ added in v0.13.1
type InputBlockParser struct{}
InputBlockParser is the parser for the "input" block.
func NewInputBlockParser ¶ added in v0.13.1
func NewInputBlockParser() *InputBlockParser
NewInputBlockParser returns a new parser specification for the "input" block.
func (*InputBlockParser) Name ¶ added in v0.13.1
func (i *InputBlockParser) Name() string
Name returns the type of the block.
func (*InputBlockParser) Parse ¶ added in v0.13.1
func (i *InputBlockParser) Parse(p *TerramateParser, block *ast.Block) error
Parse parses the "input" block.
type ManifestConfig ¶
type ManifestConfig struct {
Default *ManifestDesc
}
ManifestConfig represents the manifest config block of a Terramate configuration.
type ManifestDesc ¶
type ManifestDesc struct {
// Files is a list of patterns that specify which files the manifest wants to include.
Files []string
// Excludes is a list of patterns that specify which files the manifest wants to exclude.
Excludes []string
}
ManifestDesc represents a parsed manifest description.
type MergedBlockHandler ¶ added in v0.13.1
type MergedBlockHandler interface {
// Name is the block name (e.g. "terramate").
Name() string
// Parse parses the block.
Parse(*TerramateParser, *ast.MergedBlock) error
// Validate postconditions after parsing.
Validate(*TerramateParser) error
}
MergedBlockHandler specifies how a merged block should be parsed.
type MergedBlockHandlerConstructor ¶ added in v0.13.1
type MergedBlockHandlerConstructor func() MergedBlockHandler
MergedBlockHandlerConstructor is a constructor for a merged block handler.
func DefaultMergedBlockHandlers ¶ added in v0.13.1
func DefaultMergedBlockHandlers() []MergedBlockHandlerConstructor
DefaultMergedBlockHandlers returns the default merged block specifications for the parser.
type MergedLabelsBlockHandler ¶ added in v0.13.1
type MergedLabelsBlockHandler interface {
// Name is the block name (e.g. "globals").
Name() string
// Parse parses the block.
Parse(*TerramateParser, ast.LabelBlockType, *ast.MergedBlock) error
// Validate postconditions after parsing.
Validate(*TerramateParser) error
}
MergedLabelsBlockHandler specifies how a merged block with labels should be parsed.
type MergedLabelsBlockHandlerConstructor ¶ added in v0.13.1
type MergedLabelsBlockHandlerConstructor func() MergedLabelsBlockHandler
MergedLabelsBlockHandlerConstructor is a constructor for a merged labels block handler.
func DefaultMergedLabelsBlockHandlers ¶ added in v0.13.1
func DefaultMergedLabelsBlockHandlers() []MergedLabelsBlockHandlerConstructor
DefaultMergedLabelsBlockHandlers returns the default merged block specifications for the parser.
type Option ¶ added in v0.13.1
type Option func(*TerramateParser)
Option is a function that can be used to configure a TerramateParser.
func WithExperiments ¶ added in v0.13.1
WithExperiments is an option to set the experiments to be enabled in the parser.
func WithMergedBlockHandlers ¶ added in v0.13.1
func WithMergedBlockHandlers(specs ...MergedBlockHandlerConstructor) Option
WithMergedBlockHandlers is an option to set the merged block specifications for the parser.
func WithMergedLabelsBlockHandlers ¶ added in v0.13.1
func WithMergedLabelsBlockHandlers(specs ...MergedLabelsBlockHandlerConstructor) Option
WithMergedLabelsBlockHandlers is an option to set the merged labels block specifications for the parser.
func WithStrictMode ¶ added in v0.13.1
func WithStrictMode() Option
WithStrictMode is an option to enable strict mode in the parser.
func WithUniqueBlockHandlers ¶ added in v0.13.1
func WithUniqueBlockHandlers(specs ...UniqueBlockHandlerConstructor) Option
WithUniqueBlockHandlers is an option to set the unique block specifications for the parser.
func WithUnmergedBlockHandlers ¶ added in v0.13.1
func WithUnmergedBlockHandlers(specs ...UnmergedBlockHandlerConstructor) Option
WithUnmergedBlockHandlers is an option to set the unmerged block specifications for the parser.
type OptionalCheck ¶ added in v0.4.4
type OptionalCheck int
OptionalCheck is a bool that can also have no configured value.
const ( // CheckIsUnset means no value was specified. CheckIsUnset OptionalCheck = iota // CheckIsFalse means the check is disabled. CheckIsFalse // CheckIsTrue means the check is enabled. CheckIsTrue )
func ToOptionalCheck ¶ added in v0.4.4
func ToOptionalCheck(v bool) OptionalCheck
ToOptionalCheck creates an OptionalCheck value from a bool.
func (OptionalCheck) ValueOr ¶ added in v0.4.4
func (v OptionalCheck) ValueOr(def bool) bool
ValueOr returns if an OptionalCheck is enabled, or the given default if its unset.
type Output ¶ added in v0.10.1
type Output struct {
info.Range
Name string
Backend hcl.Expression
Description hcl.Expression
Value hcl.Expression
Sensitive hcl.Expression
}
Output holds the parsed value for the `output` block.
type OutputBlockParser ¶ added in v0.13.1
type OutputBlockParser struct{}
OutputBlockParser is the specification for the output block.
func NewOutputBlockParser ¶ added in v0.13.1
func NewOutputBlockParser() *OutputBlockParser
NewOutputBlockParser returns a new parser specification for the "output" block.
func (*OutputBlockParser) Name ¶ added in v0.13.1
func (*OutputBlockParser) Name() string
Name returns the type of the block.
func (*OutputBlockParser) Parse ¶ added in v0.13.1
func (*OutputBlockParser) Parse(p *TerramateParser, block *ast.Block) error
Parse parses the "output" block.
type RawConfig ¶
type RawConfig struct {
// MergedAttributes are the top-level attributes of all files.
// This will be available after calling Parse or ParseConfig
MergedAttributes ast.Attributes
// MergedBlocks are the merged blocks from all files.
// This will be available after calling Parse or ParseConfig
MergedBlocks ast.MergedBlocks
// MergedLabelBlocks are the labelled merged blocks.
// This will be available after calling Parse or ParseConfig
MergedLabelBlocks ast.MergedLabelBlocks
// UnmergedBlocks are the unmerged blocks from all files.
// This will be available after calling Parse or ParseConfig
UnmergedBlocks ast.Blocks
// UniqueBlocks are blocks that can only appear once in the config.
UniqueBlocks map[string]*ast.Block
// contains filtered or unexported fields
}
RawConfig is the configuration (attributes and blocks) without schema validations.
func NewCustomRawConfig ¶
NewCustomRawConfig returns a new customized RawConfig.
func NewTopLevelRawConfig ¶
func NewTopLevelRawConfig() RawConfig
NewTopLevelRawConfig returns a new RawConfig object tailored for the Terramate top-level attributes and blocks.
type RootConfig ¶
type RootConfig struct {
Git *GitConfig
Generate *GenerateRootConfig
ChangeDetection *ChangeDetectionConfig
Run *RunConfig
Cloud *CloudConfig
Experiments []string
DisableSafeguards safeguard.Keywords
Telemetry *TelemetryConfig
}
RootConfig represents the root config block of a Terramate configuration.
func (*RootConfig) HasSafeguardDisabled ¶ added in v0.4.5
func (r *RootConfig) HasSafeguardDisabled(keyword safeguard.Keyword) bool
HasSafeguardDisabled checks if the configuration (including the deprecated) has the given keyword disabled.
type RunConfig ¶
type RunConfig struct {
// CheckGenCode enables generated code is up-to-date check on run.
CheckGenCode bool
// Env contains environment definitions for run.
Env *RunEnv
}
RunConfig represents Terramate run configuration.
func NewRunConfig ¶ added in v0.4.5
func NewRunConfig() *RunConfig
NewRunConfig creates a new run configuration.
type RunEnv ¶
type RunEnv struct {
// Attributes is the collection of attribute definitions within the env block.
Attributes ast.Attributes
}
RunEnv represents Terramate run environment.
type Script ¶ added in v0.4.4
type Script struct {
Range info.Range
Labels []string // Labels of the script block used for grouping scripts
Name *ast.Attribute // Name of the script
Description *ast.Attribute // Description is a human readable description of a script
Jobs []*ScriptJob // Job represents the command(s) part of this script
Lets *ast.MergedBlock // Lets are script local variables.
}
Script represents a parsed script block
func (*Script) AccessorName ¶ added in v0.5.0
AccessorName returns the name traversal for accessing the script.
type ScriptBlockParser ¶ added in v0.13.1
type ScriptBlockParser struct{}
ScriptBlockParser is a parser for the "script" block
func NewScriptBlockParser ¶ added in v0.13.1
func NewScriptBlockParser() *ScriptBlockParser
NewScriptBlockParser returns a new parser specification for the "script" block.
func (*ScriptBlockParser) Name ¶ added in v0.13.1
func (*ScriptBlockParser) Name() string
Name returns the type of the block.
func (*ScriptBlockParser) Parse ¶ added in v0.13.1
func (*ScriptBlockParser) Parse(p *TerramateParser, block *ast.Block) error
Parse parses the "script" block.
type ScriptJob ¶ added in v0.4.4
type ScriptJob struct {
Name *ast.Attribute
Description *ast.Attribute
Command *Command // Command is a single executable command
Commands *Commands // Commands is a list of executable commands
}
ScriptJob represent a Job within a Script
type SharingBackend ¶ added in v0.10.1
type SharingBackend struct {
Name string
Type SharingBackendType
Command []string
Filename string
}
SharingBackend holds the parsed values for the `sharing_backend` block.
type SharingBackendBlockParser ¶ added in v0.13.1
type SharingBackendBlockParser struct{}
SharingBackendBlockParser is the parser for the "sharing_backend" block.
func NewSharingBackendBlockParser ¶ added in v0.13.1
func NewSharingBackendBlockParser() *SharingBackendBlockParser
NewSharingBackendBlockParser returns a new parser specification for the "sharing_backend" block.
func (*SharingBackendBlockParser) Name ¶ added in v0.13.1
func (*SharingBackendBlockParser) Name() string
Name returns the type of the block.
func (*SharingBackendBlockParser) Parse ¶ added in v0.13.1
func (*SharingBackendBlockParser) Parse(p *TerramateParser, block *ast.Block) error
Parse parses the "outputs_sharing" block.
type SharingBackendType ¶ added in v0.10.1
type SharingBackendType int
SharingBackendType is the type of the sharing backend.
const (
TerraformSharingBackend SharingBackendType = iota + 1
)
These are the valid sharing_backend types.
func (SharingBackendType) String ¶ added in v0.10.1
func (st SharingBackendType) String() string
type SharingBackends ¶ added in v0.10.1
type SharingBackends []SharingBackend
SharingBackends is a list of SharingBackend blocks.
type Stack ¶
type Stack struct {
// ID of the stack. If the ID is empty it indicates this stack has no ID.
ID string
// Name of the stack
Name string
// Description of the stack
Description string
// Tags is a list of non-duplicated list of tags
Tags []string
// After is a list of non-duplicated stack entries that must run before the
// current stack runs.
After []string
// Before is a list of non-duplicated stack entries that must run after the
// current stack runs.
Before []string
// Wants is a list of non-duplicated stack entries that must be selected
// whenever the current stack is selected.
Wants []string
// WantedBy is a list of non-duplicated stack entries that must select
// this stack whenever they are selected.
WantedBy []string
// Watch is a list of files to be watched for changes.
Watch []string
}
Stack is the parsed "stack" HCL block.
type StackBlockSpec ¶ added in v0.13.1
type StackBlockSpec struct {
}
StackBlockSpec is the specification for the stack block.
func NewStackBlockParser ¶ added in v0.13.1
func NewStackBlockParser() *StackBlockSpec
NewStackBlockParser returns a new parser specification for the "stack" block.
func (*StackBlockSpec) Name ¶ added in v0.13.1
func (*StackBlockSpec) Name() string
Name returns the name of the block.
func (*StackBlockSpec) Parse ¶ added in v0.13.1
func (*StackBlockSpec) Parse(p *TerramateParser, block *ast.Block) error
Parse parses the "stack" block.
type StackFilterConfig ¶ added in v0.4.4
StackFilterConfig represents Terramate stack_filter configuration block.
type TargetsConfig ¶ added in v0.9.0
type TargetsConfig struct {
Enabled bool
}
TargetsConfig represents Terramate targets configuration.
type TelemetryConfig ¶ added in v0.11.4
type TelemetryConfig struct {
Enabled *bool
}
TelemetryConfig represents Terramate telemetry configuration.
type TerragruntChangeDetectionConfig ¶ added in v0.11.0
type TerragruntChangeDetectionConfig struct {
Enabled TerragruntChangeDetectionEnabledOption
}
TerragruntChangeDetectionConfig is the `terramate.config.change_detection.terragrunt` config.
type TerragruntChangeDetectionEnabledOption ¶ added in v0.6.5
type TerragruntChangeDetectionEnabledOption int
TerragruntChangeDetectionEnabledOption is the change detection options for enabling Terragrunt.
const ( TerragruntAutoOption TerragruntChangeDetectionEnabledOption = iota TerragruntOffOption TerragruntForceOption )
Terragrunt Enabling options.
type Terramate ¶
type Terramate struct {
// RequiredVersion contains the terramate version required by the stack.
RequiredVersion string
// RequiredVersionAllowPreReleases allows pre-release to be matched if true.
RequiredVersionAllowPreReleases bool
// Config is the parsed config blocks.
Config *RootConfig
}
Terramate is the parsed "terramate" HCL block.
type TerramateBlockParser ¶ added in v0.13.1
type TerramateBlockParser struct{}
TerramateBlockParser is the parser for the "terramate" block.
func NewTerramateBlockParser ¶ added in v0.13.1
func NewTerramateBlockParser() *TerramateBlockParser
NewTerramateBlockParser returns a new parser specification for the "terramate" block.
func (*TerramateBlockParser) Name ¶ added in v0.13.1
func (*TerramateBlockParser) Name() string
Name returns the type of the block.
func (*TerramateBlockParser) Parse ¶ added in v0.13.1
func (*TerramateBlockParser) Parse(p *TerramateParser, block *ast.MergedBlock) error
Parse parses the "terramate" block.
func (*TerramateBlockParser) Validate ¶ added in v0.14.6
func (*TerramateBlockParser) Validate(*TerramateParser) error
Validate postconditions after parsing.
type TerramateParser ¶
type TerramateParser struct {
Config RawConfig
Imported RawConfig
ParsedConfig Config
// contains filtered or unexported fields
}
TerramateParser is an HCL parser tailored for Terramate configuration schema. As the Terramate configuration can span multiple files in the same directory, this API allows you to define the exact set of files (and contents) that are going to be included in the final configuration.
func NewTerramateParser ¶
func NewTerramateParser(rootdir string, dir string, opts ...Option) (*TerramateParser, error)
NewTerramateParser creates a Terramate parser for the directory dir inside the root directory. The parser creates sub-parsers for parsing imports but keeps a list of all parsed files of all sub-parsers for detecting cycles and import duplications. The subparsers inherits this parser options.
func (*TerramateParser) AddDir ¶
func (p *TerramateParser) AddDir(dir string) error
AddDir walks over all the files in the directory dir and add all .tm and .tm.hcl files to the parser.
func (*TerramateParser) AddFile ¶
func (p *TerramateParser) AddFile(path string) error
AddFile adds a file path to be parsed.
func (*TerramateParser) AddFileContent ¶
func (p *TerramateParser) AddFileContent(name string, data []byte) error
AddFileContent adds a file to the set of files to be parsed.
func (*TerramateParser) Imports ¶
func (p *TerramateParser) Imports() (ast.Blocks, error)
Imports returns all import blocks.
func (*TerramateParser) IsRootConfig ¶ added in v0.13.1
func (p *TerramateParser) IsRootConfig() (bool, error)
IsRootConfig parses rootdir and tells if it contains a root config or not. Note: after identifying this is the config you need, then call ParseConfig() to retrieve the full config.
func (*TerramateParser) ParseConfig ¶
func (p *TerramateParser) ParseConfig() (*Config, error)
ParseConfig parses and checks the schema of previously added files and return either a Config or an error.
func (*TerramateParser) ParseHCL ¶ added in v0.13.1
func (p *TerramateParser) ParseHCL() error
ParseHCL does the syntax parsing, applying imports and merging of configurations but do not validate if the HCL schema is a valid Terramate configuration.
func (*TerramateParser) ParsedBodies ¶
func (p *TerramateParser) ParsedBodies() map[string]*hclsyntax.Body
ParsedBodies returns a map of filename to the parsed hclsyntax.Body.
type UniqueBlockHandler ¶ added in v0.13.1
type UniqueBlockHandler interface {
// Name is the block name (e.g. "vendor").
Name() string
// Parse parses the block.
Parse(*TerramateParser, *ast.Block) error
}
UniqueBlockHandler specifies how a unique block should be parsed.
type UniqueBlockHandlerConstructor ¶ added in v0.13.1
type UniqueBlockHandlerConstructor func() UniqueBlockHandler
UniqueBlockHandlerConstructor is a constructor for a unique block handler.
func DefaultUniqueBlockHandlers ¶ added in v0.13.1
func DefaultUniqueBlockHandlers() []UniqueBlockHandlerConstructor
DefaultUniqueBlockHandlers returns the default unique block specifications for the parser.
type UnmergedBlockHandler ¶ added in v0.13.1
type UnmergedBlockHandler interface {
// Name is the block name (e.g. "stack").
Name() string
// Parse parses the block.
Parse(*TerramateParser, *ast.Block) error
}
UnmergedBlockHandler specifies how the block should be parsed.
func NewGenerateHCLBlockParser ¶ added in v0.13.1
func NewGenerateHCLBlockParser() UnmergedBlockHandler
NewGenerateHCLBlockParser returns a new parser specification for the "generate_hcl" block.
type UnmergedBlockHandlerConstructor ¶ added in v0.13.1
type UnmergedBlockHandlerConstructor func() UnmergedBlockHandler
UnmergedBlockHandlerConstructor is a constructor for an unmerged block handler.
func DefaultUnmergedBlockParsers ¶ added in v0.13.1
func DefaultUnmergedBlockParsers() []UnmergedBlockHandlerConstructor
DefaultUnmergedBlockParsers returns the default unmerged block specifications for the parser.
type VendorBlockParser ¶ added in v0.13.1
type VendorBlockParser struct{}
VendorBlockParser is the parser for the "vendor" block.
func NewVendorBlockParser ¶ added in v0.13.1
func NewVendorBlockParser() *VendorBlockParser
NewVendorBlockParser returns a new parser specification for the "vendor" block.
func (*VendorBlockParser) Name ¶ added in v0.13.1
func (*VendorBlockParser) Name() string
Name returns the type of the block.
func (*VendorBlockParser) Parse ¶ added in v0.13.1
func (*VendorBlockParser) Parse(p *TerramateParser, block *ast.Block) (err error)
Parse parses the "vendor" block.
type VendorConfig ¶
type VendorConfig struct {
// Manifest is the parsed manifest block, if any.
Manifest *ManifestConfig
// Dir is the path where vendored projects will be stored.
Dir string
}
VendorConfig is the parsed "vendor" HCL block.
Source Files
¶
- block_assert_parser.go
- block_generate_file_parser.go
- block_generate_hcl_parser.go
- block_globals_parser.go
- block_input_parser.go
- block_output_parser.go
- block_script_parser.go
- block_sharing_backend_parser.go
- block_stack_parser.go
- block_terramate_parser.go
- block_vendor_parser.go
- default_merged_labels_parser_handlers.go
- default_merged_parser_handlers.go
- default_unique_parser_handlers.go
- default_unmerged_parser_handlers.go
- doc.go
- hcl.go
- hcl_options.go
- printer.go
- raw_config.go
- sharing_backend.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ast provides low level parsing facilities for HCL configuration.
|
Package ast provides low level parsing facilities for HCL configuration. |
|
Package eval provides both full and partial evaluation of HCL.
|
Package eval provides both full and partial evaluation of HCL. |
|
Package fmt contains functions for formatting hcl config.
|
Package fmt contains functions for formatting hcl config. |
|
Package info provides informational types related to hcl.
|
Package info provides informational types related to hcl. |