Documentation
¶
Overview ¶
Package cone computes a change's cone within one estate (GitHub issue #1956): the blocks a git diff changes, deletes or refactors, and every block that reads one of them in the head configuration. A plan given the cone as targets lets the plan graph add the ancestors itself, so this package writes no second targeting rule.
The diff is block-level over the root module: two blocks with the same type and labels are the same node, and a node changed when its source text, whitespace aside, differs. A local module call changed when any file under its source directory did. tfvars change the variables they set. A guard names the conditions under which a cone cannot be trusted, and a caller that sees one plans the whole estate instead.
Index ¶
Constants ¶
const ( GuardNoBase = "no-base" GuardProvider = "provider-changed" GuardLockFile = "lock-file-changed" GuardLiveBlock = "live-block-changed" GuardTerraform = "terraform-block-changed" GuardUnplaced = "refactor-unplaced" GuardEmpty = "empty-cone" GuardParse = "config-unreadable" GuardSweep = "sweep-outside-cone" GuardNonNative = "json-config" GuardModuleRemote = "remote-module-changed" )
Guard reasons, as the JSON document and the plan note name them.
DefaultShare is the largest share of the estate's blocks a cone may hold before the guard plans everything instead (the research's 30%).
Variables ¶
This section is empty.
Functions ¶
func MissedUpdates ¶
MissedUpdates is the claim's check (GitHub issue #1956): given the addresses a full plan changes and the cone's targets, it returns the changes no cone target covers. A cone that drops a dependent leaves that dependent's update here; an empty answer is the cone holding.
Types ¶
type Guard ¶
type Guard struct {
Full bool `json:"full"`
Kind string `json:"kind,omitempty"`
Reason string `json:"reason,omitempty"`
}
Guard is the verdict: Full means plan everything, for Reason.
type Options ¶
type Options struct {
// Dir is the root module's directory, inside a git working tree. The
// head side is the working tree as it is now, uncommitted edits included,
// because that is what a plan in Dir reads.
Dir string
// Base is the git revision the change is measured against.
Base string
Share float64
}
Options is one cone computation.
type Result ¶
type Result struct {
Schema int `json:"schema"`
Base string `json:"base"`
BaseSHA string `json:"base_sha,omitempty"`
// Changed are the nodes whose source differs, in head-graph terms
// (resource, data.x.y, module.m, var.v, local.l, output.o).
Changed []string `json:"changed"`
// Deleted are block addresses present at Base and absent now.
Deleted []string `json:"deleted"`
// Refactor are moved from/to, removed from and import to addresses.
Refactor []string `json:"refactor"`
// Widened are blocks added by the co-managed type-pair table.
Widened []string `json:"widened"`
// Reach is every node in the cone: Changed plus descendants plus
// Widened, of every kind.
Reach []string `json:"reach"`
// Targets are the resource and module addresses to pass as -target:
// Reach's targetable members, Deleted and Refactor.
Targets []string `json:"targets"`
// Blocks and ConeBlocks size the estate and the cone for the share.
Blocks int `json:"blocks"`
ConeBlocks int `json:"cone_blocks"`
Guard Guard `json:"guard"`
}
Result is the cone.
func Compute ¶
Compute reads the diff and returns the cone. An error is returned only when Dir cannot be read at all; everything else that defeats a cone is a guard verdict on the result.