stackdrift

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

View Source
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.

View Source
const (
	ActionChanged      = "changed"
	ActionMissing      = "missing"
	ActionOwnerChanged = "owner_changed"
)

Item actions in a drift summary.

Variables

This section is empty.

Functions

func IntervalFromEnv

func IntervalFromEnv() time.Duration

IntervalFromEnv reads APP_STACK_DRIFT_INTERVAL; 0 disables the loop and an unset or invalid value falls back to the default.

func Summarize

func Summarize(p iac.Plan, limit int) []store.StackDriftItem

Summarize reduces a plan to drift items: field paths only, never the old or new values, so env, labels and commands stay hidden. At most max items.

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
}

Checker records drift for every stack.

func (*Checker) CheckAll

func (c *Checker) CheckAll(ctx context.Context)

CheckAll runs one pass. A failure on one stack is logged and never stops the others or the loop.

func (*Checker) Run

func (c *Checker) Run(ctx context.Context, interval time.Duration)

Run checks every interval until ctx ends. Interval <= 0 returns at once.

type OpenLive

type OpenLive func(ctx context.Context) (iac.Doer, func(), error)

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.

Jump to

Keyboard shortcuts

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