parser

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Overview

Package parser loads Terraform plan JSON into a normalized resource list.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProviderForType

func ProviderForType(tfType string) string

ProviderForType maps a Terraform resource type to the pricing provider that serves it, based on the type's provider prefix.

Types

type Plan

type Plan struct {
	FormatVersion string            `json:"format_version"`
	Resources     []PlannedResource `json:"-"`
}

func LoadPlanJSON

func LoadPlanJSON(path string) (*Plan, error)

LoadPlanJSON parses `terraform show -json <plan>` output. Only "create" and "update" actions contribute to cost; "delete" resources are handled in diff mode.

type PlannedResource

type PlannedResource struct {
	Address string                 `json:"address"`
	Type    string                 `json:"type"` // e.g. "tencentcloud_instance"
	Name    string                 `json:"name"`
	After   map[string]interface{} `json:"after"` // resource_changes[].change.after
	Region  string                 `json:"region,omitempty"`
}

PlannedResource is one row we hand to the pricing engine. It intentionally keeps the raw attribute map so per-type mappers can pull what they need (instance_type, data_disks, charge_type, etc.).

type UsageOverrides

type UsageOverrides map[string]map[string]interface{}

UsageOverrides maps resource address -> arbitrary usage key/value pairs. Example:

tencentcloud_cos_bucket.static_site:
  monthly_storage_gb: 200
  monthly_get_requests: 1000000

Unknown fields are preserved and consumed by mapper-specific Extract logic.

func LoadUsageYAML

func LoadUsageYAML(path string) (UsageOverrides, error)

LoadUsageYAML reads usage assumptions from YAML. Empty path means "no overrides" and returns an empty map.

Jump to

Keyboard shortcuts

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