Documentation
¶
Overview ¶
Package app is the hive CLI's composition root: the engine services plus the pieces only the CLI has (plugins, the command set, sources, its config).
Index ¶
- Variables
- func BuildSourceRegistry(logger zerolog.Logger, cfg *config.Config, exec cliengine.Executor, ...) *sources.Registry
- type App
- func (a *App) AttachServerSession(ctx context.Context, serverName string, sess session.Session) error
- func (a *App) DaemonClient(autoStart bool) *daemonclient.Client
- func (a *App) DefaultServer() string
- func (a *App) ServerAPI(name string) (sessionapi.API, error)
- func (a *App) SessionAPI() sessionapi.API
- func (a *App) StartServerSession(ctx context.Context, serverName string, sess session.Session) (server.Host, error)
- func (a *App) TargetServer(name string) error
- func (a *App) TargetsServer() bool
- type BuildInfo
- type Multiplexer
Constants ¶
This section is empty.
Variables ¶
var ErrSessionCompleted = errors.New("the session's commands finished, so it has no terminal to attach to")
ErrSessionCompleted is a session whose commands all finished, so it left no terminal to attach to.
Functions ¶
func BuildSourceRegistry ¶
func BuildSourceRegistry(logger zerolog.Logger, cfg *config.Config, exec cliengine.Executor, kvStore kv.KV) *sources.Registry
BuildSourceRegistry constructs the sources.Registry from cfg, registering a per-backend source for each enabled builtin. Registration failures are logged and the offending entry is skipped rather than failing startup.
Types ¶
type App ¶
type App struct {
*hive.Engine
// Logger carries no cmp label. A command or component adds its own.
Logger zerolog.Logger
// Config is the CLI config. It shadows Engine.Config, and its embedded
// engine half is the config the engine was built from.
Config *config.Config
// ConfigPath is the config file the CLI loaded, which a daemon it starts
// must load too.
ConfigPath string
Doctor *doctor.Service
Multiplexer Multiplexer
Plugins *plugins.Manager
CommandSet *plugins.CommandSet
Build BuildInfo
Sources *sources.Registry
// Servers is the local session API and each server under servers:.
Servers *servers.Fleet
// contains filtered or unexported fields
}
App is the central entry point for all hive operations. It embeds the engine, whose accessors (Sessions, Messages, HC, ...) commands and the TUI call per use, and adds what only the CLI has.
func NewApp ¶
func NewApp( logger zerolog.Logger, engine *hive.Engine, cfg *config.Config, multiplexer Multiplexer, pluginMgr *plugins.Manager, commandSet *plugins.CommandSet, pluginInfos []doctor.PluginInfo, configPath string, ) *App
NewApp wraps an engine built from &cfg.Config with the CLI pieces. Doctor validates the whole CLI config, so `hive doctor` keeps reporting errors in sections only the CLI reads.
func (*App) AttachServerSession ¶ added in v0.69.0
func (a *App) AttachServerSession(ctx context.Context, serverName string, sess session.Session) error
AttachServerSession starts sess on the named server and attaches to it: in a new window inside tmux, so the caller keeps its own, and on this terminal outside it.
func (*App) DaemonClient ¶ added in v0.68.0
func (a *App) DaemonClient(autoStart bool) *daemonclient.Client
DaemonClient reaches the daemon for this data directory. It needs only the logger, the config, and ConfigPath, so commands that skip the engine can call it. With autoStart, a dial that finds no daemon starts this binary as one.
func (*App) DefaultServer ¶ added in v0.68.0
DefaultServer is the server that SessionAPI reaches and that a bare session id names: the --server server, else session.LocalServer.
func (*App) ServerAPI ¶ added in v0.68.0
func (a *App) ServerAPI(name string) (sessionapi.API, error)
ServerAPI is the session API of the named server; session.LocalServer names this machine.
func (*App) SessionAPI ¶ added in v0.68.0
func (a *App) SessionAPI() sessionapi.API
SessionAPI is the path for session writes, session reads, and session-view status: the daemon when experimental.daemon is on, else this process's engine. Tmux-only helpers and git reads stay on Sessions().
func (*App) StartServerSession ¶ added in v0.69.0
func (a *App) StartServerSession(ctx context.Context, serverName string, sess session.Session) (server.Host, error)
StartServerSession makes sure the tmux session of sess on the named server runs, by the server's rules, and returns the ssh target to attach with.
func (*App) TargetServer ¶ added in v0.68.0
TargetServer points SessionAPI at the daemon on a server under servers:, so session commands act on that server's sessions instead of local ones. session.LocalServer keeps the local sessions.
func (*App) TargetsServer ¶ added in v0.68.0
TargetsServer reports whether SessionAPI reaches a server, where paths and tmux sessions on this machine mean nothing.
type Multiplexer ¶
type Multiplexer interface {
sessionsvc.Multiplexer
terminal.PaneSource
ResolveTarget(ctx context.Context, raw string) (multiplexer.Pane, error)
SendLiteral(ctx context.Context, target multiplexer.Target, text string) error
SendKey(ctx context.Context, target multiplexer.Target, key multiplexer.NamedKey) error
Paste(ctx context.Context, target multiplexer.Target, text []byte, opts multiplexer.PasteOptions) error
}
Multiplexer exposes the shared operations used by application commands.