Documentation
¶
Overview ¶
Package server is the upgradescope continuous-mode server: snapshot ingest, persisted evaluations, a read API, and on-demand what-if re-evaluation. Storage is behind store.Store; the CLI owns flag parsing and store construction (DB path never reaches this package).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeDelta ¶
ComputeDelta implements the notification delta rules (shared contract):
- prev == nil (first-ever evaluation of this cluster+target) → no events.
- Blocker findings added since prev (diff by stable finding key) → one new-blocker event each, capped at maxBlockerEvents, then a single "and N more".
- Blocker count went >0 → 0 → one became-ready event.
- eol-approaching warnings added since prev (by key) → one event each.
Identity is Finding.Key — deliberately count-free, so a title-only change ("3 objects" → "2 objects") never re-alerts the same blocker. Findings with an empty Key (reports stored before Key existed) fall back to Title. Duplicate keys within one report emit one event (first occurrence wins).
Event.Cluster is filled with curr.ClusterID (the inventory UID); the caller (notifyDelta) overwrites it with the human cluster name from the push envelope before delivery. Order is deterministic: new-blockers in report order, summary, became-ready, eol-approaching in report order.
func WhatIf ¶
func WhatIf(ctx context.Context, st store.Store, k kb.KB, tm TeamMap, clusterID int64, target inventory.Version, now time.Time) (engine.Report, error)
WhatIf re-evaluates a cluster's latest stored snapshot against an arbitrary target using the server's KB. Nothing is stored. now is injected by the caller (the server passes s.now()) so EOL-window math stays deterministic and testable. tm (nil = no-op) applies the server's namespace→team override, matching what evaluateSnapshot stores. Returns store.ErrNotFound (wrapped) when the cluster has no snapshots.
Types ¶
type Config ¶
type Config struct {
Listen string // listen address for Start, e.g. ":8080"
Store store.Store // required
KB kb.KB // evaluation knowledge base
ExtraTargets []string // minors evaluated for every snapshot, e.g. ["1.37"]
Notifier notify.Notifier // nil = notifications disabled
IngestToken string // required bearer for POST /api/v1/snapshots
ReadToken string // optional bearer for the read API; "" = open (document loudly)
TeamMap TeamMap // optional namespace→team override, applied before every Evaluate
Version string // build version stamped into SARIF tool metadata ("" = omitted)
}
Config wires a Server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves the ingest + read API. Construct with New; a Server is single-use (one Start/Shutdown cycle).
func (*Server) Handler ¶
Handler exposes the full route table (API + dashboard fallback) for httptest and embedding.
func (*Server) Ready ¶
func (s *Server) Ready() <-chan struct{}
Ready is closed once the listener is bound. It is NEVER closed when Listen fails — Start just returns the error — so callers must not block on Ready alone: run Start in a goroutine and select on Ready() AND the goroutine's error channel, or a bad Listen address hangs the caller.
type TeamMap ¶
type TeamMap []TeamMapRule
TeamMap is the server-side namespace→team override (spec: labels + server override). It is applied over the namespace team labels carried in the inventory at evaluation time — a matching rule replaces the label; a namespace matching no rule keeps its label. A nil/empty TeamMap is a no-op.
func LoadTeamMap ¶
LoadTeamMap reads and parses a --team-map YAML file.
func ParseTeamMap ¶
ParseTeamMap parses YAML of the form:
- pattern: "payments-*" team: payments
Every rule must have a non-empty pattern (valid path.Match glob) and team.
func (TeamMap) Apply ¶
func (m TeamMap) Apply(ns []inventory.NamespaceInfo) []inventory.NamespaceInfo
Apply returns a rewritten copy of ns: for each namespace, the first rule whose glob matches sets the team; no match keeps the inventory label. The input slice is never mutated (it may alias a caller's inventory).
type TeamMapRule ¶
TeamMapRule maps namespaces matching a glob Pattern (path.Match grammar) to Team. Rules are ordered; the first matching pattern wins.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package notify defines the notification seam fired on finding deltas (new blocker, became-ready, add-on entering the EOL window) — never on every snapshot.
|
Package notify defines the notification seam fired on finding deltas (new blocker, became-ready, add-on entering the EOL window) — never on every snapshot. |
|
Package store persists clusters, snapshots and evaluations for the upgradescope server.
|
Package store persists clusters, snapshots and evaluations for the upgradescope server. |
|
storetest
Package storetest pins the behavioral contract of store.Store.
|
Package storetest pins the behavioral contract of store.Store. |