Documentation
¶
Overview ¶
Package app contains the business logic for the gow CLI, separated from the cobra command wiring in cmd/gow. All side-effecting operations are injected via the Deps struct, making every operation testable without real hardware, filesystem, or network access.
Index ¶
- Variables
- func AddStackFlags(cmd *cobra.Command, sf *StackFlags)
- func NewManager(cfg CLIConfig, d Deps) (*site.Manager, error)
- func RunBackup(cfg CLIConfig, domain string, d Deps) error
- func RunBackupCron(cfg CLIConfig, d Deps) error
- func RunBackupSchedule(cfg CLIConfig, domain, schedule string, retain int, d Deps) error
- func RunBackupUnschedule(cfg CLIConfig, domain string, d Deps) error
- func RunClone(cfg CLIConfig, src, dst string, d Deps) error
- func RunCreate(cfg CLIConfig, sf SiteFlags, domain string, d Deps) error
- func RunDelete(cfg CLIConfig, sf SiteFlags, domain string, d Deps) error
- func RunFlush(cfg CLIConfig, domain string, d Deps) error
- func RunInfo(cfg CLIConfig, sf SiteFlags, domain string, w io.Writer, d Deps) error
- func RunList(cfg CLIConfig, w io.Writer, d Deps) error
- func RunLog(cfg CLIConfig, lf LogFlags, domain string, d Deps) error
- func RunMetrics(cfg CLIConfig, w io.Writer, d Deps, jsonOutput bool) error
- func RunOffline(cfg CLIConfig, domain string, d Deps) error
- func RunOnline(cfg CLIConfig, domain string, d Deps) error
- func RunPresets(w io.Writer) error
- func RunReconcile(cfg CLIConfig, d Deps) error
- func RunRestore(cfg CLIConfig, domain, archivePath string, d Deps) error
- func RunSSL(cfg CLIConfig, sf SiteFlags, domain string, d Deps) error
- func RunStackMigrate(sf StackFlags, d Deps) error
- func RunStackOp(sf StackFlags, op stackOp, d Deps) error
- func RunStackPurge(cfg CLIConfig, sf StackFlags, d Deps) error
- func RunStackStatus(w io.Writer, d Deps) error
- func RunStatus(cfg CLIConfig, w io.Writer, d Deps) error
- func RunUpdate(cfg CLIConfig, sf SiteFlags, domain string, d Deps) error
- func RunWP(cfg CLIConfig, domain string, args []string, d Deps) error
- func ValidateDomain(s string) error
- type CLIConfig
- type Deps
- type LogFlags
- type SiteFlags
- type StackFlags
Constants ¶
This section is empty.
Variables ¶
var ( StackOpInstall = stackOp{ // contains filtered or unexported fields } StackOpUpgrade = stackOp{ // contains filtered or unexported fields } StackOpRemove = stackOp{ // contains filtered or unexported fields } StackOpPurge = stackOp{ // contains filtered or unexported fields } StackOpStart = stackOp{ // contains filtered or unexported fields } StackOpStop = stackOp{ // contains filtered or unexported fields } StackOpRestart = stackOp{ // contains filtered or unexported fields } StackOpReload = stackOp{ // contains filtered or unexported fields } )
StackOp* declare the supported stack lifecycle operations the CLI can run.
Functions ¶
func AddStackFlags ¶
func AddStackFlags(cmd *cobra.Command, sf *StackFlags)
AddStackFlags registers stack component flags on a cobra command.
func NewManager ¶
NewManager constructs a site.Manager using the injected dependencies.
func RunBackupCron ¶
RunBackupCron is the entry point for the hidden backup-cron command. It iterates all sites with a backup schedule, runs backups, and prunes.
func RunBackupSchedule ¶
RunBackupSchedule sets or updates the automatic backup schedule for a site.
func RunBackupUnschedule ¶
RunBackupUnschedule removes the automatic backup schedule for a site.
func RunMetrics ¶
RunMetrics collects and displays live server metrics.
func RunOffline ¶
RunOffline puts a site into maintenance mode.
func RunReconcile ¶
RunReconcile recomputes allocations and reloads OLS.
func RunRestore ¶
RunRestore validates inputs, creates a Manager, and calls Restore.
func RunStackMigrate ¶
func RunStackMigrate(sf StackFlags, d Deps) error
RunStackMigrate migrates a stack component (e.g. MariaDB) to a new version.
func RunStackOp ¶
func RunStackOp(sf StackFlags, op stackOp, d Deps) error
RunStackOp executes a stack operation (install, upgrade, remove, etc.).
func RunStackPurge ¶
func RunStackPurge(cfg CLIConfig, sf StackFlags, d Deps) error
RunStackPurge purges stack packages and configs, blocking if sites depend on them.
func RunStackStatus ¶
RunStackStatus shows status for all installed stack components.
func ValidateDomain ¶
ValidateDomain rejects inputs that cannot safely be used as a site name. The string becomes a system user name, database name, filesystem path component, and OLS config identifier — anything containing shell meta, path separators, SQL meta, or whitespace is rejected here so downstream code can assume clean input.
Types ¶
type CLIConfig ¶
type CLIConfig struct {
ConfDir string
StateFile string
PolicyFile string
WebRoot string
LogDir string // per-site log directory (default: /var/log/lsws)
}
CLIConfig holds paths and flags resolved from the CLI.
type Deps ¶
type Deps struct {
Ctx context.Context
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
DetectSpecs func() (system.Specs, error)
LoadPolicy func(string) (allocator.Policy, error)
OpenStore func(string) (*state.Store, error)
NewOLS func() ols.Controller
NewRunner func() stack.Runner
InstalledPHP func() []string
PHPAvailable func(string) bool
WPInstall func(domain, webRoot, cacheMode, multisite string) error
DBCleanup func(domain string) error
}
Deps groups the side-effecting operations that app depends on. Production code uses DefaultDeps; tests inject mocks via this struct.
func DefaultDeps ¶
func DefaultDeps() Deps
DefaultDeps returns a Deps struct wired to production implementations.
type LogFlags ¶
type LogFlags struct {
Access bool // --access
Error bool // --error
Follow bool // --follow / -f
Lines int // --lines / -n
}
LogFlags holds flags for the `site log` command.
type SiteFlags ¶
type SiteFlags struct {
SiteType string // --type (create only: html, php, wp)
PHP string // --php (version string)
Preset string // --tune (blog, woocommerce, custom)
PHPMemory uint // --php-memory
WorkerBudget uint // --worker-budget
NoCache bool // --no-cache (create only, wp only: disable LSCache)
Multisite string // --multisite (create only, wp only: subdirectory or subdomain)
Verbose bool // --verbose (info only)
NoPrompt bool // --no-prompt (delete only)
Isolate bool // --isolate (update only)
SSLEmail string // --email (ssl only)
SSLStaging bool // --staging (ssl only)
SSLWildcard bool // --wildcard (ssl only, requires --dns)
SSLDNS string // --dns (ssl only, currently: "cloudflare")
SSLHSTS bool // --hsts (ssl only)
RestoreFile string // --file (restore only)
BackupSchedule string // --schedule (backup-schedule: daily or weekly)
BackupRetain int // --retain (backup-schedule: number of backups to keep)
}
SiteFlags holds per-command flags for site operations.
type StackFlags ¶
type StackFlags struct {
OLS bool
PHP string // --php (version string, e.g. "83", "84")
PHP81 bool
PHP82 bool
PHP83 bool
PHP84 bool
PHP85 bool
MariaDB bool
Redis bool
WPCLI bool
Composer bool
Certbot bool
Target string // --target for migrate
}
StackFlags holds per-command flags for stack operations.