model

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package model holds the shared, budget-agnostic intermediate types that flow through the gather → fit → render pipeline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action is the reduced primary-action bucket for a resource change.

const (
	ActionAdd     Action = "add"
	ActionChange  Action = "change"
	ActionDestroy Action = "destroy"
	ActionReplace Action = "replace"
	ActionForget  Action = "forget" // removed from state, real resource kept
	ActionNoop    Action = "noop"   // no config change; carries a move/import annotation
)

func (Action) Mutates added in v0.5.1

func (a Action) Mutates() bool

Mutates reports whether the action changes the real resource (create/update/delete/replace), as opposed to pure state bookkeeping (move/import → noop, and forget) that makes no apply-time provider write and so needs no elevated permission. Classification keys off this: a guard category such as `iam` fires only when the apply actually requires the gated (PAM-granted) write permission, not when a resource is merely moved, imported, or forgotten.

type AttrDiff

type AttrDiff struct {
	Name     string
	Variants []Variant
	Selected int // chosen variant index; fit mutates this
}

AttrDiff is one changed attribute with its ordered variants (index 0 = preferred).

func (AttrDiff) AtLast

func (a AttrDiff) AtLast() bool

AtLast reports whether the selected variant is already the least-detail one.

func (AttrDiff) Sel

func (a AttrDiff) Sel() Variant

Sel returns the currently-selected variant.

type Change

type Change struct {
	Address string
	Type    string
	Action  Action
	Fields  []Field // populated for create/delete/update/replace/forget
	URL     string

	// State operations (annotations on top of Action; Action may be ActionNoop
	// when the only change is a move or import).
	Moved           bool
	PreviousAddress string // old address when Moved
	Imported        bool
	ImportID        string // import id when Imported
}

Change is one resource change within a stack.

type Class

type Class struct {
	Name string
	Icon string // "" when no glyph
}

Class is the classification result for a stack.

func (Class) Label

func (c Class) Label() string

Label renders the class as "icon name" or just "name".

type Counts

type Counts struct {
	Add, Change, Destroy, Replace int
	Move, Import, Forget          int
}

Counts holds per-stack action tallies (pure no-ops excluded). Move/Import/ Forget are tracked separately from the create/change/destroy/replace buckets.

func (Counts) AnyChange

func (c Counts) AnyChange() bool

AnyChange reports whether the stack has anything worth rendering — a config change, or a move / import / forget.

func (Counts) Total

func (c Counts) Total() int

Total returns the sum of the create/change/destroy/replace buckets.

type Field added in v0.2.0

type Field struct {
	Name     string
	Kind     string    // "json"/"yaml" for structured blocks; "" otherwise
	Leaves   []Leaf    // inline rows; empty when this is a block
	Variants []Variant // block ladder; empty when this is leaves
	Selected int       // chosen variant (block only); fit mutates
}

Field is one top-level attribute of a resource change. It renders either as aligned Leaves (scalars, small structural diffs, sensitive/unknown) or, when large, as a foldable block carrying the Variant ladder fit degrades.

func (Field) AtLast added in v0.2.0

func (f Field) AtLast() bool

AtLast reports whether the selected block variant is the least-detail one.

func (Field) IsBlock added in v0.2.0

func (f Field) IsBlock() bool

IsBlock reports whether this field renders as a foldable block.

func (Field) Sel added in v0.2.0

func (f Field) Sel() Variant

Sel returns the selected block variant (block fields only).

type Leaf added in v0.2.0

type Leaf struct {
	Op     LeafOp
	Path   string // dotted, includes the attribute name (e.g. "labels.team")
	Old    string // rendered scalar; used for change/remove
	New    string // rendered scalar; used for add/change
	Inline string // when set, rendered verbatim instead of Old/New (e.g. "(sensitive value)")
}

Leaf is one aligned `op path = value` row.

func (Leaf) Value added in v0.2.0

func (l Leaf) Value() string

Value returns the right-hand side of the `=`.

type LeafOp added in v0.2.0

type LeafOp uint8

LeafOp is the change kind for a single leaf attribute path.

const (
	OpAdd    LeafOp = iota // added leaf
	OpChange               // changed leaf
	OpRemove               // removed leaf
)

func (LeafOp) Sym added in v0.2.0

func (o LeafOp) Sym() string

Sym returns the diff prefix for the op (+, ~, -).

type Level

type Level string

Level identifies a render variant, ordered most → least detail.

const (
	LevelInline     Level = "inline"     // scalar / sensitive / known-after-apply
	LevelStructural Level = "structural" // changed paths only
	LevelLineDiff   Level = "linediff"   // unified line diff
	LevelSummary    Level = "summary"    // magnitude only
	LevelHidden     Level = "hidden"     // omitted
)
type Link struct {
	Label string
	URL   string
}

Link is a labelled report-header link.

type RenderMode

type RenderMode int

RenderMode is the terminal-cascade level chosen by fit.

const (
	ModeFull        RenderMode = iota // table + per-stack details
	ModeSummaryOnly                   // table + notice, no details
	ModeMinimal                       // one-line aggregate + notice
)

type Report

type Report struct {
	Title       string
	Marker      string
	Classified  bool  // whether to show the Categories column
	Default     Class // fallback badge shown for a stack that matched no category
	Stacks      []Stack
	Mode        RenderMode
	Notice      string // cascade notice (set by fit when degrading)
	DetailsOpen bool   // render <details open> when true
	HeaderLinks []Link
}

Report is the complete intermediate model.

type Stack

type Stack struct {
	Name       string
	URL        string
	Counts     Counts
	Categories []Class // matched categories in rule order; empty → render the default
	Changes    []Change
}

Stack is one stack's parsed, classified plan.

type Variant

type Variant struct {
	Level   Level
	Content string // markdown fragment (lines inside the “`diff block)
	Bytes   int    // len(Content); used by fit for largest-first selection
}

Variant is one possible rendering of a single attribute diff.

Jump to

Keyboard shortcuts

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