installer

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 9 Imported by: 0

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.

func Detect

func Detect() Environment

Detect reports the current 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.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, plan *InstallPlan) error

Execute runs the install plan after getting consent. Returns the first error encountered.

type InstallPlan

type InstallPlan struct {
	Steps       []InstallStep
	Unavailable []UnavailableBackend
}

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.

func FindByID

func FindByID(id string) (*Manifest, error)

FindByID finds a manifest by backend ID.

func LoadAll

func LoadAll() ([]Manifest, error)

LoadAll reads and parses all embedded backend manifests.

type OS

type OS string

OS identifies a supported host operating system.

const (
	OSMacOS   OS = "macos"
	OSLinux   OS = "linux"
	OSWindows OS = "windows"
	OSUnknown OS = "unknown"
)

func DetectOS

func DetectOS() OS

DetectOS reports the current runtime operating system.

func (OS) String

func (o OS) String() string

String returns the stable string representation of the operating system.

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.

func (RealRunner) Output

func (RealRunner) Output(ctx context.Context, name string, args ...string) ([]byte, error)

Output executes name with args using exec.CommandContext and returns stdout.

func (RealRunner) Run

func (RealRunner) Run(ctx context.Context, name string, args ...string) error

Run executes name with args using exec.CommandContext.

type UnavailableBackend

type UnavailableBackend struct {
	BackendID   string
	DisplayName string
	Message     string
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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