Documentation
¶
Overview ¶
Package stackdrift periodically plans each stack's latest applied revision against live state and records whether they still match (ADR 042). It only reads: nothing here applies a plan or writes a live resource.
Index ¶
Constants ¶
const ( EnvInterval = "APP_STACK_DRIFT_INTERVAL" EnvSummaryMax = "APP_STACK_DRIFT_SUMMARY_MAX" DefaultInterval = 15 * time.Minute )
Env names for the loop. APP_STACK_DRIFT_INTERVAL=0 turns it off.
const ( ActionChanged = "changed" ActionMissing = "missing" ActionOwnerChanged = "owner_changed" )
Item actions in a drift summary.
const DefaultTick = 30 * time.Second
DefaultTick keeps the loop cheap while off but quick to notice a setting change.
Variables ¶
This section is empty.
Functions ¶
func IntervalFromEnv ¶
IntervalFromEnv reads APP_STACK_DRIFT_INTERVAL; 0 disables the loop and an unset or invalid value falls back to the default.
Types ¶
type Checker ¶
type Checker struct {
Store Store
Live OpenLive
// ProjectName resolves a stack's project id to the name documents use.
ProjectName func(ctx context.Context, id string) string
Logger *slog.Logger
Now func() time.Time
// StartDelay is the wait before the first pass after boot.
StartDelay time.Duration
// Interval and SummaryMax read live settings each cycle; nil falls back to env.
Interval func(ctx context.Context) time.Duration
SummaryMax func(ctx context.Context) int
// Tick is how often RunLive re-reads the interval; zero means DefaultTick.
Tick time.Duration
}
Checker records drift for every stack.
func (*Checker) CheckAll ¶
CheckAll runs one pass. A failure on one stack is logged and never stops the others or the loop.
type OpenLive ¶
OpenLive returns a read-only client for live state and a release func the checker calls when the pass is done.
type Store ¶
type Store interface {
ListStacks(ctx context.Context) ([]store.StackRecord, error)
ListStackRevisions(ctx context.Context, stackID string, limit int) ([]store.StackRevisionRecord, error)
GetStackRevision(ctx context.Context, stackID string, number int) (store.StackRevisionRecord, error)
ListStackLedger(ctx context.Context, stackID string) ([]store.StackLedgerEntry, error)
GetStackResourceOwner(ctx context.Context, kind, key string) (store.StackLedgerEntry, bool, error)
SetStackDrift(ctx context.Context, d store.StackDrift) error
}
Store is the store surface the checker uses.