Documentation
¶
Overview ¶
Package cockpitrun owns Cockpit open/export operations without CLI dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 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 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 ¶
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).