Documentation
¶
Overview ¶
Package drift detects cluster drift: changes made to live resources outside of Deployah that Deployah's own spec-edit plan would not otherwise report.
Client predicts each resource via a server-side apply dry-run and fetches its live state. ComputeDrift diffs the two with deployah.dev/deployah/internal/plan.ComputeDiff and subtracts every field path already explained by the spec-edit plan, so only changes the cluster picked up on its own remain. This backs `deployah plan --drift`:
A = diff(render, last successful release) # the spec edit B = diff(predicted, live) # total delta drift = B minus paths(A) # per resource, per field path
Index ¶
Constants ¶
const FieldManager = "deployah"
FieldManager is the field manager name every drift dry-run PATCH is sent with. It matches the field manager Deployah's real applies use, so a prediction reflects Deployah's own ownership, not a foreign manager's.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the production Predictor, talking to a real Kubernetes API server through a dynamic client and a discovery-backed REST mapper.
type Predictor ¶
type Predictor interface {
// Predict returns the predicted and live YAML for the single resource
// described by resourceYAML. live is "" with a nil error when the
// resource does not exist yet (not a failure).
Predict(ctx context.Context, resourceYAML string) (predicted, live string, err error)
}
Predictor predicts a resource's post-apply state via a server-side apply dry-run and fetches its current live state. Client is the production implementation; tests substitute a stub to exercise ComputeDrift's subtraction logic without a cluster.
type Result ¶
type Result struct {
// Changes lists per-resource drift: fields that differ between the
// predicted apply and the resource's live state, but were not already
// part of the spec-edit diff in the plan passed to [ComputeDrift].
Changes []planengine.Change
// Incomplete lists resource labels ("Kind/name" or
// "Kind/namespace/name") that drift could not be checked for, e.g.
// because of missing RBAC. A non-empty Incomplete means the plan is
// partial and must say so rather than silently omit those resources.
Incomplete []string
}
Result is the output of ComputeDrift.
func ComputeDrift ¶
func ComputeDrift(ctx context.Context, predictor Predictor, specPlan *planengine.Plan, currentManifest string) (*Result, error)
ComputeDrift predicts each resource in currentManifest via predictor and compares it against live state, subtracting field paths already explained by specPlan.Changes so only changes the cluster picked up outside of Deployah remain. On a fresh install (specPlan.Header.FreshInstall) it short-circuits to an empty, complete Result: there is no live baseline to compare against.