Documentation
¶
Overview ¶
Package platform isolates the OS-specific behaviour authama needs, so the rest of the tree can stay free of runtime.GOOS branches: terminal handling for reading secrets without echoing them (here), and the OS predicates every other package asks its questions through (os.go).
The one deliberate exception is util/desktop, which dispatches to a different notification backend per OS. That is a self-contained implementation choice rather than a predicate leaking across the tree, so it keeps its own switch.
Index ¶
- Variables
- func EmitUseKeychain() bool
- func FirstClass() bool
- func IsLinux() bool
- func IsMacOS() bool
- func IsWindows() bool
- func OSName() string
- func ReadLine(f io.Reader) (string, error)
- func ReadSecret(prompt string) (string, error)
- func StderrIsTerminal() bool
- func StdinIsTerminal() bool
- type SystemInfo
Constants ¶
This section is empty.
Variables ¶
var ErrNotATerminal = errors.New("standard input is not a terminal")
ErrNotATerminal is returned by ReadSecret when standard input is not a terminal, so callers can fall back to reading a piped line instead.
Functions ¶
func EmitUseKeychain ¶
func EmitUseKeychain() bool
EmitUseKeychain reports whether the rendered ssh config should carry UseKeychain.
It is an Apple extension: ssh on macOS reads a key's passphrase from the login keychain instead of prompting. OpenSSH elsewhere does not know the keyword, and an unknown keyword is a hard parse error for the whole file - which is why the renderer also pins `IgnoreUnknown UseKeychain`, and why this has to be decided per machine rather than baked into the manifest.
func FirstClass ¶
func FirstClass() bool
FirstClass reports whether this OS is one authama is tested on. Elsewhere it still builds and mostly works, but the platform layer falls back to generic behaviour and preflight says so.
func ReadLine ¶
ReadLine consumes a single line, one byte at a time. A buffered reader would swallow whatever follows the newline, which matters here because callers read a second line to confirm a passphrase.
func ReadSecret ¶
ReadSecret prompts on stderr and reads one line with terminal echo disabled. The previous terminal state is restored before returning, including when the user interrupts the prompt, so a cancelled read cannot leave the terminal unable to echo.
func StderrIsTerminal ¶ added in v0.1.6
func StderrIsTerminal() bool
StderrIsTerminal reports whether standard error is a terminal: where a progress line may be drawn without ending up in a log or a pipe.
func StdinIsTerminal ¶
func StdinIsTerminal() bool
StdinIsTerminal reports whether standard input is a terminal.
Types ¶
type SystemInfo ¶ added in v0.1.6
type SystemInfo struct {
OS string // "macOS", "Ubuntu", "Windows 11 Pro"
OSVersion string // "26.1", "24.04.3 LTS (Noble Numbat)", "24H2"
OSBuild string // "25B78", "26100.4652"
Kernel string // "Darwin 25.1.0", "Linux 6.8.0-51-generic"
Arch string // runtime.GOARCH: "arm64", "amd64"
Hostname string
Model string // "MacBookPro18,3", "ThinkPad X1 Carbon Gen 11"
Vendor string // "Apple", "LENOVO"
CPU string // "Apple M1 Pro", "Intel(R) Core(TM) i7-1365U"
Cores int // physical cores, when known
Threads int // logical processors (runtime.NumCPU)
PerfCores int // Apple silicon: performance cores
EffCores int // Apple silicon: efficiency cores
Memory uint64 // total physical memory, bytes
Booted time.Time
}
SystemInfo describes the computer authama runs on, for the About page. Every field is best effort: what this OS does not expose, or refuses to say, is left empty (zero), and nothing here ever fails.
func System ¶ added in v0.1.6
func System() SystemInfo
System gathers SystemInfo for this computer. It reads the kernel and the OS's own records directly (sysctl, /proc, the registry) and runs no commands, so it is quick enough to call per request.
func (SystemInfo) Uptime ¶ added in v0.1.6
func (s SystemInfo) Uptime() time.Duration
Uptime is how long the computer has been up, rounded to the minute; zero when the boot time is unknown.