Help us shape the future of Go! Take the 2026 Go Developer Survey

pkg

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AbsDir func(string) (string, error) = filepath.Abs
View Source
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.

View Source
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
	},
})
View Source
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

func LoadMPTFHclBlocks

func LoadMPTFHclBlocks(ignoreUnsupportedBlock bool, dir string) ([]*golden.HclBlock, error)

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 (rd *BaseData) AddressLength() int

func (*BaseData) BlockType

func (bd *BaseData) BlockType() string

func (*BaseData) CanExecutePrePlan

func (bd *BaseData) CanExecutePrePlan() bool

func (*BaseData) Data

func (bd *BaseData) Data()

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 Data

type Data interface {
	golden.PlanBlock
	Data()
}

type DataLocal

type DataLocal struct {
	*BaseData
	*golden.BaseBlock

	ExpectedNameName string    `hcl:"name,optional"`
	Result           cty.Value `attribute:"result"`
}

func (*DataLocal) ExecuteDuringPlan

func (dl *DataLocal) ExecuteDuringPlan() error

func (*DataLocal) String

func (dl *DataLocal) String() string

func (*DataLocal) Type

func (dl *DataLocal) Type() string

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

type DataMoved struct {
	*BaseData
	*golden.BaseBlock

	Result cty.Value `attribute:"result"`
}

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

func (d *DataMoved) ExecuteDuringPlan() error

func (*DataMoved) String

func (d *DataMoved) String() string

func (*DataMoved) Type

func (d *DataMoved) Type() string

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 (*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) Format

func (n *NewBlockTransform) Format(block *hclwrite.Block) (*hclwrite.Block, 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) Convert

func (r *ProviderSchemaData) Convert(schemas map[string]*tfjson.Schema) (cty.Value, error)

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 (*RegexReplaceExpressionTransform) Type

type RemoveBlockContentBlockTransform

type RemoveBlockContentBlockTransform struct {
	*golden.BaseBlock
	*BaseTransform
	TargetBlockAddress string   `hcl:"target_block_address"`
	Paths              []string `hcl:"paths"`
}

func (*RemoveBlockContentBlockTransform) Apply

func (*RemoveBlockContentBlockTransform) Type

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 (*RemoveObjectAttributesTransform) Decode added in v0.5.0

func (*RemoveObjectAttributesTransform) Type added in v0.5.0

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 (*RenameAttributeOrNestedBlockTransform) Type

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

type RequiredProvider

type RequiredProvider struct {
	Source  *string `attribute:"source"`
	Version *string `attribute:"version"`
}

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

type TerraformCliModuleSourceFetcher added in v0.1.3

type TerraformCliModuleSourceFetcher struct {
	// contains filtered or unexported fields
}

func (TerraformCliModuleSourceFetcher) Get added in v0.1.3

func (t TerraformCliModuleSourceFetcher) Get(source, version, baseDir string) (*tfconfig.Module, error)

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

type TestFileData struct {
	*BaseData
	*golden.BaseBlock

	Result cty.Value `attribute:"result"`
}

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 (u *UpdateInPlaceTransform) PatchWriteBlock(dest terraform.Block, patch *hclwrite.Block) error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL