host

package
v0.1.0-dev.20260127192156 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 6 Imported by: 0

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.

func NewHost

func NewHost() Host

NewHost returns the appropriate Host implementation for the current platform. This is the main entry point for platform-specific functionality.

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

	// 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

type Result struct {
	OK     bool
	Stdout string
	Stderr string
	Code   int
}

Result represents a command execution result. Returned by shell, package, and service operations.

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL