advanceddrift

package
v0.46.7 Latest Latest
Warning

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

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

Documentation

Overview

Package advanceddrift detects drift per Terramate stack of the local host (ADR-0045 section 2 and section 3, docs/ARCHITECTURE.md "Advanced drift per stack (Stage 1)").

Stack-level drift is what `tofu plan -detailed-exitcode` sees in each OpenTofu root. Container state that changes outside OpenTofu stays invisible to that plan; the native container drift detection of `stackkit drift detect` keeps covering it (ADR-0045 section 5), and the drift report combines both.

Index

Constants

View Source
const (
	StackConverged   = terramatehost.StackConverged
	StackDrifted     = terramatehost.StackDrifted
	StackFailed      = terramatehost.StackFailed
	StackPendingRoot = terramatehost.StackPendingRoot
)

Per-stack statuses.

View Source
const (
	StatusClean   = "clean"
	StatusDrifted = "drifted"
	StatusUnknown = "unknown"
)

Overall statuses of a drift report that carries stacks.

View Source
const EventPhase = "advanced.drift.stack"

EventPhase is the rollout event phase emitted once per stack, so Techstack can stream one drift subject per stack.

Variables

This section is empty.

Functions

func EventAttributes

func EventAttributes(stack Stack) map[string]string

EventAttributes are the rollout event attributes of one stack entry.

func OverallStatus

func OverallStatus(nativeDrift bool, stacks []Stack) string

OverallStatus combines native drift and the stack entries: drifted when the native report or any stack drifted, otherwise unknown when any stack failed or a required root is pending, otherwise clean.

func Required

func Required(role string) bool

Required reports whether a pending_root stack prevents a clean report. Core and workload roots must exist; edge and federation roots are not materialized by the executor yet.

Types

type Request

type Request struct {
	WorkspaceRoot string
	Layout        terramatehost.Layout
	Tools         terramatehost.Tools
	// ToolsErr reports that the packaged binaries are unavailable; every
	// stack is then failed without any process run.
	ToolsErr error
	Timeout  time.Duration
	// Event receives every finished stack entry in run order.
	Event func(Stack)
}

Request is one per-stack drift detection over the local host project.

type Stack

type Stack struct {
	StackID      string   `json:"stackId"`
	Role         string   `json:"role"`
	ModuleRef    string   `json:"moduleRef"`
	SiteRef      string   `json:"siteRef"`
	NodeRef      string   `json:"nodeRef"`
	RuntimeRoot  string   `json:"runtimeRoot"`
	Status       string   `json:"status"`
	PlanExitCode *int     `json:"planExitCode,omitempty"`
	Summary      *Summary `json:"summary,omitempty"`
	DurationMS   int64    `json:"durationMs"`
	Detail       string   `json:"detail,omitempty"`
}

Stack is one `stacks[]` entry of `stackkit.drift-report/v1`.

func Detect

func Detect(ctx context.Context, request Request) ([]Stack, error)

Detect plans every stack of the local host in run order and never applies. A missing core root leaves the host project unmaterialized and reports every local stack as pending_root. An error is returned only for an invalid request; stack-level failures are entries with status failed.

type Summary

type Summary struct {
	Add     int `json:"add"`
	Change  int `json:"change"`
	Destroy int `json:"destroy"`
}

Summary is the resource count of a plan's `Plan: X to add, Y to change, Z to destroy.` line.

func ParseSummary

func ParseSummary(stdout string) *Summary

ParseSummary reads the last `Plan: X to add, Y to change, Z to destroy` line of a plan output. `No changes.` yields a zero summary; any other output yields nil.

Jump to

Keyboard shortcuts

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