Documentation
¶
Index ¶
- Variables
- func LoadMPTFHclBlocks(ignoreUnsupportedBlock bool, dir string) ([]*golden.HclBlock, error)
- type AppendBlockBodyTransform
- type BaseData
- type BaseTransform
- type Data
- type DataLocal
- type DataModule
- type DataMoved
- type DataOutput
- type DataSourceData
- type DataVariable
- type EnsureLocalTransform
- type EphemeralData
- type MetaProgrammingTFConfig
- func (c *MetaProgrammingTFConfig) AddBlock(filename string, block *hclwrite.Block) error
- func (c *MetaProgrammingTFConfig) DataBlocks() []*terraform.RootBlock
- func (c *MetaProgrammingTFConfig) EphemeralBlocks() []*terraform.RootBlock
- func (c *MetaProgrammingTFConfig) Init(hclBlocks []*golden.HclBlock) error
- func (c *MetaProgrammingTFConfig) LocalBlocks() []*terraform.RootBlock
- func (c *MetaProgrammingTFConfig) ModuleBlocks() []*terraform.RootBlock
- func (c *MetaProgrammingTFConfig) ModuleDir() string
- func (c *MetaProgrammingTFConfig) MovedBlocks() []*terraform.RootBlock
- func (c *MetaProgrammingTFConfig) OutputBlocks() []*terraform.RootBlock
- func (c *MetaProgrammingTFConfig) ResourceBlocks() []*terraform.RootBlock
- func (c *MetaProgrammingTFConfig) RootBlock(address string) *terraform.RootBlock
- func (c *MetaProgrammingTFConfig) RunPlan() error
- func (c *MetaProgrammingTFConfig) SaveToDisk() error
- func (c *MetaProgrammingTFConfig) TerraformBlock() *terraform.RootBlock
- func (c *MetaProgrammingTFConfig) VariableBlocks() []*terraform.RootBlock
- type MetaProgrammingTFPlan
- type ModuleSourceData
- type MoveBlockTransform
- type NewBlockTransform
- func (n *NewBlockTransform) Apply() error
- func (n *NewBlockTransform) Decode(block *golden.HclBlock, context *hcl.EvalContext) error
- func (n *NewBlockTransform) Format(block *hclwrite.Block) (*hclwrite.Block, error)
- func (n *NewBlockTransform) NewWriteBlock() *hclwrite.Block
- func (n *NewBlockTransform) Type() string
- type ProviderSchemaData
- type RegexReplaceExpressionTransform
- type RemoveBlockContentBlockTransform
- type RemoveBlockTransform
- type RemoveObjectAttributesTransform
- type Rename
- type RenameAttributeOrNestedBlockTransform
- type ReorderAttributesTransform
- type RequiredProvider
- type ResourceData
- type SortBlocksInFileTransform
- type TerraformCliModuleSourceFetcher
- type TerraformCliProviderSchemaRetriever
- type TerraformData
- type TerraformModuleRef
- func ModuleRefs(tfDir string) ([]*TerraformModuleRef, error)
- func NewTerraformModuleRef(dir, key, source, version string) (*TerraformModuleRef, error)
- func NewTerraformRootModuleRef(dir string) (*TerraformModuleRef, error)
- func NewTerraformTestFileRef(dir, testFile string) (*TerraformModuleRef, error)
- type TerraformModuleSourceFetcher
- type TerraformProviderSchemaRetriever
- type TestFileData
- type Transform
- type UpdateInPlaceTransform
- func (u *UpdateInPlaceTransform) Apply() error
- func (u *UpdateInPlaceTransform) Decode(block *golden.HclBlock, context *hcl.EvalContext) error
- func (u *UpdateInPlaceTransform) PatchWriteBlock(dest terraform.Block, patch *hclwrite.Block) error
- func (u *UpdateInPlaceTransform) String() string
- func (u *UpdateInPlaceTransform) Type() string
- func (u *UpdateInPlaceTransform) UpdateBlock() *hclwrite.Block
Constants ¶
This section is empty.
Variables ¶
var ModuleSourceFetcherFactory = func(ctx context.Context) TerraformModuleSourceFetcher { return moduleSourceMetadataFetcher{TerraformCliModuleSourceFetcher{ctx: ctx}} }
ModuleSourceFetcherFactory is overridable in tests; the default returns a CLI-backed metadata fetcher with exact public-registry version caching.
var ObjectEntriesFunc = function.New(&function.Spec{ Description: "Inspect literal object keys and unevaluated value expressions.", Params: []function.Parameter{ {Name: "input", Type: cty.DynamicPseudoType}, }, Type: function.StaticReturnType(cty.Map(cty.String)), Impl: func(args []cty.Value, _ cty.Type) (cty.Value, error) { input := args[0] var source []byte switch { case input.Type() == cty.String: source = []byte(input.AsString()) case input.Type().IsObjectType() || input.Type().IsMapType(): if !input.IsWhollyKnown() { return cty.NilVal, fmt.Errorf("object_entries input must be wholly known") } source = hclwrite.TokensForValue(input).Bytes() default: return cty.NilVal, fmt.Errorf("object_entries input must be an object expression string, object or map") } object, err := parseLiteralObject(source) if err != nil { return cty.NilVal, err } items, err := staticObjectItems(object) if err != nil { return cty.NilVal, err } values := make(map[string]cty.Value, len(items)) for key, item := range items { values[key] = cty.StringVal(string(item.ValueExpr.Range().SliceBytes(source))) } if len(values) == 0 { return cty.MapValEmpty(cty.String), nil } return cty.MapVal(values), nil }, })
var SchemaRetrieverFactory = func(ctx context.Context) TerraformProviderSchemaRetriever { return NewTerraformCliProviderSchemaRetriever(ctx) }
var ToHclFunc = function.New(&function.Spec{ Description: "Convert an cty.Value to HCL config in string format", Params: []function.Parameter{ { Name: "input", Type: cty.DynamicPseudoType, }, }, Type: function.StaticReturnType(cty.String), Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { input := args[0] return cty.StringVal(string(hclwrite.TokensForValue(input).BuildTokens(nil).Bytes())), nil }, })
Functions ¶
Types ¶
type AppendBlockBodyTransform ¶
type AppendBlockBodyTransform struct {
*golden.BaseBlock
*BaseTransform
TargetBlockAddress string `hcl:"target_block_address" validate:"required"`
BlockBody string `hcl:"block_body" validate:"required"`
}
func (*AppendBlockBodyTransform) Apply ¶
func (u *AppendBlockBodyTransform) Apply() error
func (*AppendBlockBodyTransform) PatchWriteBlock ¶
func (u *AppendBlockBodyTransform) PatchWriteBlock(dest terraform.Block, patch *hclwrite.Body)
func (*AppendBlockBodyTransform) String ¶
func (u *AppendBlockBodyTransform) String() string
func (*AppendBlockBodyTransform) Type ¶
func (u *AppendBlockBodyTransform) Type() string
type BaseData ¶
type BaseData struct{}
func (*BaseData) AddressLength ¶
func (*BaseData) CanExecutePrePlan ¶
type BaseTransform ¶
type BaseTransform struct{}
func (*BaseTransform) AddressLength ¶
func (bt *BaseTransform) AddressLength() int
func (*BaseTransform) BlockType ¶
func (bt *BaseTransform) BlockType() string
func (*BaseTransform) CanExecutePrePlan ¶
func (bt *BaseTransform) CanExecutePrePlan() bool
func (*BaseTransform) Transform ¶
func (bt *BaseTransform) Transform()
type DataLocal ¶
type DataLocal struct {
*BaseData
*golden.BaseBlock
ExpectedNameName string `hcl:"name,optional"`
Result cty.Value `attribute:"result"`
}
func (*DataLocal) ExecuteDuringPlan ¶
type DataModule ¶
type DataModule struct {
*BaseData
*golden.BaseBlock
ExpectedModuleName string `hcl:"name,optional"`
Result cty.Value `attribute:"result"`
}
DataModule exposes every `module` block in the target Terraform module as a map keyed by module name. Each value is the block's full EvalContext — stringified attributes plus an `mptf` metadata sub-object.
Optional `name` filter narrows the result to a single module block.
func (*DataModule) ExecuteDuringPlan ¶
func (d *DataModule) ExecuteDuringPlan() error
func (*DataModule) String ¶
func (d *DataModule) String() string
func (*DataModule) Type ¶
func (d *DataModule) Type() string
type DataMoved ¶
DataMoved exposes every `moved` block in the target Terraform module as a map keyed by a synthetic, declaration-order index ("0", "1", ...). Moved blocks have no native label, so the index is the only stable way to address them individually.
Each value is the block's EvalContext — `from` and `to` attribute strings plus an `mptf` metadata sub-object.
func (*DataMoved) ExecuteDuringPlan ¶
type DataOutput ¶
type DataOutput struct {
*BaseData
*golden.BaseBlock
ExpectedOutputName string `attribute:"name"`
Result cty.Value `attribute:"result"`
}
func (*DataOutput) ExecuteDuringPlan ¶
func (d *DataOutput) ExecuteDuringPlan() error
func (*DataOutput) String ¶
func (d *DataOutput) String() string
func (*DataOutput) Type ¶
func (d *DataOutput) Type() string
type DataSourceData ¶
type DataSourceData struct {
*BaseData
*golden.BaseBlock
DataSourceType string `hcl:"data_source_type,optional"`
UseCount bool `hcl:"use_count,optional" default:"false"`
UseForEach bool `hcl:"use_for_each,optional" default:"false"`
Result cty.Value `attribute:"result"`
}
func (*DataSourceData) ExecuteDuringPlan ¶
func (dd *DataSourceData) ExecuteDuringPlan() error
func (*DataSourceData) String ¶
func (dd *DataSourceData) String() string
func (*DataSourceData) Type ¶
func (dd *DataSourceData) Type() string
type DataVariable ¶
type DataVariable struct {
*BaseData
*golden.BaseBlock
ExpectedNameName string `hcl:"name,optional"`
ExpectedType string `hcl:"type,optional"`
Result cty.Value `attribute:"result"`
}
func (*DataVariable) ExecuteDuringPlan ¶
func (dd *DataVariable) ExecuteDuringPlan() error
func (*DataVariable) String ¶
func (dd *DataVariable) String() string
func (*DataVariable) Type ¶
func (dd *DataVariable) Type() string
type EnsureLocalTransform ¶
type EnsureLocalTransform struct {
*golden.BaseBlock
*BaseTransform
LocalName string `hcl:"name" validate:"required"`
FallbackFileName string `hcl:"fallback_file_name" validate:"required"`
// contains filtered or unexported fields
}
func (*EnsureLocalTransform) Apply ¶
func (u *EnsureLocalTransform) Apply() error
func (*EnsureLocalTransform) Decode ¶
func (u *EnsureLocalTransform) Decode(block *golden.HclBlock, context *hcl.EvalContext) error
func (*EnsureLocalTransform) String ¶
func (u *EnsureLocalTransform) String() string
func (*EnsureLocalTransform) Type ¶
func (u *EnsureLocalTransform) Type() string
type EphemeralData ¶ added in v0.1.3
type EphemeralData struct {
*BaseData
*golden.BaseBlock
EphemeralType string `hcl:"ephemeral_type,optional"`
UseCount bool `hcl:"use_count,optional" default:"false"`
UseForEach bool `hcl:"use_for_each,optional" default:"false"`
Result cty.Value `attribute:"result"`
}
func (*EphemeralData) ExecuteDuringPlan ¶ added in v0.1.3
func (ed *EphemeralData) ExecuteDuringPlan() error
func (*EphemeralData) String ¶ added in v0.1.3
func (ed *EphemeralData) String() string
func (*EphemeralData) Type ¶ added in v0.1.3
func (ed *EphemeralData) Type() string
type MetaProgrammingTFConfig ¶
type MetaProgrammingTFConfig struct {
*golden.BaseConfig
// contains filtered or unexported fields
}
func NewMetaProgrammingTFConfig ¶
func NewMetaProgrammingTFConfig(m *TerraformModuleRef, varConfigDir *string, hclBlocks []*golden.HclBlock, cliFlagAssignedVars []golden.CliFlagAssignedVariables, ctx context.Context) (*MetaProgrammingTFConfig, error)
func (*MetaProgrammingTFConfig) AddBlock ¶
func (c *MetaProgrammingTFConfig) AddBlock(filename string, block *hclwrite.Block) error
func (*MetaProgrammingTFConfig) DataBlocks ¶
func (c *MetaProgrammingTFConfig) DataBlocks() []*terraform.RootBlock
func (*MetaProgrammingTFConfig) EphemeralBlocks ¶ added in v0.1.3
func (c *MetaProgrammingTFConfig) EphemeralBlocks() []*terraform.RootBlock
func (*MetaProgrammingTFConfig) Init ¶
func (c *MetaProgrammingTFConfig) Init(hclBlocks []*golden.HclBlock) error
func (*MetaProgrammingTFConfig) LocalBlocks ¶
func (c *MetaProgrammingTFConfig) LocalBlocks() []*terraform.RootBlock
func (*MetaProgrammingTFConfig) ModuleBlocks ¶
func (c *MetaProgrammingTFConfig) ModuleBlocks() []*terraform.RootBlock
func (*MetaProgrammingTFConfig) ModuleDir ¶ added in v0.1.4
func (c *MetaProgrammingTFConfig) ModuleDir() string
ModuleDir returns the absolute directory of the Terraform module mapotf is currently transforming. Used by data blocks that need to resolve paths declared in the caller's `.mptf.hcl` (for example `data "module_source"` auto-defaults its `base_dir` to this so relative sources resolve against the caller's module, not against an internal temp folder).
func (*MetaProgrammingTFConfig) MovedBlocks ¶
func (c *MetaProgrammingTFConfig) MovedBlocks() []*terraform.RootBlock
func (*MetaProgrammingTFConfig) OutputBlocks ¶
func (c *MetaProgrammingTFConfig) OutputBlocks() []*terraform.RootBlock
func (*MetaProgrammingTFConfig) ResourceBlocks ¶
func (c *MetaProgrammingTFConfig) ResourceBlocks() []*terraform.RootBlock
func (*MetaProgrammingTFConfig) RootBlock ¶
func (c *MetaProgrammingTFConfig) RootBlock(address string) *terraform.RootBlock
func (*MetaProgrammingTFConfig) RunPlan ¶ added in v0.1.11
func (c *MetaProgrammingTFConfig) RunPlan() error
func (*MetaProgrammingTFConfig) SaveToDisk ¶
func (c *MetaProgrammingTFConfig) SaveToDisk() error
func (*MetaProgrammingTFConfig) TerraformBlock ¶
func (c *MetaProgrammingTFConfig) TerraformBlock() *terraform.RootBlock
func (*MetaProgrammingTFConfig) VariableBlocks ¶
func (c *MetaProgrammingTFConfig) VariableBlocks() []*terraform.RootBlock
type MetaProgrammingTFPlan ¶
type MetaProgrammingTFPlan struct {
Transforms []Transform
// contains filtered or unexported fields
}
func RunMetaProgrammingTFPlan ¶
func RunMetaProgrammingTFPlan(c *MetaProgrammingTFConfig) (*MetaProgrammingTFPlan, error)
func (*MetaProgrammingTFPlan) Apply ¶
func (m *MetaProgrammingTFPlan) Apply() error
func (*MetaProgrammingTFPlan) String ¶
func (m *MetaProgrammingTFPlan) String() string
type ModuleSourceData ¶ added in v0.1.3
type ModuleSourceData struct {
*BaseData
*golden.BaseBlock
Source string `hcl:"source"`
Version string `hcl:"version,optional"`
BaseDir string `hcl:"base_dir,optional"`
Variables cty.Value `attribute:"variables"`
Outputs cty.Value `attribute:"outputs"`
RequiredVariables cty.Value `attribute:"required_variables"`
OptionalVariables cty.Value `attribute:"optional_variables"`
}
ModuleSourceData fetches the variables and outputs of a Terraform module (by `source` + optional `version`) and exposes them as cty values that downstream transforms can compose against. The pre-sorted `required_variables` / `optional_variables` lists are intended to be fed into `reorder_attributes.body_attributes` so a `module.<name>` block's inputs end up in required-then-optional alphabetical order.
`source` accepts the same values you'd write in a `module { source = "..." }` block: registry shortcuts (`Azure/naming/azurerm`), git URLs, and local paths (`./submod`, `../../`, absolute paths). Local paths are resolved against `base_dir`, which defaults to the target Terraform module's directory so callers normally don't need to set it.
func (*ModuleSourceData) ExecuteDuringPlan ¶ added in v0.1.3
func (d *ModuleSourceData) ExecuteDuringPlan() error
func (*ModuleSourceData) String ¶ added in v0.1.3
func (d *ModuleSourceData) String() string
func (*ModuleSourceData) Type ¶ added in v0.1.3
func (d *ModuleSourceData) Type() string
type MoveBlockTransform ¶
type MoveBlockTransform struct {
*golden.BaseBlock
*BaseTransform
TargetBlockAddress string `hcl:"target_block_address"`
FileName string `hcl:"file_name"`
}
func (*MoveBlockTransform) Apply ¶
func (m *MoveBlockTransform) Apply() error
func (*MoveBlockTransform) Type ¶
func (m *MoveBlockTransform) Type() string
type NewBlockTransform ¶
type NewBlockTransform struct {
*golden.BaseBlock
*BaseTransform
NewBlockType string `hcl:"new_block_type"`
FileName string `hcl:"filename"`
Labels []string `hcl:"labels,optional"`
NewBody string `hcl:"body,optional"`
// contains filtered or unexported fields
}
func (*NewBlockTransform) Apply ¶
func (n *NewBlockTransform) Apply() error
func (*NewBlockTransform) Decode ¶
func (n *NewBlockTransform) Decode(block *golden.HclBlock, context *hcl.EvalContext) error
func (*NewBlockTransform) NewWriteBlock ¶
func (n *NewBlockTransform) NewWriteBlock() *hclwrite.Block
func (*NewBlockTransform) Type ¶
func (n *NewBlockTransform) Type() string
type ProviderSchemaData ¶
type ProviderSchemaData struct {
*BaseData
*golden.BaseBlock
Source string `hcl:"provider_source"`
Version string `hcl:"provider_version"`
Resources cty.Value `attribute:"resources"`
DataSources cty.Value `attribute:"data_sources"`
ResourcesRequiredAttributes cty.Value `attribute:"resources_required_attributes"`
ResourcesOptionalAttributes cty.Value `attribute:"resources_optional_attributes"`
DataSourcesRequiredAttributes cty.Value `attribute:"data_sources_required_attributes"`
DataSourcesOptionalAttributes cty.Value `attribute:"data_sources_optional_attributes"`
}
func (*ProviderSchemaData) ExecuteDuringPlan ¶
func (r *ProviderSchemaData) ExecuteDuringPlan() error
func (*ProviderSchemaData) Type ¶
func (r *ProviderSchemaData) Type() string
type RegexReplaceExpressionTransform ¶
type RegexReplaceExpressionTransform struct {
*golden.BaseBlock
*BaseTransform
Regex string `hcl:"regex" validate:"required"`
Replacement string `hcl:"replacement"`
}
func (*RegexReplaceExpressionTransform) Apply ¶
func (r *RegexReplaceExpressionTransform) Apply() error
func (*RegexReplaceExpressionTransform) Type ¶
func (r *RegexReplaceExpressionTransform) Type() string
type RemoveBlockContentBlockTransform ¶
type RemoveBlockContentBlockTransform struct {
*golden.BaseBlock
*BaseTransform
TargetBlockAddress string `hcl:"target_block_address"`
Paths []string `hcl:"paths"`
}
func (*RemoveBlockContentBlockTransform) Apply ¶
func (r *RemoveBlockContentBlockTransform) Apply() error
func (*RemoveBlockContentBlockTransform) Type ¶
func (r *RemoveBlockContentBlockTransform) Type() string
type RemoveBlockTransform ¶
type RemoveBlockTransform struct {
*golden.BaseBlock
*BaseTransform
TargetBlockAddress string `hcl:"target_block_address"`
}
func (*RemoveBlockTransform) Apply ¶
func (r *RemoveBlockTransform) Apply() error
func (*RemoveBlockTransform) Type ¶
func (r *RemoveBlockTransform) Type() string
type RemoveObjectAttributesTransform ¶ added in v0.5.0
type RemoveObjectAttributesTransform struct {
*golden.BaseBlock
*BaseTransform
TargetBlockAddress string `hcl:"target_block_address"`
AttributePath []string `hcl:"attribute_path"`
Keys []string `hcl:"keys"`
RemoveEmptyAttribute bool `hcl:"remove_empty_attribute,optional"`
}
func (*RemoveObjectAttributesTransform) Apply ¶ added in v0.5.0
func (r *RemoveObjectAttributesTransform) Apply() error
func (*RemoveObjectAttributesTransform) Decode ¶ added in v0.5.0
func (r *RemoveObjectAttributesTransform) Decode(block *golden.HclBlock, context *hcl.EvalContext) error
func (*RemoveObjectAttributesTransform) Type ¶ added in v0.5.0
func (r *RemoveObjectAttributesTransform) Type() string
type Rename ¶
type Rename struct {
ResourceType string `hcl:"resource_type"`
// We'll deprecate `attribute_path` in favor of `element_path`.
AttributePath []string `hcl:"attribute_path,optional" validate:"excluded_with=element_path"`
ElementPath []string `hcl:"element_path,optional" validate:"excluded_with=attribute_path,required_without=attribute_path"`
NewName string `hcl:"new_name" validate:"required"`
RenameOnlyNewNameAbsent bool `hcl:"rename_only_new_name_absent,optional" default:"false"`
}
type RenameAttributeOrNestedBlockTransform ¶
type RenameAttributeOrNestedBlockTransform struct {
*golden.BaseBlock
*BaseTransform
Renames []Rename `hcl:"rename,block"`
}
func (*RenameAttributeOrNestedBlockTransform) Apply ¶
func (r *RenameAttributeOrNestedBlockTransform) Apply() error
func (*RenameAttributeOrNestedBlockTransform) Type ¶
func (r *RenameAttributeOrNestedBlockTransform) Type() string
type ReorderAttributesTransform ¶
type ReorderAttributesTransform struct {
*golden.BaseBlock
*BaseTransform
TargetBlockAddress string `hcl:"target_block_address"`
HeadAttributes []string `hcl:"head_attributes,optional"`
BodyAttributes []string `hcl:"body_attributes,optional"`
FootAttributes []string `hcl:"foot_attributes,optional"`
HeadFootLineBreaks *bool `hcl:"head_foot_line_breaks,optional"`
SortBodyAlphabetically *bool `hcl:"sort_body_alphabetically,optional"`
NestedBlockPath []string `hcl:"nested_block_path,optional"`
}
ReorderAttributesTransform re-orders the attributes and nested blocks of one root block.
Semantics:
- "Element" = an attribute (name = value) or a nested block. Nested blocks are identified by their type name, except for `dynamic "X"` blocks which are identified by their label (`X`), so they line up with the static block they emit.
- Elements named in `head_attributes` come first, in the listed order.
- Elements named in `foot_attributes` come last, in the listed order.
- Elements named in `body_attributes` come first within the body section, in the listed order. Every other element of the body section is then appended; by default that remainder is sorted alphabetically by name. Set `sort_body_alphabetically = false` to preserve original source order for the unlisted body remainder instead.
- When `head_foot_line_breaks` is true (default) a blank line is inserted between the head section and the body, and between the body and the foot section. Set to `false` to suppress these blank lines.
- Every nested block in the output is preceded by a blank line, except when the previous element is a nested block sharing the same orderable name. Adjacent same-kind siblings (e.g. two `validation {}` blocks of a variable, two `dynamic "subnet" {}` blocks of a resource) stay grouped without a blank line between them, matching typical Terraform formatting. If a section boundary (head/foot) coincides with the adjacency the section blank line still wins.
- Names in `head_attributes` / `body_attributes` / `foot_attributes` that are not present on the block are silently skipped.
- The same name appearing in more than one of `head_attributes`, `body_attributes`, or `foot_attributes` is a configuration error.
This transform never adds, removes, or mutates attribute values — only the layout changes.
func (*ReorderAttributesTransform) Apply ¶
func (r *ReorderAttributesTransform) Apply() error
func (*ReorderAttributesTransform) Type ¶
func (r *ReorderAttributesTransform) Type() string
type RequiredProvider ¶
type ResourceData ¶
type ResourceData struct {
*BaseData
*golden.BaseBlock
ResourceType string `hcl:"resource_type,optional"`
UseCount bool `hcl:"use_count,optional" default:"false"`
UseForEach bool `hcl:"use_for_each,optional" default:"false"`
Result cty.Value `attribute:"result"`
}
func (*ResourceData) ExecuteDuringPlan ¶
func (rd *ResourceData) ExecuteDuringPlan() error
func (*ResourceData) String ¶
func (rd *ResourceData) String() string
func (*ResourceData) Type ¶
func (rd *ResourceData) Type() string
type SortBlocksInFileTransform ¶
type SortBlocksInFileTransform struct {
*golden.BaseBlock
*BaseTransform
FileName string `hcl:"file_name"`
DesiredOrder []string `hcl:"desired_order" validate:"unique,dive,min=1"`
}
SortBlocksInFileTransform ensures every block listed in `desired_order` lives in `file_name`, in the listed order, after any blocks that are already in the file but absent from the list.
Semantics:
- For each address in `desired_order`, the block is removed from whichever file currently holds it and appended to `file_name` in the listed order.
- Blocks already in `file_name` that are NOT in `desired_order` are left untouched at the top of the file.
- An address that does not resolve to a known block is a hard error (silent skip would mask drift, since `desired_order` is usually computed from a data source).
- An empty `desired_order` is a no-op. This makes it safe to drive the list from a data source (e.g. `[for v in data.variable.all.result : "variable.${v.name}"]`) in module contexts where the data source resolves to an empty collection — for example `examples/*` directories that have no `variables.tf`.
func (*SortBlocksInFileTransform) Apply ¶
func (s *SortBlocksInFileTransform) Apply() error
func (*SortBlocksInFileTransform) Type ¶
func (s *SortBlocksInFileTransform) Type() string
type TerraformCliModuleSourceFetcher ¶ added in v0.1.3
type TerraformCliModuleSourceFetcher struct {
// contains filtered or unexported fields
}
type TerraformCliProviderSchemaRetriever ¶
type TerraformCliProviderSchemaRetriever struct {
// contains filtered or unexported fields
}
func (TerraformCliProviderSchemaRetriever) Get ¶
func (t TerraformCliProviderSchemaRetriever) Get(providerSource, versionConstraint string) (*tfjson.ProviderSchema, error)
type TerraformData ¶
type TerraformData struct {
*BaseData
*golden.BaseBlock
RequiredVersion *string `attribute:"required_version"`
RequiredProviders map[string]RequiredProvider
Block cty.Value `attribute:"block"`
}
func (*TerraformData) BaseValues ¶ added in v0.2.1
func (d *TerraformData) BaseValues() map[string]cty.Value
BaseValues exports provider metadata with string-typed nulls instead of golden's nil pointer values.
func (*TerraformData) ExecuteDuringPlan ¶
func (d *TerraformData) ExecuteDuringPlan() error
func (*TerraformData) Type ¶
func (d *TerraformData) Type() string
type TerraformModuleRef ¶
type TerraformModuleRef struct {
Key string `json:"Key"`
Source string `json:"Source"`
Dir string `json:"Dir"`
AbsDir string
Version string `json:"Version"`
GitHash string
TestFile string
}
func ModuleRefs ¶
func ModuleRefs(tfDir string) ([]*TerraformModuleRef, error)
func NewTerraformModuleRef ¶
func NewTerraformModuleRef(dir, key, source, version string) (*TerraformModuleRef, error)
func NewTerraformRootModuleRef ¶
func NewTerraformRootModuleRef(dir string) (*TerraformModuleRef, error)
func NewTerraformTestFileRef ¶ added in v0.3.0
func NewTerraformTestFileRef(dir, testFile string) (*TerraformModuleRef, error)
NewTerraformTestFileRef selects one test file owned by dir.
func (*TerraformModuleRef) Load ¶
func (m *TerraformModuleRef) Load() error
func (*TerraformModuleRef) LoadAbsDir ¶
func (m *TerraformModuleRef) LoadAbsDir() error
func (*TerraformModuleRef) LoadGitHash ¶
func (m *TerraformModuleRef) LoadGitHash()
type TerraformModuleSourceFetcher ¶ added in v0.1.3
type TerraformModuleSourceFetcher interface {
Get(source, version, baseDir string) (*tfconfig.Module, error)
}
TerraformModuleSourceFetcher fetches a Terraform module and returns its parsed metadata via terraform-config-inspect.
For local sources (./, ../, absolute paths) the fetcher resolves the source against baseDir and loads it directly — no terraform invocation, no temp folder. baseDir is required in this case and is normally auto-defaulted by the calling data block to the target module's directory.
For remote sources (registry shortcuts, git URLs, etc.) the fetcher writes a synthetic wrapper into a temp folder and runs `terraform get` to download the module. `terraform get` also validates the wrapper against the target module's required inputs; that validation error is tolerated as long as the download itself succeeded, because terraform-config-inspect only needs the downloaded `.tf` files to parse variable and output declarations.
baseDir is ignored for remote sources but is still expected on every call so the data block layer can auto-default it uniformly.
func NewTerraformCliModuleSourceFetcher ¶ added in v0.1.3
func NewTerraformCliModuleSourceFetcher(ctx context.Context) TerraformModuleSourceFetcher
type TerraformProviderSchemaRetriever ¶
type TerraformProviderSchemaRetriever interface {
Get(providerSource, versionConstraint string) (*tfjson.ProviderSchema, error)
}
func NewTerraformCliProviderSchemaRetriever ¶
func NewTerraformCliProviderSchemaRetriever(ctx context.Context) TerraformProviderSchemaRetriever
type TestFileData ¶ added in v0.3.0
func (*TestFileData) ExecuteDuringPlan ¶ added in v0.3.0
func (d *TestFileData) ExecuteDuringPlan() error
func (*TestFileData) String ¶ added in v0.3.0
func (d *TestFileData) String() string
func (*TestFileData) Type ¶ added in v0.3.0
func (d *TestFileData) Type() string
type Transform ¶
type Transform interface {
golden.ApplyBlock
Transform()
}
type UpdateInPlaceTransform ¶
type UpdateInPlaceTransform struct {
*golden.BaseBlock
*BaseTransform
TargetBlockAddress string `hcl:"target_block_address" validate:"required"`
DynamicBlockBody string `hcl:"dynamic_block_body,optional"`
MergeObjectAttributes bool `hcl:"merge_object_attributes,optional"`
MatchNestedBlockLabels bool `hcl:"match_nested_block_labels,optional"`
// contains filtered or unexported fields
}
func (*UpdateInPlaceTransform) Apply ¶
func (u *UpdateInPlaceTransform) Apply() error
func (*UpdateInPlaceTransform) Decode ¶
func (u *UpdateInPlaceTransform) Decode(block *golden.HclBlock, context *hcl.EvalContext) error
func (*UpdateInPlaceTransform) PatchWriteBlock ¶
func (*UpdateInPlaceTransform) String ¶
func (u *UpdateInPlaceTransform) String() string
func (*UpdateInPlaceTransform) Type ¶
func (u *UpdateInPlaceTransform) Type() string
func (*UpdateInPlaceTransform) UpdateBlock ¶
func (u *UpdateInPlaceTransform) UpdateBlock() *hclwrite.Block
Source Files
¶
- base_data.go
- base_transform.go
- data_data_source.go
- data_ephemeral.go
- data_local.go
- data_module.go
- data_module_source.go
- data_moved.go
- data_output.go
- data_provider_schema.go
- data_resource.go
- data_terraform.go
- data_test_file.go
- data_variable.go
- init.go
- module_source.go
- module_source_cache.go
- module_source_cache_unix.go
- mptf_block.go
- mptf_config.go
- mptf_funcs.go
- mptf_object_funcs.go
- mptf_plan.go
- provider_schema_disk_cache.go
- resource_schema.go
- terraform_module_ref.go
- transform_append_block_body.go
- transform_ensure_local.go
- transform_move_block.go
- transform_new_block.go
- transform_regex_replace_expression.go
- transform_remove_block.go
- transform_remove_block_element_block.go
- transform_remove_object_attributes.go
- transform_rename_block_element.go
- transform_reorder_attributes.go
- transform_sort_blocks_in_file.go
- transform_update_in_place.go
- transform_update_in_place_object.go