Documentation
¶
Overview ¶
Package host provides platform-specific bindings for lore's Starlark runtime.
The host package abstracts OS-specific operations behind a common interface, allowing Starlark phase scripts to be platform-agnostic. The correct implementation is selected at build time via Go build tags.
Design decisions:
- ADR-010: Host Bindings API (see lore-design-decisions.md)
- ADR-005: Windows Package Manager Choice (winget preferred over choco)
Unsettled decisions affecting this package:
- ADR-011: Package Authoring (may affect how package.* bindings work)
- ADR-014: Registry Infrastructure Strategy (affects lore.* bindings)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host interface {
// Platform returns system information.
Platform() Platform
// PackageManager returns the preferred package manager for this platform.
PackageManager() PackageManager
// ServiceManager returns the service manager for this platform.
ServiceManager() ServiceManager
// RunCommand executes a shell command.
RunCommand(command string, sudo bool) Result
// ExpandPath expands ~ to home directory.
ExpandPath(path string) string
// HomeDir returns the user's home directory.
HomeDir() string
}
Host provides the full set of platform-specific operations. Created via NewHost() which returns the appropriate implementation.
type PackageManager ¶
type PackageManager interface {
// Name returns the package manager identifier.
Name() string
// Installed checks if a package is installed.
Installed(name string) bool
// Version returns the installed version of a package.
Version(name string) string
// Available checks if a package exists in the package manager's repositories.
// This verifies the package can be installed, not that it is installed.
Available(name string) bool
// Search finds packages matching a query string.
// Returns up to limit results (0 = no limit).
Search(query string, limit int) []SearchResult
// Install installs one or more packages.
Install(packages ...string) Result
// Remove removes a package.
Remove(name string) Result
// Update refreshes the package index.
Update() Result
// AddRepo adds a package repository.
AddRepo(url, keyURL, name string) Result
// NeedsSudo returns true if operations require privilege elevation.
NeedsSudo() bool
}
PackageManager abstracts package manager operations. Each platform provides its own implementation.
type Platform ¶
type Platform struct {
OS string // GOOS: "darwin", "linux", "windows"
Arch string // GOARCH: "amd64", "arm64", "386"
Distro string // Distribution: "debian", "ubuntu", "fedora", "macos", "windows"
Version string // OS version string
Hostname string // Machine hostname
}
Platform holds system information using Go's naming conventions. Exposed to Starlark as the read-only `platform` object.
func DetectPlatform ¶
func DetectPlatform() Platform
DetectPlatform returns current system information. Delegates to platform-specific detection.
type Result ¶
Result represents a command execution result. Returned by shell, package, and service operations.
type SearchResult ¶
type SearchResult struct {
Name string // Package name
Version string // Available version (may be empty)
Description string // Package description
}
SearchResult represents a package found by search.
type ServiceManager ¶
type ServiceManager interface {
// Exists checks if a service exists.
Exists(name string) bool
// Status returns the service status.
Status(name string) string
// Start starts a service.
Start(name string) Result
// Stop stops a service.
Stop(name string) Result
// Enable enables a service at boot.
Enable(name string) Result
// Disable disables a service at boot.
Disable(name string) Result
// NeedsSudo returns true if operations require privilege elevation.
NeedsSudo() bool
}
ServiceManager abstracts service management operations. Each platform provides its own implementation (systemd, launchd, Windows Services).