plan

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package plan parses a Terraform plan JSON document into a RawStack: reduced action counts plus the set of affected attributes for each change action.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RawAttr

type RawAttr struct {
	Name      string
	Before    any
	After     any
	Sensitive bool // the WHOLE attribute is sensitive (marker is a bare `true`)
	Unknown   bool // known after apply
	// BeforeSensitive/AfterSensitive carry Terraform's per-path sensitivity tree
	// for this attribute when it is a nested map/list (not a bare bool), so the
	// differ can redact only the sensitive sub-paths instead of the whole value.
	BeforeSensitive any
	AfterSensitive  any
}

RawAttr is one changed attribute, pre-rendering.

type RawChange

type RawChange struct {
	Address string
	Type    string
	Actions []string // raw tf actions, e.g. ["update"] or ["delete","create"]
	Action  model.Action
	Attrs   []RawAttr // populated for create/delete/update/replace/forget

	Name          string
	ModuleAddress string

	// Raw holds top-level scalar attributes (string/number/bool), after over
	// before, sensitive values skipped. Retained for classification attribute
	// extraction, which must see attributes even when they did not change.
	Raw map[string]any

	Moved           bool
	PreviousAddress string
	Imported        bool
	ImportID        string
}

RawChange is one resource change with its raw Terraform actions retained (classify needs them) alongside the reduced bucket.

type RawStack

type RawStack struct {
	Name    string
	Counts  model.Counts
	Changes []RawChange
}

RawStack is a parsed plan for one stack (no-ops excluded).

func Parse

func Parse(name string, data []byte) (RawStack, error)

Parse reads a `terraform show -json` plan document.

func (*RawStack) ApplyStateMoves added in v0.5.9

func (rs *RawStack) ApplyStateMoves(targets statemoves.Set) int

ApplyStateMoves reclassifies every change whose address is a pending cross-state move-target (from the --state-moves manifest) as a MOVE rather than the create/update terraform plans it as. A cross-state move lands the resource in a fresh destination state, so terraform shows it as a create with no PreviousAddress; --state-moves is the out-of-band knowledge that it is really a relocation. After this overlay such a change is indistinguishable from an in-stack `moved`: its mutating count is removed (it makes no apply-time provider write), Counts.Move is incremented, Action becomes Noop (so classification skips it — no IAM gate) and Moved is set (so it renders with the move glyph, not a create). Returns the number of changes reclassified so the caller can surface a non-gating "move" category.

An empty target set is a no-op (the fail-safe when --state-moves is absent).

Jump to

Keyboard shortcuts

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