Documentation
¶
Overview ¶
Package platform provides OS / package-manager detection and the small set of privileged and unprivileged host operations the CLI relies on.
Index ¶
- func Dispatch(mac, linux func() error) error
- func Has(name string) bool
- func InstallPackage(pkg string) error
- func IsActiveService(unit string) bool
- func Output(name string, args ...string) (string, error)
- func RemoveFilePrivileged(path string) error
- func Run(name string, args ...string) error
- func Sudo(args ...string) error
- func SudoPrime(reason string) error
- func WriteFilePrivileged(path string, content []byte, mode os.FileMode) error
- type ExecRunner
- type OS
- type PackageManager
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dispatch ¶
Dispatch runs the handler matching the current OS, erroring on unsupported platforms. It is the single place per-OS behavior branches.
func InstallPackage ¶
InstallPackage installs a package using the detected package manager.
func IsActiveService ¶
IsActiveService reports whether a systemd unit is active (Linux only).
func RemoveFilePrivileged ¶
RemoveFilePrivileged removes a root-owned file, ignoring a missing file.
func Sudo ¶
Sudo runs a command with elevated privileges, prompting once if needed. When already running as root it executes the command directly.
Types ¶
type ExecRunner ¶ added in v0.3.0
type ExecRunner struct{}
ExecRunner is the production Runner. It carries no state and forwards every call to the package-level functions, so routing host steps through a Runner changes no observable behavior.
func (ExecRunner) RemoveFilePrivileged ¶ added in v0.3.0
func (ExecRunner) RemoveFilePrivileged(path string) error
func (ExecRunner) Sudo ¶ added in v0.3.0
func (ExecRunner) Sudo(args ...string) error
func (ExecRunner) WriteFilePrivileged ¶ added in v0.3.0
type PackageManager ¶
type PackageManager string
PackageManager identifies a supported package manager.
const ( // Brew is Homebrew (macOS). Brew PackageManager = "brew" // Apt is APT (Ubuntu/Debian). Apt PackageManager = "apt" )
func DetectPackageManager ¶
func DetectPackageManager() (PackageManager, error)
DetectPackageManager returns the available package manager for the host.
type Runner ¶ added in v0.3.0
type Runner interface {
Run(name string, args ...string) error
Sudo(args ...string) error
WriteFilePrivileged(path string, content []byte, mode os.FileMode) error
RemoveFilePrivileged(path string) error
}
Runner is the privileged/host exec surface the install/uninstall host steps mutate through. ExecRunner is the production adapter — each method delegates to the matching package function unchanged — so production behavior is identical; tests pass a fake that records calls to assert step ordering and rollback without touching the host.