graph

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package graph derives a project topology (nodes + edges) from apps and databases. No HTTP and no DB driver: it maps records to cards, so it is trivially unit-testable. It does read the engine registry (internal/databases) for per-engine display facts, the noun a slice wears, its drawer route, rather than keeping a second copy of them here. Edges are inferred the way Railway infers them: a service that references another service's address is connected to it. The references themselves come from the resolver (refs), which knows exactly what each tile reads, the canvas doesn't guess.

Index

Constants

View Source
const (
	ProxyNodeID = "proxy:traefik"
	HostNodeID  = "host:ports"
)

Synthetic node IDs (stable so drag positions persist).

View Source
const (
	// CardW/CardH are the card box. CardGapX/CardGapY are the clear space a
	// placement keeps around one, so two cards never touch.
	CardW    = 220.0
	CardH    = 96.0
	CardGapX = 40.0
	CardGapY = 30.0
	// GridPx is the snap grid, and the dot spacing of the canvas background.
	GridPx = 22
)

The canvas's geometry, declared once. Everything that places or measures a card reads these: the layout engines here, the card box in components/canvas/canvas.templ, and the client (dragging, the no-overlap nudge, the system-column wall), which is handed them as data attributes rather than repeating the numbers. They used to be spelled out in five places, and a Go test was pinned to a JS function by comment to keep two of them honest.

Variables

This section is empty.

Functions

func AddForwards

func AddForwards(g *Graph, fwds []Forward)

AddForwards appends an ephemeral card per relay, placed left of its target tile's card with an edge to it. Runs after Build (and after autoLayout): these cards take no node_positions row and are not draggable, so their position is always derived from the target's. A forward into a tile with no card of its own (a sliced instance) still gets a card, parked at the left margin with no edge.

func AppNodeID

func AppNodeID(id string) string

AppNodeID / DBNodeID build the stable node identifiers.

func ApplyPlacement

func ApplyPlacement(g *Graph, byTile map[string]TileTasks, multiNode bool)

ApplyPlacement fills in the node chip, the replica roll-up and any move in flight. multiNode is false on a one-node swarm, and then no chip is drawn at all, a single-node install looks exactly as it did before any of this.

func ConnectorNodeID

func ConnectorNodeID(id string) string

func DBNodeID

func DBNodeID(id string) string

func EnvNodeID

func EnvNodeID(slug string) string

EnvNodeID is the stable node id for an environment card. Slug-based like the tile ids, so a rebuilt environment keeps its place on the canvas.

func ForwardNodeID

func ForwardNodeID(tileID string, port int) string

ForwardNodeID is stable per (tile, port) so a poll can diff cards by id.

func MapTile

func MapTile(nodeOf map[string]string, tileID, node string)

MapTile points both sampler spellings of a tile at the same card. The sampler keys a tile "app:<id>" or "db:<id>" depending on repo.Tile.IsManaged, and a canvas rollup has no reason to re-derive that: claiming both is cheap and keeps a reclassified tile from silently losing its lane.

func MarkRunning

func MarkRunning(g *Graph, open []repo.CronRun)

MarkRunning overwrites the last-run line on the cron and function cards whose tile has a run in flight. A post-pass rather than another Build argument: Build stays a pure function of the rows it is handed, and the runs table is not one of them.

func OrgNodeID

func OrgNodeID(id string) string

OrgNodeID is the root canvas's stable card id. Keyed on the org's UUID rather than its slug: a rename changes the slug, and the card should keep its place.

func RefNodeID

func RefNodeID(instanceID string) string

RefNodeID is the stable node id for a shared-instance reference card.

func ResourceHref

func ResourceHref(kind, providerTileID, name string) string

ResourceHref is the drawer a slice card opens: an engine with its own per-slice UI (an s3 object browser, a postgres data browser scoped to the slice's credentials) gets that; any other slice opens its instance.

func ResourceNodeID

func ResourceNodeID(id string) string

ResourceNodeID is the stable node id for a provisioned logical slice.

func ScopeSuffix

func ScopeSuffix(scopeKind string) string

ScopeSuffix names a tile's sharing scope for card subtitles. The canvas is the one place scope was invisible: an env-only instance and an org-wide one drew identical cards.

func SecretsNodeID

func SecretsNodeID(scope string) string

func SliceDomains

func SliceDomains(kind string, public bool, instanceDomains []string) []string

SliceDomains decides which of the hosting instance's domains a slice card should wear.

Every slice used to inherit them unconditionally, which said two wrong things at once: a private bucket advertised a public hostname, and a postgres logical database showed one even though the engine cannot sit behind an HTTP router at all. Only a publicly-readable slice of an HTTP-speaking engine is actually reachable at the instance's hostname, so only it keeps the chip. The published port is separate and stays, that one is real for every slice.

func StackNodeID

func StackNodeID(slug string) string

StackNodeID / ConnectorNodeID are the org canvas's stable ids.

func TileIDOf

func TileIDOf(nodeID string) string

TileIDOf pulls the tile id back out of a card id, for the card kinds that stand for a tile. "" for everything else (envs, connectors, the host).

func VarsNodeID

func VarsNodeID(scope string) string

VarsNodeID / SecretsNodeID are the stable ids of a scope's two cards. "vars:org" predates the split, so the plain card keeps that id and saved drag positions survive.

func WorstStatus

func WorstStatus(tiles []repo.Tile) string

WorstStatus collapses a group of tiles into the one light its card can show, an environment card standing for its tiles, a stack card for its environments. The most alarming status wins: a crash is what the operator needs to see.

The ranking has to agree with what the card renderers call each status (nodeStatus in components/canvas/canvas.templ, statusSpan in static/js/graph.js), or the same tile reads one way zoomed out and another zoomed in. "done" ranks with "running" for exactly that reason: both render as Online, so a stack of finished cron tiles must not roll up to blank and draw itself "idle".

Volumes are skipped, they have no lifecycle of their own to report.

Types

type ArrangeStyle

type ArrangeStyle string

ArrangeStyle picks the auto-layout engine for cards without a saved position. It lives in the user's graph-prefs blob: the canvas client owns that JSON, the server reads this one key back out of it.

const (
	// ArrangeClusters lays each connected group out as its own island, an
	// app stays beside its databases, buckets and crons. Cards that stitch
	// several islands together (a shared instance) become hubs in their own
	// column. The default: real environments are mostly parallel app-stacks.
	ArrangeClusters ArrangeStyle = "clusters"
	// ArrangeFlow layers cards left to right by edge direction: triggers and
	// ingress first, the services they call next, what those read after.
	ArrangeFlow ArrangeStyle = "flow"
)

func StyleFromPrefs

func StyleFromPrefs(prefs string) ArrangeStyle

StyleFromPrefs reads the arrange key out of a graph-prefs JSON blob. Anything unrecognised (including "") is the default.

type Edge

type Edge struct {
	From string `json:"from"`
	To   string `json:"to"`
	Kind string `json:"kind,omitempty"`
}

Edge connects two nodes. Kind styles the line: "" (app -> db reference), "ingress" (proxy -> app), "port" (host -> db).

type EnvSummary

type EnvSummary struct {
	ID     string
	Slug   string
	Name   string
	Href   string
	Tiles  int
	Status string // worst tile status in the env: error > building > running
	Staged bool   // pending staged changes or a config plan waiting
	Color  string // envcolor CSS value

	// Proxied hostnames of every tile in the env. Non-empty puts the env
	// behind the Traefik card, same as an app one level down.
	Domains []string

	// Stack-scoped instances and out-of-env shared instances the env's tiles
	// provision from. Each becomes an edge to the matching card.
	InstanceIDs []string
	RefIDs      []string

	// Live port-forward relays into this env's tiles (count chip on the card,
	// same rollup idea as DomainCount one level up).
	ForwardCount int
}

EnvSummary is one environment as the stack canvas sees it. The handler does the rollups (it owns the tiles); this package only draws them.

type Forward

type Forward struct {
	TileID string
	Port   int
	Users  []ForwardUser // empty = idling
}

Forward is one live proxyrelay as the env canvas draws it: a tunnel into TileID on Port, with a badge per user who has a forward open.

type ForwardUser

type ForwardUser struct {
	Name   string `json:"name"`
	Role   string `json:"role,omitempty"`
	Avatar string `json:"avatar,omitempty"`
}

ForwardUser is one avatar badge on a forward card. Avatar is a ready URL ("" = initials fallback), resolved by the handler, since this package doesn't know where uploads are served from.

type Graph

type Graph struct {
	Nodes []Node `json:"nodes"`
	Edges []Edge `json:"edges"`
	// Annotations are the canvas's shared notes (text labels, boxes). Loaded by
	// the page handler after Build*, they belong to the canvas, not the
	// topology, so no Build function computes them.
	Annotations []repo.Annotation `json:"annotations,omitempty"`
	// Groups tie cards/annotations together so they move as one. Loaded the
	// same way as Annotations.
	Groups []repo.GraphGroup `json:"groups,omitempty"`
}

Graph is the full topology for a project.

func Build

func Build(apps []repo.Tile, dbs []repo.Tile, resources []repo.ManagedResource, domains map[string][]string, positions map[string][2]float64, rates NetRates, traffic []TrafficPair, refs map[string][]string) Graph

refs maps a consumer tile ID to what it references: tile IDs, and resource IDs for provisioned slices. Edges are drawn only for targets that are nodes on this canvas.

func BuildOrg

func BuildOrg(stacks []StackSummary, instances []OrgInstance, connectors []OrgConnector, vars VarCards, positions map[string][2]float64) Graph

BuildOrg draws one organization: its stacks, the instances they share, the connectors feeding them, and the org's variable and secret cards wired to the stacks that read them.

The org itself is NOT a card here. It used to be one, linking to the settings page, but a card standing for the canvas you are already looking at is a tautology, and it read as an eighth stack. Org administration is a Settings link in the page header instead (handler/org/graph.templ). Deliberately edgeless: the org owns every card here, so one line per stack would say nothing the canvas doesn't already say by containing them.

func BuildOrgs

func BuildOrgs(orgs []OrgSummary, positions map[string][2]float64) Graph

BuildOrgs draws the root canvas: one card per organization the viewer belongs to. Deliberately edgeless, organizations are isolated from each other by definition, so there is nothing to connect. This level is a launcher, and the canvas is here for consistency with every level below (and because the drill-down animation only exists on canvases).

func BuildStack

func BuildStack(envs []EnvSummary, instances []StackInstance, refs []Reference, vars VarCards, positions map[string][2]float64) Graph

BuildStack draws one stack: its environments, the stack-scoped instances they share, ghost cards for shared instances living elsewhere, and the stack's variable and secret cards wired to the environments that read them. Traffic is not built here: the status handler rolls container flows up onto these cards with RollupTraffic.

func (*Graph) AddReferences

func (g *Graph) AddReferences(refs []Reference, positions map[string][2]float64)

AddReferences appends ghost cards for cross-env shared instances plus their edges to local consumers. Called after Build so consumer nodes already have their laid-out positions; each ghost parks just right of its first consumer (saved drag positions win). no force-layout, a secondary card beside its consumer reads clearly and stays a tiny, test-free addition.

func (*Graph) AddVarCards

func (g *Graph) AddVarCards(v VarCards, positions map[string][2]float64)

AddVarCards drops a scope's variable cards onto an already-built graph, the env canvas builds its tile graph first and layers these on, where BuildStack/BuildOrg take the cards as an argument instead.

func (*Graph) Arrange

func (g *Graph) Arrange(style ArrangeStyle, positions map[string][2]float64)

Arrange assigns positions to every node that has no saved one; saved drags always win. Call it after the graph is fully assembled (references, var cards) so every card takes part. Deterministic: same graph, same style, same result.

type NetRates

type NetRates map[string][2]float64 // [rx, tx] bytes/second

Build assembles the graph. positions maps node ID -> (x, y); nodes without a saved position fall back to a deterministic auto-layout so the canvas is never empty-looking on first view. NetRates carries the latest per-tile network sample, keyed by tile ID.

type Node

type Node struct {
	ID     string   `json:"id"` // "app:<uuid>" | "db:<uuid>"
	Kind   NodeKind `json:"kind"`
	Name   string   `json:"name"`
	Detail string   `json:"detail"` // source type / engine
	Status string   `json:"status"`
	// Waiting names the value a deploy stopped for: the config declares it and
	// nobody has set it. Only ever set alongside Status "waiting".
	Waiting string `json:"waiting,omitempty"`

	// Engine is the technology behind the card: the storage engine of a db /
	// slice / ghost ("postgres", "s3", …) or a connector's provider
	// ("github"). Carried separately from Detail so a card can pick its icon
	// without parsing its own subtitle, which is display copy and gets
	// reworded.
	Engine string `json:"engine,omitempty"`

	Href string  `json:"href"`
	X    float64 `json:"x"`
	Y    float64 `json:"y"`

	// Nav marks a card whose Href is a page to open, not a drawer fragment:
	// drilling down a level (env, stack) or leaving the canvas entirely
	// (connectors, the variables card). Kind cannot decide this, connector
	// cards share KindRef with shared-instance ghosts, which do have drawers.
	Nav bool `json:"nav,omitempty"`

	// Position came from a saved drag, not the auto layout. The client uses
	// this to know when a canvas still has never-dragged cards: the first
	// drag then snapshots every position, so autoLayout's "anchor newcomers
	// beside a dragged neighbor" branch only ever fires for genuinely new
	// cards.
	Saved bool `json:"saved,omitempty"`

	// HostAccess marks a tile running privileged or with host devices, worth
	// a badge, because it is the one setting that pierces the container
	// boundary.
	HostAccess bool `json:"hostAccess,omitempty"`

	// UpdateAvailable: the registry watcher has seen a newer image digest
	// than what runs, the card wears a "new version" chip.
	UpdateAvailable bool `json:"updateAvailable,omitempty"`

	// Outside-world exposure: proxied domains (apps) or a published host
	// port (databases). Empty/zero = internal only.
	Domains      []string `json:"domains,omitempty"`
	ExternalPort int      `json:"externalPort,omitempty"`

	// DomainCount stands in for Domains on the org canvas: hostnames belong to
	// tiles, and a stack card that listed every one of them would be a wall of
	// text. The count says "reachable from outside", the level below says how.
	DomainCount int `json:"domainCount,omitempty"`

	// Named volumes mounted by the tile (Railway-style chip on the card).
	Volumes []string `json:"volumes,omitempty"`

	// Subtiles are drawn as tiles stacked under the card, narrower than it:
	// an attached volume under its service, a db's data volume, the managed
	// instance hosting a slice. Purely visual (not nodes, no edges) each
	// with a click-through to its own drawer.
	Subtiles []Subtile `json:"subtiles,omitempty"`

	// Cron cards: preformatted last-run and next-run display lines.
	LastRun string `json:"lastRun,omitempty"`
	NextRun string `json:"nextRun,omitempty"`

	// Live network rates (bytes/second) from the latest metric sample.
	RxBps float64 `json:"rxBps,omitempty"`
	TxBps float64 `json:"txBps,omitempty"`

	// Resource cards: how busy this logical database is and how big it is.
	// Read from the engine per database, not from the wire, bytes on a wire
	// belong to the instance's container and can't be split between slices.
	TxnRate   float64 `json:"txnRate,omitempty"`
	SizeBytes int64   `json:"sizeBytes,omitempty"`

	// Deck is how many layers to draw behind an env/stack card so it reads as
	// a literal stack of what's inside it. Capped at 2 by the builders, the
	// card says "3 tiles" in words, the layers only need to say "several".
	Deck int `json:"deck,omitempty"`

	// UI-staging marker: "pending" (a staged edit) or "delete" (staged for
	// teardown). Empty = no pending change. Set post-build from staged_changes.
	Staged string `json:"staged,omitempty"`

	// Color is the environment's colour as a CSS value (env cards only).
	Color string `json:"color,omitempty"`

	// Ephemeral marks a card that comes and goes without a page change (a
	// forward relay). graph.js excludes these from its node-count reload
	// check and creates/removes them from the status poll instead.
	Ephemeral bool `json:"ephemeral,omitempty"`

	// Forward cards: one badge per user with a forward open. Empty = the
	// relay is idling out its last 60 seconds.
	Forwards []ForwardUser `json:"forwards,omitempty"`

	// ForwardCount stands in for forward cards on the stack and org canvases,
	// the same way DomainCount stands in for Domains: the chip says someone is
	// tunnelled in here, the level below says who.
	ForwardCount int `json:"forwardCount,omitempty"`

	// Placement (docs/plans/32-multi-node-ui.md, canvas). Node is where this
	// card's first replica runs, shown as a chip only when the swarm has more
	// than one node, a single-node install looks exactly as it did. Home is
	// set on a pinned tile, and the chip then carries a house mark: its
	// volume is on that machine's disk and the tile cannot move without the
	// data moving with it.
	Node string `json:"node,omitempty"`
	Home bool   `json:"home,omitempty"`

	// MovingTo is the node a volume move is copying towards, and MovePct how
	// far it has got. The chip reads old to new for the whole move and a thin
	// bar runs along the bottom of the card; the status chip stays whatever it
	// is, because the tile really is still running until the final sync.
	MovingTo string `json:"movingTo,omitempty"`
	MovePct  int    `json:"movePct,omitempty"`

	// Replicas is the roll-up over a stateless tile's tasks: "running · 3/3",
	// or amber "degraded · 2/3" when any replica is failed or starting. Zero
	// means the tile has one replica and the card is simply the tile.
	Replicas Replicas `json:"replicas,omitzero"`
}

Node is one card on the canvas.

type NodeKind

type NodeKind string

NodeKind distinguishes cards on the canvas.

const (
	KindApp      NodeKind = "app"
	KindManaged  NodeKind = "managed"
	KindProxy    NodeKind = "proxy"    // synthetic: the managed Traefik ingress
	KindHost     NodeKind = "host"     // synthetic: ports published on the host
	KindCron     NodeKind = "cron"     // a tile that runs on a schedule
	KindFunction NodeKind = "function" // run-to-completion tile: manual / on-deploy trigger
	KindVolume   NodeKind = "volume"   // persistent storage, stacked under its service
	KindRef      NodeKind = "ref"      // read-only ghost: a shared db instance living in another env
	// KindResource is one logical slice, a database or bucket provisioned out
	// of an instance. It has no container of its own, but it does have its own
	// credentials and its own consumers, so it is its own card: the instance
	// tile is where it lives, not what an app talks to.
	KindResource NodeKind = "resource"
	// Higher-level canvases: one card per environment on a stack graph, one
	// per stack on an org graph, one per organization at the root. Clicking
	// them navigates a level down.
	KindEnv   NodeKind = "env"
	KindStack NodeKind = "stack"
	KindOrg   NodeKind = "org"
	// KindVars is one card standing for a scope's variables, the canvas shows
	// that they exist and links to the editor, it is not an editor itself.
	KindVars NodeKind = "vars"
	// KindConnector is an external integration owned by an org (a GitHub app
	// install). Its own kind so it doesn't inherit the shared-instance card.
	KindConnector NodeKind = "connector"
	// KindForward is a live port-forward relay: one card per proxyrelay
	// container, listing who is tunnelled in. Ephemeral, it exists exactly as
	// long as the container does.
	KindForward NodeKind = "forward"
)

type OrgConnector

type OrgConnector struct {
	ID       string
	Name     string
	Detail   string
	Provider string // "github", picks the card's icon
	Href     string
}

OrgConnector is an external integration owned by the org (a GitHub app install, an S3 destination).

type OrgInstance

type OrgInstance struct {
	ID     string
	Name   string
	Detail string
	Engine string // storage engine, for the card's icon
	Status string
	Href   string

	// How this instance is reachable from outside: proxied hostnames, a
	// published host port, or neither.
	Domains      []string
	ExternalPort int
}

OrgInstance is a tile shared with the whole org (a database everyone provisions from, a singleton service).

type OrgSummary

type OrgSummary struct {
	ID     string
	Name   string
	Slug   string
	Href   string
	Stacks int
	// Nav navigates to Href instead of opening it as a drawer. The root canvas
	// always navigates; the org's own card on its own canvas sets this to reach
	// the settings page.
	Nav     bool
	Members int
	// SetupPending: the wizard is still open, so the org answers nothing but
	// its own setup. Clicking the card is a redirect (owner) or a holding page
	// (everyone else), and a card that says "0 stacks" gives no hint of that.
	SetupPending bool
}

OrgSummary is one organization as the root canvas sees it.

type Reference

type Reference struct {
	InstanceID  string
	Name        string
	Detail      string // e.g. "postgres · managed"
	Engine      string // storage engine, for the card's icon
	Href        string
	ConsumerIDs []string // app tile ids in this env provisioning from it

	// The instance's own outside-world exposure, so a ghost card says as much
	// about reachability as the real card in its home environment.
	Domains      []string
	ExternalPort int
}

Reference is a shared db instance consumed by services in this env but living in another env, shown as a read-only ghost card that links to the instance's real home.

type ReplicaRow

type ReplicaRow struct {
	Slot   int    `json:"slot"`
	State  string `json:"state"`
	Age    string `json:"age"`
	Node   string `json:"node"`
	TaskID string `json:"taskId"`
}

ReplicaRow is one dealt replica under the card.

type Replicas

type Replicas struct {
	// Want is the configured count, Running how many are actually up.
	Want, Running int
	// Rows are replicas 2 and up, in slot order, capped by the canvas.
	Rows []ReplicaRow
	// Hidden is how many did not fit, and HiddenWord summarises them in one
	// word ("all running", "1 starting", "2 failed").
	Hidden     int
	HiddenWord string
}

Replicas is a stateless tile's task roll-up. The card is replica 1; every replica above it is dealt underneath as a subtile.

func (Replicas) Degraded

func (r Replicas) Degraded() bool

Degraded reports whether any replica is not running. Amber, not red: the tile is up, just not all of it.

type StackInstance

type StackInstance struct {
	ID     string
	Name   string
	Detail string // "postgres · stack-scoped"
	Engine string
	Status string
	Href   string

	// How this instance is reachable from outside: proxied hostnames, a
	// published host port, or neither.
	Domains      []string
	ExternalPort int
}

StackInstance is a stack-scoped managed instance: this canvas's resident in the tree, the same way an org-scoped one is a card on the org canvas. Slices and env-scoped instances live one level down, inside the env cards.

type StackSummary

type StackSummary struct {
	ID     string
	Slug   string
	Name   string
	Href   string
	Envs   int
	Status string // worst status across the stack's tiles

	// How many proxied hostnames the stack's tiles serve. > 0 puts it behind
	// the Traefik card; the hostnames themselves live one level down.
	DomainCount int

	// Live port-forward relays into this stack's tiles.
	ForwardCount int

	// Org-shared instances this stack's tiles consume.
	InstanceIDs []string

	// ConfigConnectorID is the connector hosting this stack's config-as-code
	// repo, "" when the stack is not config-managed. SourceConnectorIDs are
	// the connectors its tiles clone service source through. The two say
	// different things, so they are drawn as different lines.
	ConfigConnectorID  string
	SourceConnectorIDs []string
}

StackSummary is one stack as the org canvas sees it.

type Subtile

type Subtile struct {
	Kind   string `json:"kind"` // "volume", or the engine of a managed instance
	Name   string `json:"name"`
	Detail string `json:"detail,omitempty"`
	Href   string `json:"href"` // drawer fragment base; the client opens Href+"/panel"
}

Subtile is one tile stacked under a card: name on the left, detail on the right, an icon picked by Kind ("volume" or an engine name), and the drawer its click opens. One visual component serves every flavour, a sub-tile is a sub-tile, whatever it stands for.

type Task

type Task struct {
	Slot     int
	State    string
	NodeName string
	Started  time.Time
}

Task is one running replica.

type TileTasks

type TileTasks struct {
	// Want is the configured replica count.
	Want int
	// Tasks in slot order.
	Tasks []Task
	// HomeNode is set for a pinned tile: its volume is on that node's disk.
	HomeNode string
	// MovingTo and MovePct describe a volume move in flight.
	MovingTo string
	MovePct  int
}

TileTasks is one tile's tasks as swarm reports them.

type TrafficPair

type TrafficPair struct {
	From string  `json:"from"` // node ID
	To   string  `json:"to"`
	Bps  float64 `json:"bps"`
}

TrafficPair is an observed flow between two graph nodes (conntrack).

func RollupTraffic

func RollupTraffic(pairs map[string]float64, nodeOf map[string]string) []TrafficPair

RollupTraffic maps container-level flows onto a coarser canvas. pairs is the sampler snapshot ("app:<id>|db:<id>" -> bytes/sec); nodeOf renames each endpoint to the card standing for it at this level (a tile to its env card, an env's tiles to their stack card). Endpoints with no card drop out, flows whose ends land on the same card collapse away (an env talking to itself is not a line), and parallel flows sum. The JS side draws a lane only where the pair has an edge, so mapped-but-unconnected pairs cost nothing.

type VarCards

type VarCards struct {
	Scope string // "stack" | "org", the node id suffix
	Label string // card title prefix, e.g. "Organization"
	Href  string // the variables editor; cards open Href+"/panel" in the drawer

	Plain, Secret int // how many variables of each class the scope holds

	// Node ids of the cards that reference at least one variable of each class.
	PlainBy, SecretBy []string
}

VarCards is one scope's pair of variable cards, plain values and secrets, plus the cards that reference them. Two cards rather than one because "who can read this" is the only question the canvas can usefully answer about a variable, and it is the one that splits them.

Only names and counts ever reach the graph: Node is serialized straight to the browser by the canvas status endpoints, so a value must never live here.

Jump to

Keyboard shortcuts

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