Documentation ¶
Overview ¶
Package depgen extracts resource dependency information from Terraform provider documentation and test files.
Index ¶
- type Attr
- type AttrMap
- type AttrSchema
- type Model
- type Parser
- func (p *Parser) Apply(rules map[string]bool) *Parser
- func (p *Parser) Call(fn func(*Attr) bool) *Parser
- func (p *Parser) Model() *Model
- func (p *Parser) Parse(fn func() tf.ResourceProvider) *Parser
- func (p *Parser) ParseDir(root string) *Parser
- func (p *Parser) Schema(typ, attr string) (s AttrSchema)
- type Val
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attr ¶
Attr contains all discovered values for one attribute. Attr may refer to a nested attribute within the type (e.g. "attr1.attr2.attr3"). Simple values are those composed of exactly one managed resource interpolation, such as "${resource_type.name.attr}". Complex values may include literal text, multiple interpolations, function calls, etc. These can normally be ignored for the purposes of dependency inference, but sometimes may require provider-specific logic to generate the correct DepSpec.
func (*Attr) Explain ¶
Explain returns a string explaining why this attribute should not be included in a DepMap.
type AttrSchema ¶
AttrSchema describes the schema of a resource attribute. Hier will contain multiple schemas for nested attributes.
func (*AttrSchema) IsScalar ¶
func (s *AttrSchema) IsScalar() bool
IsScalar returns true if s refers to exactly one value. It returns false if the attribute is part of a list or set, or if it refers to a map without an explicit key.
func (*AttrSchema) IsString ¶
func (s *AttrSchema) IsString() bool
IsString returns true if s refers to a string attribute.
type Model ¶
Model is passed to a template to generate Go source code for the dependency map.
func (*Model) DepMapType ¶
DepMapType returns tfx.DepMap type.
type Parser ¶
type Parser struct { Provider *schema.Provider Sources []string TypeMap map[string]AttrMap // contains filtered or unexported fields }
Parser extracts interpolated attribute values from HCL examples.
func (*Parser) Apply ¶
Apply removes or keeps attributes in p.TypeMap by looking up rules in a map. Keys may be "<type>.<attr>", "<type>", or ".<attr>", with lookups performed in that order. First match wins.
func (*Parser) Call ¶
Call calls fn for each attribute in p.TypeMap and removes those for which fn returns false.
func (*Parser) Parse ¶
func (p *Parser) Parse(fn func() tf.ResourceProvider) *Parser
Parse calls ParseDir on the module root directory of the specified provider.
func (*Parser) ParseDir ¶
ParseDir recursively parses all supported file types in the specified directory. It may be called multiple times for different roots.
func (*Parser) Schema ¶
func (p *Parser) Schema(typ, attr string) (s AttrSchema)
Schema returns the schema of the specified resource attribute ("type.name").
type Val ¶
Val is an attribute value that contains interpolations. AttrSchema, Type, and Attr are set only for simple interpolations.
func NewVal ¶
NewVal parses a HashiCorp Interpolation Language (HIL) string and returns a new Val if it contains at least one interpolated resource expression.