Documentation
¶
Overview ¶
Package app ties the pieces together: the CLI and the wizard call it to install, update, run and manage instances.
Index ¶
- Constants
- func FormatPorts(d *spec.Definition, ports map[string]int) string
- type App
- func (a *App) AddRegistry(ctx context.Context, src registry.Source) error
- func (a *App) Backups(name string) ([]Backup, error)
- func (a *App) Catalog() ([]Entry, []string, error)
- func (a *App) ConsoleCommand(name, line string, o ConsoleOptions) (string, error)
- func (a *App) ConsoleDetails(name string) (ConsoleInfo, error)
- func (a *App) ConsoleSession(ctx context.Context, name string, o ConsoleOptions, stdin io.Reader, ...) error
- func (a *App) Find(ref string) (Entry, error)
- func (a *App) Install(ctx context.Context, p *Plan) (*instance.Instance, error)
- func (a *App) LoadConfig() (*Config, error)
- func (a *App) Logs(name string, lines int, follow bool) error
- func (a *App) MakeBackup(name string) (Backup, error)
- func (a *App) PlanInstall(req InstallRequest) (*Plan, error)
- func (a *App) PortReport(name string) (string, error)
- func (a *App) Reconfigure(name string, c Changes) error
- func (a *App) Refresh(ctx context.Context) error
- func (a *App) Remove(name string) error
- func (a *App) RemoveRegistry(name string) error
- func (a *App) Restart(name string, warn time.Duration) error
- func (a *App) Restore(name, file string) error
- func (a *App) Run(ctx context.Context, name string) error
- func (a *App) SaveConfig(c *Config) error
- func (a *App) Say(name, msg string) error
- func (a *App) Sources() ([]registry.Source, error)
- func (a *App) Start(name string) error
- func (a *App) Status(name string) (StatusLine, error)
- func (a *App) Statuses() ([]StatusLine, map[string]error, error)
- func (a *App) SteamLogin(ctx context.Context, user string) error
- func (a *App) SteamLogout() error
- func (a *App) Stop(name string) error
- func (a *App) Update(ctx context.Context, name string, warn time.Duration, steamOutput bool) error
- type Backup
- type Changes
- type Config
- type ConsoleInfo
- type ConsoleKind
- type ConsoleOptions
- type Entry
- type InstallRequest
- type NeedsNewerError
- type Plan
- type StatusLine
Constants ¶
const DefaultBackupKeep = 10
DefaultBackupKeep is how many backups are kept when an instance doesn't say otherwise.
const UpdateHint = "Update Anyserve to get them: go install github.com/jonsjava/anyserve/cmd/anyserve@latest"
UpdateHint tells people how to get a newer Anyserve.
Variables ¶
This section is empty.
Functions ¶
func FormatPorts ¶
func FormatPorts(d *spec.Definition, ports map[string]int) string
FormatPorts explains which ports to forward and which to keep private.
Types ¶
type App ¶
type App struct {
Dirs paths.Dirs
Store instance.Store
// Out is for normal output, Log for progress messages.
Out io.Writer
Log func(format string, a ...any)
}
App is the shared state for one command.
func (*App) AddRegistry ¶
AddRegistry adds and fetches an extra registry.
func (*App) Catalog ¶
Catalog loads every registry from the verified cache. The main registry falls back to the snapshot built into the binary. Registries that can't be loaded are reported as warnings, not errors.
func (*App) ConsoleCommand ¶
func (a *App) ConsoleCommand(name, line string, o ConsoleOptions) (string, error)
ConsoleCommand runs one console command and returns what the server printed in reply.
func (*App) ConsoleDetails ¶
func (a *App) ConsoleDetails(name string) (ConsoleInfo, error)
ConsoleDetails reports how to reach an instance's console.
func (*App) ConsoleSession ¶
func (a *App) ConsoleSession(ctx context.Context, name string, o ConsoleOptions, stdin io.Reader, out io.Writer, tty bool) error
ConsoleSession is an interactive console: what the user types goes to the server, and replies (or, for the server's own console, all its output) are shown until input ends.
func (*App) LoadConfig ¶
LoadConfig reads the config file, returning an empty config if missing.
func (*App) MakeBackup ¶
MakeBackup archives the definition's backup paths. If the server is running and can save on command, it's told to save first.
func (*App) PlanInstall ¶
func (a *App) PlanInstall(req InstallRequest) (*Plan, error)
PlanInstall validates a request without changing anything.
func (*App) PortReport ¶
PortReport describes what to forward or open for an instance.
func (*App) Reconfigure ¶
Reconfigure applies changes and restarts the instance if it was running.
func (*App) RemoveRegistry ¶
RemoveRegistry removes an extra registry.
func (*App) Restore ¶
Restore unpacks a backup over the server files. The server must be stopped, and a safety backup of the current state is taken first.
func (*App) SaveConfig ¶
SaveConfig writes the config file.
func (*App) Status ¶
func (a *App) Status(name string) (StatusLine, error)
Status reports on one instance.
func (*App) Statuses ¶
func (a *App) Statuses() ([]StatusLine, map[string]error, error)
Statuses reports on every instance.
func (*App) SteamLogin ¶
SteamLogin signs in to Steam through SteamCMD, which caches the session. Only the user name is saved; SteamCMD handles the password and Steam Guard itself.
func (*App) SteamLogout ¶
SteamLogout forgets the saved Steam user.
type Changes ¶
type Changes struct {
Settings map[string]string
Ports map[string]int
// Expose and Unexpose open private ports to the network, or close
// them again (stacks only).
Expose, Unexpose []string
}
Reconfigure changes settings or ports, rewrites config files and restarts the server if it was running. Changes are what `anyserve config` can change on an instance.
type Config ¶
type Config struct {
// Registries are extra registries on top of the built-in main one.
Registries []registry.Source `json:"registries,omitempty"`
// SteamUser is the account `anyserve steam login` signed in with, for
// servers that can't download anonymously. SteamCMD keeps the session;
// the password is never stored here.
SteamUser string `json:"steam_user,omitempty"`
}
Config is the user's Anyserve settings file.
type ConsoleInfo ¶
type ConsoleInfo struct {
Kind ConsoleKind
// For RCON.
Protocol string
Port int
Public bool
Password string
// For exec.
Service string
Command []string
Description string
}
ConsoleInfo describes an instance's console, for `console --info`.
type ConsoleKind ¶
type ConsoleKind string
ConsoleKind says how Anyserve reaches a server's console.
const ( // ConsoleStdin types into the server's own console through the // supervisor. Replies only show up in the server's output. ConsoleStdin ConsoleKind = "stdin" // ConsoleRCON uses the server's remote console, which replies. ConsoleRCON ConsoleKind = "rcon" // ConsoleExec runs a program in one of a stack's containers. ConsoleExec ConsoleKind = "exec" )
type ConsoleOptions ¶
type ConsoleOptions struct {
// Stdin forces the server's own console even when RCON is available.
Stdin bool
}
ConsoleOptions picks how a console command is delivered.
type Entry ¶
type Entry struct {
Registry string
Def *spec.Definition
}
Entry is one service in the combined catalog.
type InstallRequest ¶
type InstallRequest struct {
Service string // "id" or "registry/id"
Name string
Target string
Settings map[string]string
Ports map[string]int
// ServerDir overrides where server files go.
ServerDir string
Start bool
// SteamOutput shows SteamCMD's full output.
SteamOutput bool
// Expose opens these private ports to the network (stacks only).
Expose []string
}
InstallRequest describes a new instance.
type NeedsNewerError ¶
type NeedsNewerError struct {
ID, Registry, Reason string
}
NeedsNewerError reports a service the registry offers that this version of Anyserve can't use.
func (*NeedsNewerError) Error ¶
func (e *NeedsNewerError) Error() string
type Plan ¶
type Plan struct {
Req InstallRequest
Entry Entry
Target target.Target
Settings map[string]any
Ports map[string]int
Warnings []string
}
Plan is a checked install request, ready to run. The wizard builds one first so it can show a summary before anything is downloaded.
type StatusLine ¶
type StatusLine struct {
Instance *instance.Instance
Def *spec.Definition
Status target.Status
// Upgrade is the newer definition version available, if any.
Upgrade string
}
StatusLine summarizes one instance for `list` and `status`.