Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandRunner ¶
type CommandRunner interface {
Run(ctx context.Context, name string, args ...string) error
Output(ctx context.Context, name string, args ...string) ([]byte, error)
}
CommandRunner abstracts exec.CommandContext for testing.
type ConsentFunc ¶
type ConsentFunc func(plan *InstallPlan) bool
ConsentFunc asks the user for confirmation before installing. Returns true to proceed, false to abort.
type Environment ¶
type Environment struct {
OS OS
PM PackageManager
}
Environment describes the detected host installation environment.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor runs installation plans.
func NewExecutor ¶
func NewExecutor(runner CommandRunner, consent ConsentFunc) *Executor
NewExecutor creates an executor with the given command runner and consent callback.
type InstallPlan ¶
type InstallPlan struct {
Steps []InstallStep
}
InstallPlan is the result of planning an installation.
func Plan ¶
func Plan(env Environment, provider Provider, backendIDs []string) (*InstallPlan, error)
Plan creates an installation plan for the given backend IDs. If backendIDs is empty, plans for all known backends. Uses the detected Environment to pick the right provider.
type InstallSpec ¶
type InstallSpec struct {
Packages []string `toml:"packages"`
}
InstallSpec describes the package names for a package manager.
type InstallStep ¶
type InstallStep struct {
BackendID string
DisplayName string
Packages []string
Command []string
ProviderName string
}
InstallStep represents a single backend installation step.
type Manifest ¶
type Manifest struct {
ID string `toml:"id"`
DisplayName string `toml:"display_name"`
Description string `toml:"description"`
Binaries []string `toml:"binaries"`
Homepage string `toml:"homepage"`
Install map[string]InstallSpec `toml:"install"`
Verify VerifySpec `toml:"verify"`
}
Manifest describes an installable backend dependency.
type PackageManager ¶
type PackageManager string
PackageManager identifies a supported system package manager.
const ( PMBrew PackageManager = "brew" PMApt PackageManager = "apt" PMDnf PackageManager = "dnf" PMPacman PackageManager = "pacman" PMZypper PackageManager = "zypper" PMWinget PackageManager = "winget" PMScoop PackageManager = "scoop" PMChoco PackageManager = "choco" PMUnknown PackageManager = "unknown" )
func DetectPackageManager ¶
func DetectPackageManager(os OS) PackageManager
DetectPackageManager reports the first supported package manager found in PATH.
func (PackageManager) String ¶
func (pm PackageManager) String() string
String returns the stable string representation of the package manager.
type Provider ¶
type Provider interface {
// Name returns the provider key (e.g. "brew", "apt").
Name() string
// InstallCommand returns the full command + args to install given packages.
// Returns nil if the provider is not available on this system.
InstallCommand(packages []string) ([]string, error)
// IsAvailable reports whether this provider's package manager is installed.
IsAvailable() bool
}
Provider installs packages via a specific package manager.
type RealRunner ¶
type RealRunner struct{}
RealRunner wraps os/exec for production use.
type UnavailableBackend ¶
type UnavailableBackend struct {
}
UnavailableBackend describes a backend that cannot be auto-installed.
type VerifySpec ¶
type VerifySpec struct {
Command string `toml:"command"`
Args []string `toml:"args"`
VersionRegex string `toml:"version_regex"`
}
VerifySpec describes how to verify the installed backend binary.