cockpitrun

package
v0.182.5 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: 16 Imported by: 0

Documentation

Overview

Package cockpitrun owns Cockpit open/export operations without CLI dependencies.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSessionKey = errors.New("request a cockpit login code: the running daemon is an older wb that issues no Cockpit session key; restart it with `wb daemon restart`, then run `wb cockpit` again")

ErrNoSessionKey is the refusal of a login against a daemon that minted a code and no session key: it is an older wb than this one, still running from before an update, and a session it starts would make the cookie alone an owner (cockpit#req:session-key). Nothing is printed or opened.

Functions

This section is empty.

Types

type ExportDependencies

type ExportDependencies struct {
	// LoadRecord reads this machine's daemon record for a projects root.
	LoadRecord func(root string) (daemon.State, bool, error)
	// Alive reports whether a process id is a running process. On macOS it asks
	// launchd (`launchctl print`, which changes nothing), so a daemon started in
	// the foreground by hand is reported as not running there.
	Alive func(int) bool
	// ProcessStart observes when a process started, to tell the daemon the record
	// was written for from a process that Now holds its recycled id. It reads
	// /proc on Linux and reports false elsewhere.
	ProcessStart func(int) (time.Time, bool)
	// Client is the HTTP Client for the daemon's loopback listener.
	Client func() *http.Client
	Now    func() time.Time
}

ExportDependencies is everything `wb cockpit export` touches. It deliberately has no seam that starts a daemon, mints a login code or opens a browser (cockpit-views#req:cockpit-export-verb): the verb reads the daemon record and makes anonymous loopback reads, and tests prove that no start path is reachable from it (a structural test of this struct and a call-graph test of this file).

func DefaultExportDependencies

func DefaultExportDependencies() ExportDependencies

type ExportFailure

type ExportFailure string

ExportFailure is one of the three typed reasons the verb reports on stdout with exit code 1, or empty for none. It is its code and nothing else: no error text of a dependency, no path and no response body reaches an operator or a pipe.

type ExportRequest

type ExportRequest struct {
	Root        string
	MetricsOnly bool
}

type ExportResult

type ExportResult struct {
	Body    []byte
	Drops   cockpitfleet.ExportDrops
	Failure ExportFailure
}

func Export

func Export(ctx context.Context, deps ExportDependencies, request ExportRequest) ExportResult

cockpitExportEnvelope builds this machine's export envelope from the running daemon's own fleet and machine-metrics routes, read as anonymous-local, and returns it encoded with its trailing newline, and what it left out. It never starts anything and every failure is one of the ExportFailure values. A daemon whose first pass has not ended has a partial fleet, which is not exported: the full export is warming_up until it has (the metrics-only one needs no fleet).

type LocalRequest

type LocalRequest struct {
	Root, Listen string
	Mint         bool
}

type LocalService

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

func NewLocalService

func NewLocalService(deps daemonruntime.Dependencies, login LoginOperation) LocalService

func (LocalService) Local

func (service LocalService) Local(ctx context.Context, request LocalRequest) (LocalSession, error)

cockpitLocalFromDaemon starts or reuses this machine's daemon the way `wb dashboard --local` does and, when mint is set, asks it for a login code on the owner channel (the unix socket behind the owner bearer token).

type LocalSession

type LocalSession struct {
	Listen  string
	Warning string
	Code    string
	Path    string
	Key     string
}

LocalSession is what a local invocation learns from the daemon: its listen address, a non-fatal warning from the start-or-reuse path, and, when one was requested, the login code, the path it is redeemed at and the session key of the session the code starts (cockpit#req:session-key).

type LoginOperation

type LoginOperation func(context.Context, *http.Client) (cockpit.LoginCode, string, error)

Jump to

Keyboard shortcuts

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