tf

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package tf holds Terraform-facing helpers: pure parsers for plan/schema JSON now, and (later) a driver wrapping hashicorp/terraform-exec.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DriftItem

type DriftItem struct {
	Address string
	Actions []string
}

DriftItem is one resource that did not no-op.

type RoundTrip

type RoundTrip struct {
	Clean []string    // addresses that round-tripped clean (no-op)
	Drift []DriftItem // addresses with residual drift (a property not captured)
}

RoundTrip is the parsed correctness-oracle result of a terraform plan.

func ParseRoundTrip

func ParseRoundTrip(planJSON []byte) (*RoundTrip, error)

ParseRoundTrip parses `terraform show -json <plan>` output. A managed resource whose change.actions == ["no-op"] round-tripped clean; anything else is drift. Data sources (mode != "managed") are ignored. Source: https://developer.hashicorp.com/terraform/internals/json-format

type Runner

type Runner struct {
	Dir string
	Bin string
}

Runner drives the terraform CLI in a working directory. (We can swap this for hashicorp/terraform-exec later; shelling out keeps the skeleton dependency-free.)

func New

func New(dir string) *Runner

New returns a Runner rooted at dir.

func (*Runner) Fmt

func (r *Runner) Fmt(ctx context.Context) (string, error)

Fmt runs `terraform fmt -recursive` to canonically format the generated repo. It needs no init/providers, so it is safe to run on the repo tree directly.

func (*Runner) GenerateConfig

func (r *Runner) GenerateConfig(ctx context.Context, outFile string) (string, error)

GenerateConfig runs `terraform plan -generate-config-out=<out>` to draft HCL for the import blocks in the working dir. Config generation is experimental (may over-emit / leak values), so callers curate the output.

func (*Runner) Init

func (r *Runner) Init(ctx context.Context) (string, error)

Init runs `terraform init`.

func (*Runner) InitLocal

func (r *Runner) InitLocal(ctx context.Context) (string, error)

InitLocal initializes with the remote backend skipped (local state). The correctness oracle only needs to plan against reality, not manage remote state, so it must not require the reconciled backend.tf's -backend-config.

func (*Runner) Plan

func (r *Runner) Plan(ctx context.Context, outFile string) (string, error)

Plan runs `terraform plan -out=<file>`.

func (*Runner) ShowJSON

func (r *Runner) ShowJSON(ctx context.Context, planFile string) (string, error)

ShowJSON runs `terraform show -json <plan>` (feeds ParseRoundTrip).

Jump to

Keyboard shortcuts

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