Documentation ¶
Overview ¶
Implements the `Data` interface. Doesn't really do anything.
Look in `/pkg/hcl_interpreter/README.md` for an explanation of how this works.
This module contains utilities for parsing and traversing everything in a configuration tree.
Look in `/pkg/hcl_interpreter/README.md` for an explanation of how this works.
This module contains utilities for parsing and traversing everything in a configuration tree.
cty.Value utilities
Index ¶
- Variables
- func LocalNameToString(name LocalName) string
- func LookupVal(tree cty.Value, name LocalName) cty.Value
- func MergeVal(left cty.Value, right cty.Value) cty.Value
- func ModuleNameToKey(moduleName ModuleName) string
- func ModuleNameToString(moduleName ModuleName) string
- func NestVal(prefix []string, val cty.Value) cty.Value
- func TfFilePathJoin(leading, trailing string) string
- func TraversalToString(traversal hcl.Traversal) string
- func ValToVariables(tree cty.Value) map[string]cty.Value
- func ValueToInt(val cty.Value) *int
- func ValueToInterface(val cty.Value) (interface{}, []error)
- func ValueToString(val cty.Value) *string
- type Analysis
- type Data
- func (c *Data) GetCountAttr(addrs.CountAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
- func (c *Data) GetForEachAttr(addrs.ForEachAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
- func (c *Data) GetInputVariable(v addrs.InputVariable, s tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
- func (c *Data) GetLocalValue(addrs.LocalValue, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
- func (c *Data) GetModule(addrs.ModuleCall, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
- func (c *Data) GetPathAttr(attr addrs.PathAttr, diags tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
- func (c *Data) GetResource(addrs.Resource, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
- func (c *Data) GetTerraformAttr(addrs.TerraformAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
- func (c *Data) StaticValidateReferences(refs []*addrs.Reference, self addrs.Referenceable) tfdiags.Diagnostics
- type Evaluation
- type EvaluationError
- type FullName
- func (name FullName) Add(p string) FullName
- func (name FullName) AsModuleInput() *FullName
- func (name FullName) AsModuleOutput() *FullName
- func (name FullName) AsResourceName() (*FullName, LocalName)
- func (name FullName) AsVariable() (*FullName, *FullName, LocalName)
- func (name FullName) ToString() string
- type LocalName
- type MissingRemoteSubmodulesError
- type MissingTermError
- type ModuleMeta
- type ModuleName
- type ModuleTree
- type Resource
- type ResourceMeta
- type SubmoduleLoadingError
- type Term
- type TermDependency
- type TermTree
- type TerraformModuleRegister
- type UnsupportedOperationDiag
- func (d UnsupportedOperationDiag) Description() tfdiags.Description
- func (d UnsupportedOperationDiag) ExtraInfo() interface{}
- func (d UnsupportedOperationDiag) FromExpr() *tfdiags.FromExpr
- func (d UnsupportedOperationDiag) Severity() tfdiags.Severity
- func (d UnsupportedOperationDiag) Source() tfdiags.Source
- type Visitor
Constants ¶
This section is empty.
Variables ¶
var ( // Supported fixed paths can be checked using Equals. PathModuleName = LocalName{"path", "module"} PathRootName = LocalName{"path", "root"} PathCwdName = LocalName{"path", "cwd"} TerraformWorkspaceName = LocalName{"terraform", "workspace"} )
var EmptyModuleName = []string{}
Functions ¶
func LocalNameToString ¶
func ModuleNameToKey ¶ added in v0.30.0
func ModuleNameToKey(moduleName ModuleName) string
ModuleNameToKey produces the internal key used in some parts of terraform for modules. While the user-exposed name (as returned by ModuleNameToString) would be something like:
module.foo.module.lambda
The internal key will be:
foo.lambda
func ModuleNameToString ¶
func ModuleNameToString(moduleName ModuleName) string
func TfFilePathJoin ¶
TfFilePathJoin is like `filepath.Join` but avoids cleaning the path. This allows to get unique paths for submodules including a parent module, e.g.:
. examples/mssql/../../ examples/complete/../../
func TraversalToString ¶
func TraversalToString(traversal hcl.Traversal) string
func ValToVariables ¶ added in v0.15.0
Some HCL functions require it to be a map. Returns an empty map if we have anything but an object at the root.
func ValueToInt ¶
func ValueToInterface ¶
func ValueToString ¶
Types ¶
type Analysis ¶
type Analysis struct { Fs afero.Fs // Module metadata Modules map[string]*ModuleMeta // Resource metadata Resources map[string]*ResourceMeta // Terms in the evaluation tree. Terms *TermTree // contains filtered or unexported fields }
func AnalyzeModuleTree ¶
func AnalyzeModuleTree(mtree *ModuleTree) *Analysis
func (*Analysis) VisitModule ¶
func (v *Analysis) VisitModule(meta *ModuleMeta)
func (*Analysis) VisitResource ¶ added in v0.15.0
func (v *Analysis) VisitResource(name FullName, resource *ResourceMeta)
type Data ¶
type Data struct { }
func (*Data) GetCountAttr ¶
func (c *Data) GetCountAttr(addrs.CountAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
func (*Data) GetForEachAttr ¶
func (c *Data) GetForEachAttr(addrs.ForEachAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
func (*Data) GetInputVariable ¶
func (c *Data) GetInputVariable(v addrs.InputVariable, s tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
func (*Data) GetLocalValue ¶
func (c *Data) GetLocalValue(addrs.LocalValue, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
func (*Data) GetModule ¶
func (c *Data) GetModule(addrs.ModuleCall, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
func (*Data) GetPathAttr ¶
func (c *Data) GetPathAttr(attr addrs.PathAttr, diags tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
func (*Data) GetResource ¶
func (c *Data) GetResource(addrs.Resource, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
func (*Data) GetTerraformAttr ¶
func (c *Data) GetTerraformAttr(addrs.TerraformAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
func (*Data) StaticValidateReferences ¶
func (c *Data) StaticValidateReferences(refs []*addrs.Reference, self addrs.Referenceable) tfdiags.Diagnostics
type Evaluation ¶
type Evaluation struct { Analysis *Analysis Modules map[string]cty.Value // contains filtered or unexported fields }
func EvaluateAnalysis ¶
func EvaluateAnalysis(analysis *Analysis) (*Evaluation, error)
func (*Evaluation) Errors ¶
func (e *Evaluation) Errors() []error
Errors returns the non-fatal errors encountered during evaluation
func (*Evaluation) Location ¶
func (v *Evaluation) Location( resourceId string, path []interface{}, ) []hcl.Range
func (*Evaluation) Resources ¶
func (v *Evaluation) Resources() []Resource
type EvaluationError ¶ added in v0.22.0
type EvaluationError struct {
Diags hcl.Diagnostics
}
func (EvaluationError) Error ¶ added in v0.22.0
func (err EvaluationError) Error() string
type FullName ¶
type FullName struct { Module ModuleName Local LocalName }
func ArrayToFullName ¶
func EmptyFullName ¶
func EmptyFullName(module ModuleName) FullName
func ProviderConfigName ¶
func ProviderConfigName(module ModuleName, providerName string) FullName
func StringToFullName ¶
func (FullName) AsModuleInput ¶
Parses "module.child.var.foo" into "input.child.foo"
func (FullName) AsModuleOutput ¶
Parses the use of an output (e.g. "module.child.x") to the fully expanded output name (e.g. module.child.output.x")
func (FullName) AsResourceName ¶
func (FullName) AsVariable ¶
Parses "var.my_var.key" into "variable.my_var", "var.my_var" and "key".
type LocalName ¶
type LocalName []string
func TraversalToLocalName ¶
TraversalToLocalName returns the leading LocalName (strictly-string) part of a traversal as well as the trailing part (string-or-int).
func (LocalName) ToAccessor ¶ added in v0.30.5
func (name LocalName) ToAccessor() accessor
type MissingRemoteSubmodulesError ¶ added in v0.22.0
func (MissingRemoteSubmodulesError) Error ¶ added in v0.22.0
func (err MissingRemoteSubmodulesError) Error() string
type MissingTermError ¶ added in v0.22.0
type MissingTermError struct { Range *hcl.Range Term string }
func (MissingTermError) Error ¶ added in v0.22.0
func (err MissingTermError) Error() string
type ModuleMeta ¶
type ModuleMeta struct { Dir string Name ModuleName Recurse bool Filepaths []string MissingRemoteModules []string Location *hcl.Range }
type ModuleName ¶
type ModuleName = []string
func ChildModuleName ¶ added in v0.30.0
func ChildModuleName(moduleName ModuleName, childName string) ModuleName
type ModuleTree ¶
type ModuleTree struct {
// contains filtered or unexported fields
}
We load the entire tree of submodules in one pass.
func ParseDirectory ¶
func ParseDirectory( moduleRegister *TerraformModuleRegister, parserFs afero.Fs, dir string, moduleName ModuleName, varFiles []string, ) (*ModuleTree, error)
func ParseFiles ¶
func ParseFiles( moduleRegister *TerraformModuleRegister, parserFs afero.Fs, recurse bool, dir string, moduleName ModuleName, filepaths []string, varfiles []string, ) (*ModuleTree, error)
func (*ModuleTree) Errors ¶
func (mtree *ModuleTree) Errors() []error
func (*ModuleTree) FilePath ¶
func (mtree *ModuleTree) FilePath() string
func (*ModuleTree) LoadedFiles ¶
func (mtree *ModuleTree) LoadedFiles() []string
func (*ModuleTree) Walk ¶
func (mtree *ModuleTree) Walk(v Visitor)
type Resource ¶ added in v0.15.0
type Resource struct { Meta *ResourceMeta Model models.ResourceState }
type ResourceMeta ¶
type SubmoduleLoadingError ¶ added in v0.22.0
func (SubmoduleLoadingError) Error ¶ added in v0.22.0
func (err SubmoduleLoadingError) Error() string
type Term ¶ added in v0.15.0
type Term struct {
// contains filtered or unexported fields
}
func TermFromBody ¶ added in v0.15.0
func TermFromBody(body hcl.Body) Term
func TermFromExpr ¶ added in v0.15.0
func TermFromExpr(expr hcl.Expression) Term
func (Term) Attributes ¶ added in v0.15.0
Attr retrieves a term attribute, or nil if it doesn't exist, or the term doesn't have attributes.
func (Term) Dependencies ¶ added in v0.15.0
func (t Term) Dependencies() []TermDependency
func (Term) VisitExpressions ¶ added in v0.15.0
func (t Term) VisitExpressions(f func(hcl.Expression))
VisitExpressions recursively visits all expressions in a tree of terms.
type TermDependency ¶ added in v0.30.0
type TermDependency struct { Range *hcl.Range // Optional range Traversal hcl.Traversal }
type TermTree ¶ added in v0.15.0
type TermTree struct {
// contains filtered or unexported fields
}
func NewTermTree ¶ added in v0.15.0
func NewTermTree() *TermTree
func (*TermTree) LookupByPrefix ¶ added in v0.15.0
func (*TermTree) VisitTerms ¶ added in v0.15.0
type TerraformModuleRegister ¶
type TerraformModuleRegister struct {
// contains filtered or unexported fields
}
func NewTerraformRegister ¶
func NewTerraformRegister(fsys afero.Fs, dir string) *TerraformModuleRegister
func (*TerraformModuleRegister) GetDir ¶
func (r *TerraformModuleRegister) GetDir(name ModuleName) *string
type UnsupportedOperationDiag ¶
type UnsupportedOperationDiag struct { }
func (UnsupportedOperationDiag) Description ¶
func (d UnsupportedOperationDiag) Description() tfdiags.Description
func (UnsupportedOperationDiag) ExtraInfo ¶ added in v0.18.0
func (d UnsupportedOperationDiag) ExtraInfo() interface{}
func (UnsupportedOperationDiag) FromExpr ¶
func (d UnsupportedOperationDiag) FromExpr() *tfdiags.FromExpr
func (UnsupportedOperationDiag) Severity ¶
func (d UnsupportedOperationDiag) Severity() tfdiags.Severity
func (UnsupportedOperationDiag) Source ¶
func (d UnsupportedOperationDiag) Source() tfdiags.Source
type Visitor ¶
type Visitor interface { VisitModule(meta *ModuleMeta) VisitResource(name FullName, resource *ResourceMeta) VisitTerm(name FullName, term Term) }