engine

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheInspector added in v0.9.4

type CacheInspector interface {
	// Dir returns the resolved pricing cache directory path, or empty if not backed by disk.
	Dir() string
	// TTL returns the cache time-to-live for pricing entries.
	TTL() time.Duration
	// OldestAge returns the age of the oldest cache entry, or 0 if the cache is empty.
	OldestAge(ctx context.Context) time.Duration
	// Entries returns info about all cached pricing files.
	Entries(ctx context.Context) []pricing.CacheEntry
	// CleanExpired removes all expired cache entries.
	CleanExpired(ctx context.Context)
}

CacheInspector provides diagnostic and maintenance access to the pricing cache. Obtain it via Estimator.Cache().

type Estimator

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

Estimator calculates cost estimates for terraform plans.

func NewEstimatorFromConfig

func NewEstimatorFromConfig(cfg *model.CostConfig, cache *blobcache.Cache) (*Estimator, error)

NewEstimatorFromConfig creates an Estimator from config and a prepared blob cache. This is the canonical production constructor.

func NewEstimatorWithDeps added in v0.9.4

func NewEstimatorWithDeps(runtime *costruntime.EstimationRuntime) (*Estimator, error)

NewEstimatorWithDeps creates an Estimator with an explicit combined runtime dependency. Use for testing or advanced DI scenarios where exact provider wiring must be controlled.

func (*Estimator) Cache added in v0.9.4

func (e *Estimator) Cache() CacheInspector

Cache returns a CacheInspector for diagnostic and maintenance access to the pricing cache.

func (*Estimator) EstimateModule

func (e *Estimator) EstimateModule(ctx context.Context, modulePath, region string) (*model.ModuleCost, error)

EstimateModule calculates cost for a single module from plan.json.

func (*Estimator) EstimateModules

func (e *Estimator) EstimateModules(ctx context.Context, modulePaths []string, regions map[string]string) (*model.EstimateResult, error)

EstimateModules calculates costs for multiple modules concurrently.

type ModuleExecutor

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

ModuleExecutor executes scanned module plans through the cost resolver.

func NewModuleExecutor

func NewModuleExecutor(resolver moduleResolver) *ModuleExecutor

NewModuleExecutor creates a module executor for the provided resolver.

func (*ModuleExecutor) Execute

func (e *ModuleExecutor) Execute(ctx context.Context, modulePlan *PlanResult) *model.ModuleCost

Execute resolves all resources in a module plan and aggregates the result.

type ModulePlanAdapter

type ModulePlanAdapter interface {
	LoadModule(modulePath, region string) (*PlanResult, error)
}

ModulePlanAdapter converts external plan sources into the cost engine input model.

type ModuleScanner

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

ModuleScanner loads module plans through a source-specific adapter.

func NewModuleScanner

func NewModuleScanner(adapter ModulePlanAdapter) *ModuleScanner

NewModuleScanner creates a module scanner for the provided plan adapter.

func (*ModuleScanner) Scan

func (s *ModuleScanner) Scan(modulePath, region string) (*PlanResult, error)

Scan loads a module plan through the configured adapter.

func (*ModuleScanner) ScanManyBestEffort

func (s *ModuleScanner) ScanManyBestEffort(modulePaths []string, regions map[string]string) []ScannedModulePlan

ScanManyBestEffort scans multiple modules and preserves per-module failures.

type PlanResult added in v0.10.0

type PlanResult struct {
	ModuleID   string
	ModulePath string
	Region     string
	HasChanges bool
	Resources  []PlannedResource
}

PlanResult is the provider-neutral input model consumed by the cost engine.

type PlannedResource

type PlannedResource struct {
	ResourceType resourcedef.ResourceType
	Address      string
	Name         string
	ModuleAddr   string
	Action       model.EstimateAction
	BeforeAttrs  map[string]any
	AfterAttrs   map[string]any
}

PlannedResource is the scanner's internal resource IR decoupled from raw Terraform plan types.

func (PlannedResource) ActiveAttrs

func (r PlannedResource) ActiveAttrs() map[string]any

ActiveAttrs returns the attrs that represent the resource's current target state.

func (PlannedResource) RequiresBeforeCost

func (r PlannedResource) RequiresBeforeCost() bool

RequiresBeforeCost reports whether the before-state should be priced separately.

func (PlannedResource) ResolveRequest

func (r PlannedResource) ResolveRequest(region string) costruntime.ResolveRequest

ResolveRequest returns the primary resolution request for this planned resource.

type ScannedModulePlan

type ScannedModulePlan struct {
	Index      int
	ModulePath string
	Region     string
	Plan       *PlanResult
	Err        error
}

ScannedModulePlan captures either a scanned plan or a per-module scan error.

type TerraformPlanAdapter

type TerraformPlanAdapter struct{}

TerraformPlanAdapter converts Terraform plan.json files into the engine input model.

func NewTerraformPlanAdapter

func NewTerraformPlanAdapter() *TerraformPlanAdapter

NewTerraformPlanAdapter creates a Terraform-backed module plan adapter.

func (*TerraformPlanAdapter) LoadModule

func (a *TerraformPlanAdapter) LoadModule(modulePath, region string) (*PlanResult, error)

LoadModule reads a Terraform plan and maps it into the provider-neutral input model.

Jump to

Keyboard shortcuts

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