Documentation
¶
Overview ¶
Package plan parses a `terraform show -json` plan into grouped resource actions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotAPlan = errors.New("input is not a Terraform plan document: no " +
`"resource_changes" or "planned_values" key found. Produce it with ` +
"`terraform plan -out=plan.bin && terraform show -json plan.bin`, not " +
"`terraform show -json` (which prints state)")
ErrNotAPlan is returned when the input parses as JSON but is not a Terraform plan document.
Order is the display order for actions.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action string
Action is the effective change kind for a resource.
const ( Create Action = "create" Update Action = "update" Replace Action = "replace" Destroy Action = "destroy" // Forget is Terraform's `removed` block outcome: the object is dropped from // state but left running. Nothing is destroyed, yet the resource stops being // managed, so it is reported rather than hidden. Forget Action = "forget" // Unknown is any action combination this version does not recognise (an // empty array, or a verb from a newer Terraform). It is surfaced so the // summary can never silently under-report a change it did not understand. Unknown Action = "unknown" NoOp Action = "no-op" Read Action = "read" )
type ResourceChange ¶
ResourceChange is one planned change.
type Stats ¶ added in v1.0.0
type Stats struct {
Create int `json:"create"`
Update int `json:"update"`
Replace int `json:"replace"`
Destroy int `json:"destroy"`
Forget int `json:"forget"`
Unknown int `json:"unknown"`
NoOp int `json:"no_op"`
Read int `json:"read"`
Total int `json:"total"`
HasRisk bool `json:"has_risk"`
}
Stats is the machine-readable form of a Summary, for `--stats-json` and for GitHub Actions step outputs.
type Summary ¶
type Summary struct {
Changes []ResourceChange
Counts map[Action]int
}
Summary is the parsed plan grouped by action.
func Parse ¶
Parse reads plan JSON produced by `terraform show -json plan.bin`.
Input that parses as JSON but carries neither "resource_changes" nor "planned_values" is rejected instead of being reported as an empty plan: a state file, a truncated download, or an unrelated JSON document must never render as "No changes".