matrix

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package matrix is the env × family screen: one row per family, one column per env, the family's image tag in each cell with its state spelled out — pinned, unpinned, split, external, drifted — as a word an operator can read without a legend. cells.go derives the cell values from a discovered repo (and, when the cluster has answered, from what each env is actually running) with no terminal dependency; model.go lays them out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstPartyRepos

func FirstPartyRepos(fam *gitops.Family, promotable []string) []string

FirstPartyRepos lists, sorted, the distinct first-party image repos a family runs in one env — what d offers to deploy: one opens the picker directly, several open a chooser first.

Types

type Cell

type Cell struct {
	// Present is false when the family has no Application in this env; the other fields
	// are then zero and String renders blank.
	Present bool
	// Text is the tag shown: the single first-party tag, "N images" when the family's
	// first-party occurrences span N image repos, or "N versions" when one image repo runs
	// under N references inside the env. A third-party-only family shows the same for its
	// third-party images.
	Text string
	// State is the word beside Text; "" for a present cell with no images at all.
	State State
	// Pinned: every first-party occurrence carries a digest.
	Pinned bool
	// Differs: the set of refs differs from the previous env column's. Never set on the
	// first column or when the previous column is blank. Kept as data for a caller that
	// wants to colour a change across columns; it is no longer a glyph.
	Differs bool
	// ThirdParty: the family has no first-party image at all.
	ThirdParty bool
	// Running is what the cluster reports for a drifted cell — the tag, or a short digest —
	// for the sentence under the table ("marketing runs sha-77c0ffe here; manifest says …").
	// Empty unless State is StateDrifted.
	Running string
	// contains filtered or unexported fields
}

Cell is one family × env intersection.

func (Cell) String

func (c Cell) String() string

String is the cell as the table shows it: text, two spaces, state — or blank when absent. The table aligns the state to the right of the column itself (see rows in model.go); this is the unaligned form for tests and logs.

type DriftFunc

type DriftFunc func(ctx context.Context, env string) (map[string]image.Ref, error)

DriftFunc reports what one env's cluster is running, keyed by image repo — the pod digests hoist already resolves for a plan, asked for per env at boot so the matrix can say "drifted" where the manifest and the cluster disagree. nil means no cluster is configured and no cell is ever claimed drifted (nor not drifted). The root builds it from the same resolve function the plan screen uses (AGENTS.md §4.8: this package takes a function value, never an adaptor).

type DriftMsg

type DriftMsg struct {
	// contains filtered or unexported fields
}

DriftMsg is one env's answer. gen is the refresh generation it belongs to, so a slow answer from before a refresh (F5) or a previous instance of this screen is dropped rather than painting stale drift over a newer answer.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the matrix screen. It is a value: Update, SetSize and SetStyles return the updated model.

func New

func New(repo *gitops.Repo, promotable []string, envs config.EnvsConfig, drift DriftFunc) Model

New builds the screen for a discovered repo. promotable lists the first-party image repo prefixes (see Compute). envs is the repo's policy (which envs are production — marked in the header and named in the footer, since this is the one screen where an operator chooses an env and until M10 the one place that fact was absent, #86). drift is how the cluster is asked what each env runs; nil never asks. The model has no size until SetSize is called.

func (Model) CapturesText

func (m Model) CapturesText() bool

CapturesText reports whether the image chooser is open: its "/" filter takes letters, and the root's q-to-quit must not fire over it.

func (Model) CurrentEnv

func (m Model) CurrentEnv() string

CurrentEnv is the env the column cursor is on, "" when the repo has none.

func (Model) CurrentFamily

func (m Model) CurrentFamily() string

CurrentFamily is the family the row cursor is on, "" when the matrix has no rows.

func (Model) Cursor

func (m Model) Cursor() int

Cursor is the index of the selected family row.

func (Model) InFlight

func (m Model) InFlight() []flight.Summary

InFlight is what the pane currently shows.

func (Model) Init

func (m Model) Init() tea.Cmd

Init asks the cluster what every env is running, one command per env, when a DriftFunc was supplied. The table is already drawn from the manifests; each answer refines its column when it lands.

func (Model) IsProduction

func (m Model) IsProduction(env string) bool

IsProduction reports whether env is listed in envs.production.

func (Model) Matrix

func (m Model) Matrix() Table

Matrix is the computed matrix the screen shows.

func (Model) SetInFlight

func (m Model) SetInFlight(list []flight.Summary, err error) Model

SetInFlight replaces what the pane shows. err is the listing's own failure (the state directory unreadable), shown in the pane's place; a per-promotion re-observation failure travels inside its Summary.

func (Model) SetSize

func (m Model) SetSize(width, height int) Model

SetSize fits the table to a width × height terminal.

func (Model) SetStyles

func (m Model) SetStyles(s ui.Styles) Model

SetStyles applies a palette to the table, the help line and the status bar.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update handles the screen's keys and forwards the rest to the table. Quit is the root's.

func (Model) View

func (m Model) View() string

View renders the frame: the table, the notes, the in-flight pane and the footer, with a chooser dialog over it when one is open — or the too-small line.

func (Model) WithDrift

func (m Model) WithDrift(drift DriftFunc) Model

WithDrift replaces the cluster-asking function New was given — the root uses it to hand the matrix a pods-only resolver built after New.

func (Model) WithNotice

func (m Model) WithNotice(notice string) Model

WithNotice sets the notice shown under the table — exported so the root can surface an honest message on the matrix after popping back to it from another screen whose own message it chose not to act on.

func (Model) WithNow

func (m Model) WithNow(now func() time.Time) Model

WithNow fixes the clock the pane ages promotions with (tests); the default is time.Now.

type OpenPlanMsg

type OpenPlanMsg struct {
	Source string
	Force  bool
}

OpenPlanMsg is emitted when the operator asks to plan a promotion from CurrentEnv: p asks for the configured pair (envs.pairs[Source] — the root looks it up), P (Force) always prompts for the target instead. The root recognizes this by concrete type in its own Update switch (see internal/app/screen.go).

type OpenRestartMsg

type OpenRestartMsg struct {
	Family, Target string
}

OpenRestartMsg is emitted when the operator asks to restart the family under the cursor in CurrentEnv (R). It names a family rather than an image because a restart changes no image: what it rolls is every Deployment that family declares, which is the unit an Argo Application already covers and therefore the unit the rollout is watched at.

type OpenTagsMsg

type OpenTagsMsg struct {
	ImageRepo, Target string
}

OpenTagsMsg is emitted when the operator asks to pick a new tag for the current cell (d, "deploy image" — the tag picker, internal/app/tags). ImageRepo is the one first-party image repo the family runs in CurrentEnv, or the one the operator chose when there were several.

type ResumeMsg

type ResumeMsg struct {
	ID string
}

ResumeMsg asks the root to re-drive one in-flight promotion on the flight screen (r, or enter on the pane) — the TUI's `hoist resume <id>`.

type Row

type Row struct {
	Family string
	Cells  []Cell
}

Row is one family across every env; Cells is aligned with Table.Envs.

type Running

type Running map[string]map[string]image.Ref

Running is what each env's cluster is actually running, keyed env → image repo → the running reference (tag and digest as the pod reports them). nil, or a missing env, means the cluster has not answered for that env — no cell there can be drifted, and none is claimed not to be.

type State

type State string

State is the one word a cell shows beside its tag. Colour reinforces it; it never replaces it (docs/tui/mockups.html: "state is a word, not a glyph").

const (
	// StatePinned means every first-party occurrence carries a digest.
	StatePinned State = "pinned"
	// StateUnpinned means at least one first-party occurrence is a bare tag — a moved tag is
	// invisible to imagePullPolicy: IfNotPresent (AGENTS.md principle 3).
	StateUnpinned State = "unpinned"
	// StateSplit means one image repo runs under more than one reference inside the env — the
	// condition the runbook blocks a promotion on, so it should look like a problem.
	StateSplit State = "split"
	// StateExternal means the family has no first-party image at all.
	StateExternal State = "external"
	// StateDrifted means the cluster runs a build the manifest does not declare. The single most
	// important fact on the screen when it is true, so it gets a sentence under the table too.
	StateDrifted State = "drifted"
)

type Table

type Table struct {
	Envs []string
	Rows []Row
}

Table is the whole matrix: envs sorted by name, families sorted by name (the union across envs).

func Compute

func Compute(r *gitops.Repo, promotable []string, running Running) Table

Compute derives the matrix from a discovered repo. promotable lists the image repo prefixes that count as first-party (what hoist plan --promotable takes); an occurrence matching none is third-party. running may be nil.

Jump to

Keyboard shortcuts

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