engine

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package engine takes a started run from its plan to its close (spec §4), in the run's own process. It composes what the other packages give and re-derives none of it: Terragrunt plans, applies and orders the units, and reads how each ended; plan reads each unit's plan JSON; the record keeps the run's events, lands its answers first come first served, and says where the run stands.

Where the verb needs a person, and for every plan, the engine plans every unit with its plan saved, writes each unit's facts and the round's summary, and asks at the round's level: the click in a tier that asks, the click and the delete sign-in for any delete, replacement or destroy. It waits on the record for an answer or a cancel from another process, reading it each tick, which expires the round once its plan lapses by the wall clock, as a Mac's sleep doesn't stop it. Just before an approved round applies, it checks the apply profile's login, and holds the click while signing in would mend it. Before any round applies, the account guard checks the apply's credentials reach the account each unit expects. It applies exactly the round's saved plans: those that change something, of the units that don't wait, and deletes the others as soon as it knows them. Before the apply's tools start, the record gains the credentials it runs with where the start didn't know them, as for a plan's offer. A unit waits for the next round where it was planned against mock outputs of a unit of the run, a unit it depends on changes an output or waits itself, or OpenTofu refused its saved plan as stale. A unit planned against mock outputs no round can make real, from outside the run, of a unit Terragrunt left out, or of a unit so mocked, never applies in it, and never waits. A round with nothing applied since the last plan ends the run rather than planning again.

A destroy that asks plans with -destroy for its summary, then runs Terragrunt's own destroy once approved, in one round. Where the tier allows the verb, an apply or destroy runs with no plan phase and no question. A cancel interrupts Terragrunt alone, through the run's context, and the run closes once it has exited and reported: a cancel outranks every other end. Every unit of a run that applied is in its close: its result, unchanged, or left out by Terragrunt. A plan that applied nothing has no results: its summary says what each unit planned.

A round whose plan deletes or replaces needs the delete sign-in too. Once its click lands, the run's process listens for the sign-in's keys, which a view in the person's terminal takes and hands over without touching disk; it takes them only once AWS says they act as the delete sign-in profile's permission set in its account, and records the sign-in itself (5.5.8). Nothing else unlocks the round: a sign-in on the record with no keys taken applies nothing. The round's account guard and apply use those keys in the apply profile's place (6.1.1), and the run drops them once that apply ends: each round that deletes asks for the click and a sign-in of its own (4.5.8).

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSignInKeys = errors.New("the round needs the delete sign-in's keys, and the run holds none that are live")

ErrNoSignInKeys is a round that needs the delete sign-in's keys to apply, as its plan deletes, where the run holds none that are live: its record says the round's sign-in landed with no keys taken, or the keys lapsed before its apply began.

Functions

This section is empty.

Types

type DeleteSignIn

type DeleteSignIn struct {
	Profile       config.ProfileName
	Account       account.ID
	PermissionSet string
	// Region is where the keys act, for an environment that names no
	// region of its own: the apply profile's, as a normal apply's, or
	// failing that the profile's.
	Region cloud.Region
}

DeleteSignIn is the delete sign-in's profile, and the role whose keys alone the run takes for it: the account and permission set of the profile's cloud.Profile.OwnSignIn (5.5.1). The zero value is a sign-in that isn't set up.

func (DeleteSignIn) SetUp

func (d DeleteSignIn) SetUp() bool

SetUp reports whether the delete sign-in is set up.

type Engine

type Engine struct {
	Terragrunt Terragrunt
	Logins     Logins
	// Environ is terrace's own environment, the one the Terragrunt client's
	// Environ is: the run's record names what an apply's clean environment
	// removes from it, where the run's start didn't (6.2.1).
	Environ []string
	// Now is the wall clock, which expiries are judged by; time.Now where
	// nil. It's read in UTC with no monotonic reading, as a Mac's monotonic
	// clock stops while it sleeps.
	Now func() time.Time
	// Listen listens for the delete sign-in's keys in dir, a folder of the
	// run's own; handoff.Listen where nil.
	Listen func(dir string) (Handoff, error)
}

Engine takes a started run from its plan to its close.

func (Engine) Run

func (e Engine) Run(ctx context.Context, run *record.Run, spec Spec) error

Run takes run from its start to its close, by spec, and returns once the run has closed: done, failed, cancelled, rejected or expired. The caller holds the run's lease. Where ctx ends, Terragrunt is interrupted as a cancel does, and winds down as it will. Once the run has handed an apply to Terragrunt, though ctx had ended by then and Terragrunt starts nothing, Run writes what Terragrunt reported and closes the run however ctx ends, within a few seconds of ctx's end or Terragrunt's exit, whichever is later, and at most the runner's grace and twice those few seconds after ctx's end, however long another process holds the record, as the runner kills Terragrunt once its grace is out. Terragrunt's lines reach the record for a few seconds after ctx's end, and after that wherever the record is free, and the run's log whatever happens. The close keeps what applied: done where Terragrunt reached its end by itself and the run came to its end; failed where the stop cut the run short, its close saying what the run was doing, and Run returning ctx's error. Before that, a stop leaves the run to the record, which closes it as failed once this process has gone (4.6.6), and Run returns ctx's error. Its error is also for what kept the run from its close, or what followed an event recorded, and for what the tools wrote that couldn't be read, or the record couldn't keep of them, beside the close that records it.

type Handoff

type Handoff interface {
	Serve(ctx context.Context, take func(context.Context, cloud.Keys) error) error
	Close() error
}

Handoff is where a run that waits for the delete sign-in takes the keys a view in the person's terminal took, as *handoff.Listener is: Serve has take check each set sent, and take them or say why not, until ctx ends or it's closed, and returns once no set is being taken.

type Logins

type Logins interface {
	Identity(ctx context.Context, c cloud.Credentials) (cloud.Identity, error)
}

Logins says whose credentials a profile, or keys, hold, as cloud.Cloud does: its error is a *cloud.SignedOutError where they don't work, with the command that signs the profile in where signing in mends them.

type Spec

type Spec struct {
	// Root is the repo's root, a physical path, which Terragrunt runs in.
	Root string
	// Units are the run's units as Terragrunt found them, with their
	// dependencies, in run order: the record's start's units.
	Units []terragrunt.Unit
	// Policy is what the run's verb needs over its units: its level, the
	// plans' expiry and arguments, and the profiles.
	Policy config.Policy
	// Apply is what an apply of the units needs, for a plan: its offer is
	// approved at the apply's level, and applies with the apply's profile
	// (4.7.3). It's the zero Policy where the apply's tiers refuse the
	// offer: the plan then asks nothing and applies nothing. Other verbs
	// leave it unset.
	Apply config.Policy
	// Accounts are the accounts the units expect, as account.Find gives
	// them: a unit with no guard file above it has none, nor does any unit
	// with no account guard (2.5.4). Each round's apply is checked against
	// them (2.5.3).
	Accounts map[unit.Path]account.Account
	// SourceMap maps module sources to local checkouts, for --local.
	SourceMap map[string]string
	// Parallelism caps how many units Terragrunt runs at once; 0 leaves its
	// own default.
	Parallelism int
	// Holding says which resource types hold data (7.4).
	Holding plan.DataHolding
	// DeleteSignIn is the delete sign-in, where it's set up: the run's tier
	// names one, and the AWS config makes its profile one, as
	// cloud.Profile.OwnSignIn says. Where it isn't, a round that needs it
	// can't be approved, and waits until the run is cancelled or its plan
	// expires (5.1.6).
	DeleteSignIn DeleteSignIn
}

Spec is what a started run's process needs beyond its record's start.

type Terragrunt

type Terragrunt interface {
	Plan(ctx context.Context, in terragrunt.PlanInput) (terragrunt.Outcome, error)
	Apply(ctx context.Context, in terragrunt.ApplyInput) (terragrunt.Outcome, error)
}

Terragrunt plans and applies a run's units, as terragrunt.Client does.

Jump to

Keyboard shortcuts

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