dashboard

package
v0.182.6 Latest Latest
Warning

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

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

Documentation

Overview

Package dashboard serves the daemon's loopback listener: the read-only JSON API, the redirect from the root to Cockpit, and the mounted subtrees (Cockpit and the hub). Its server-rendered operations pages are retired.

Index

Constants

View Source
const APISchemaVersion = 1
View Source
const Policy = "" /* 151-byte string literal not displayed */

Policy is the Content-Security-Policy of every response of the dashboard listener that does not set its own.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(options Options) http.Handler

NewHandler returns the daemon listener's versioned read-only API, the redirect from its root to Cockpit, and every mounted subtree (Cockpit and the hub).

Types

type HubDeliveryMarker added in v0.124.6

type HubDeliveryMarker struct {
	ID         string    `json:"id,omitempty"`
	Event      string    `json:"event,omitempty"`
	OccurredAt time.Time `json:"occurred_at"`
}

HubDeliveryMarker names one repository event and when the hub handled it.

type HubHealth added in v0.124.6

type HubHealth struct {
	Mounted               bool               `json:"mounted"`
	Polling               bool               `json:"polling"`
	PollIntervalSeconds   float64            `json:"poll_interval_seconds,omitempty"`
	RepositoriesPolled    int                `json:"repositories_polled"`
	LastEventReceived     *HubDeliveryMarker `json:"last_event_received,omitempty"`
	LastEventAcknowledged *HubDeliveryMarker `json:"last_event_acknowledged,omitempty"`
	// WebhookRedelivery is the missed-webhook recovery sweep's last completed
	// pass, or nil without a configured GitHub App.
	WebhookRedelivery *HubRedeliverySweep `json:"webhook_redelivery,omitempty"`
}

HubHealth is the self-hosted bench hub's live state, as /api/v1/health reports it. Every field is derived from the hub's own services; none of it is a secret.

type HubRedeliverySweep added in v0.147.0

type HubRedeliverySweep struct {
	LastSweepAt *time.Time `json:"last_sweep_at,omitempty"`
	Redelivered int        `json:"redelivered"`
	Abandoned   int        `json:"abandoned"`
	// Uncounted is how many redeliver calls the last pass made without
	// evidence the operator's endpoint is answering at all, so they were not
	// spent against the 3-attempt limit. A sustained non-zero value is what
	// makes an ongoing outage visible even though nothing is being
	// abandoned for it.
	Uncounted int `json:"uncounted"`
	// LastFailureAt and LastFailureClass are sticky: they report the most
	// recent failure even after a later sweep succeeds, so an operator can
	// tell "this has failed before" from a snapshot taken well afterward.
	LastFailureAt    *time.Time `json:"last_failure_at,omitempty"`
	LastFailureClass string     `json:"last_failure_class,omitempty"`
}

HubRedeliverySweep is the missed-webhook recovery sweep's last completed pass, as /api/v1/health reports it. LastSweepAt and LastFailureAt are pointers so JSON omits them before anything has happened yet, rather than rendering the zero time; a non-pointer time.Time's zero value is not what encoding/json's omitempty treats as empty.

type Options

type Options struct {
	Version             string
	DaemonPID           int
	SchedulerGeneration uint64
	// Home is the path the listener's bare address redirects to: Cockpit's
	// mount, which the daemon fills in. It is a field rather than an import
	// because the Cockpit web package's own tests build this handler. Empty
	// leaves the root unrouted, a 404.
	Home string
	// Mounts attaches extra subtrees to the same loopback listener, keyed by
	// the path prefix each one owns (it must start and end with "/"). A
	// self-hosted bench uses it for the hub API under /v0/workbench/ and the
	// embedded dashboard under /workbench/; without a hub section the map is
	// empty and the served routes are exactly what they were.
	Mounts map[string]http.Handler
	// Hub reports the live state of a self-hosted bench hub for
	// /api/v1/health. `wb daemon status` runs in a different process from
	// `wb daemon serve`, so the numbers only this process knows — how many
	// repositories the last poll tick read, and the delivery markers the hub's
	// own StatusService resolves — reach it through the health endpoint rather
	// than by opening the hub's store a second time. Nil when there is no hub.
	Hub func(context.Context) HubHealth
	// LogPath is the daemon's own runtime log file. When set, /api/v1/log
	// serves a tail of it to the owner — the daemon is the log's only
	// authority, so a reverse proxy in front of it never needs disk access of
	// its own. Empty disables the endpoint (503, to the owner only).
	LogPath string
	// Owner reports whether a request acts as the owner principal. It is the
	// seam the daemon fills with Cockpit's own session check
	// (cockpit.Server.IsOwner), so this package neither imports Cockpit nor
	// has a second authentication mechanism. The log is file content, and
	// file content is the owner's alone (cockpit#req:daemon-log-is-owner-only):
	// with no Owner the log route refuses every request.
	Owner func(*http.Request) bool
	// Peers serves /api/v1/peers and /api/v1/peers/{id}
	// (peer-connectivity#req:peers-api's "mounted...on every node"). The
	// caller always supplies one, backed by an empty-list source when this
	// daemon has no hub mounted, so a laptop-only install answers "no
	// downstream peers" instead of answering 404.
	// A nil value leaves the route unmounted (404) purely as a defensive
	// default; every real caller sets it.
	Peers http.Handler
}

Jump to

Keyboard shortcuts

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