engine

package
v1.10.1 Latest Latest
Warning

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

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

Documentation

Overview

Package engine executes a plan, and enforces the two rules that make firing one survivable: the restore record is written first, and it is updated after every single change.

The second rule matters more than it looks. A fire interrupted halfway — network drops, credentials expire, someone hits ctrl-C — must leave a record that says exactly which resources were changed and which were not. Writing the snapshot only at the end would turn an interrupted fire into an account in an unknown state, which is the situation this tool exists to prevent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deadlines

func Deadlines(snap model.Snapshot, now time.Time) []string

Deadlines reports databases that AWS will restart by itself, and when. This is the thing that turns a kill switch into a surprise a week later.

Types

type Executor

type Executor interface {
	Apply(ctx context.Context, a model.Action) error
	Restore(ctx context.Context, e model.Entry) error
}

Executor performs one change, or undoes one.

type Options

type Options struct {
	// DryRun prints what would happen and touches nothing. The default
	// everywhere: firing has to be the thing you asked for explicitly.
	DryRun bool
	// ContinueOnError keeps going when one resource fails. On by default for a
	// fire — a single unstoppable resource should not leave the rest running —
	// and off for a restore, where an early failure usually means credentials
	// are wrong and pressing on would produce a misleading partial success.
	ContinueOnError bool
	Now             func() time.Time
	Log             *audit.Log
}

type Result

type Result struct {
	Snapshot model.Snapshot
	Changed  int
	Failed   int
	Skipped  int
}

func Fire

func Fire(ctx context.Context, p model.Plan, st state.Store, ex Executor, opt Options) (Result, error)

Fire executes the plan. The snapshot is written and verified before the first change; if that fails, nothing is touched.

func Restore

func Restore(ctx context.Context, snap model.Snapshot, st state.Store, ex Executor, opt Options) (Result, error)

Restore puts back what was changed, in reverse phase order.

Jump to

Keyboard shortcuts

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