installer

package
v1.35.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: CC0-1.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTemplate added in v1.13.0

func ApplyTemplate(input string, vars *TemplateVars, installerName string) (string, error)

ApplyTemplate applies template variables to a string. It supports both Go template syntax (e.g., "{{ .Tag }}") and legacy token syntax (e.g., "{tag}"). When legacy tokens are detected, a deprecation warning is logged at DEBUG level.

func ClearInstalledVersion added in v1.33.0

func ClearInstalledVersion(name string)

ClearInstalledVersion drops the version record for the named installer, which no longer describes what is installed once the installer stops being pinned.

func FillDefaults added in v1.5.0

func FillDefaults(data *appconfig.InstallerData)

FillDefaults initializes nil fields in an InstallerData object with empty values.

func FilterInstaller added in v1.5.0

func FilterInstaller(installer IInstaller, filters []string) bool

FilterInstaller determines whether an installer should be included based on a list of filters. Filters can be positive (e.g., "name") or negative (e.g., "!name"). Filters can also target specific fields like type (e.g., "type:brew") or tags (e.g., "tag:database").

func GetPlatformArchWithFallback added in v1.10.0

func GetPlatformArchWithFallback(preferred string, fallbacks ...string) string

GetPlatformArchWithFallback attempts to determine the best architecture for a Docker image, considering a preferred architecture and a list of fallbacks.

func InstallerIsEnabled added in v1.6.0

func InstallerIsEnabled(i IInstaller) (bool, error)

InstallerIsEnabled checks if an installer is enabled. The "enabled" field in the installer data can be a boolean string ("true", "false") or a command. If it's a command, the installer is enabled if the command runs successfully (exit code 0).

func InstallerWithDefaults

func InstallerWithDefaults(
	data *appconfig.InstallerData,
	installerType appconfig.InstallerType,
	defaults *appconfig.AppConfigDefaults,
) *appconfig.InstallerData

InstallerWithDefaults applies default configurations to an installer data object. It first applies base defaults using FillDefaults, and then applies type-specific defaults.

func IsRepoUpdated added in v1.25.0

func IsRepoUpdated(key string) bool

IsRepoUpdated returns whether a key has been marked as done.

func MarkRepoUpdated added in v1.25.0

func MarkRepoUpdated(key string)

MarkRepoUpdated marks a key as done without running a function.

func PinnedVersionNeedsUpdate added in v1.33.0

func PinnedVersionNeedsUpdate(name string, pinned string) bool

PinnedVersionNeedsUpdate reports whether the pinned version differs from the one sofmani recorded. A package whose version was never recorded — installed by hand, or pinned after it was already installed — is reconciled to the pin on the next run.

func ReadInstalledVersion added in v1.33.0

func ReadInstalledVersion(name string) string

ReadInstalledVersion returns the version sofmani last installed for the named installer, or an empty string when no version was recorded.

func RecordInstalledVersion added in v1.33.0

func RecordInstalledVersion(name string, version string) error

RecordInstalledVersion stores the version installed for the named installer.

func ResetBrewListCache added in v1.32.2

func ResetBrewListCache()

ResetBrewListCache clears the cached `brew list` output. Intended for testing.

func ResetRepoUpdateTracker added in v1.25.0

func ResetRepoUpdateTracker()

ResetRepoUpdateTracker resets the tracker state. Intended for testing.

func RunInstaller

func RunInstaller(config *appconfig.AppConfig, installer IInstaller) (*summary.InstallResult, error)

RunInstaller executes the installation or update process for a given installer. It returns the result of the installation/update and any error that occurred. An installer marked `allow_failure` reports its error and yields no result, leaving the caller to carry on with the next installer.

func RunRepoUpdateOnce added in v1.25.0

func RunRepoUpdateOnce(key string, fn func() error) error

RunRepoUpdateOnce runs fn at most once per key during the process lifetime. Subsequent calls with the same key return the cached error without running fn again.

Types

type AptInstaller added in v1.3.0

type AptInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
	// PackageManager is the package manager to use (apt or apk).
	PackageManager AptPackageManager
}

AptInstaller is an installer for apt and apk packages.

func NewAptInstaller added in v1.3.0

func NewAptInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *AptInstaller

NewAptInstaller creates a new AptInstaller.

func (*AptInstaller) CheckIsInstalled added in v1.3.0

func (i *AptInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*AptInstaller) CheckNeedsUpdate added in v1.3.0

func (i *AptInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*AptInstaller) GetBinName added in v1.3.0

func (i *AptInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it uses the installer name with any `=version` suffix stripped.

func (*AptInstaller) GetData added in v1.5.0

func (i *AptInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*AptInstaller) GetOpts added in v1.3.0

func (i *AptInstaller) GetOpts() *AptOpts

GetOpts returns the parsed options for the AptInstaller.

func (*AptInstaller) GetPackageSpec added in v1.33.0

func (i *AptInstaller) GetPackageSpec() string

GetPackageSpec returns the package argument passed to the package manager, as `<name>=<version>` when a version is pinned.

func (*AptInstaller) GetPinnedVersion added in v1.33.0

func (i *AptInstaller) GetPinnedVersion() string

GetPinnedVersion implements IVersionPinned. The version may come from opts.version or from a `=version` suffix on the package name.

func (*AptInstaller) Install added in v1.3.0

func (i *AptInstaller) Install() error

Install implements IInstaller.

func (*AptInstaller) Update added in v1.3.0

func (i *AptInstaller) Update() error

Update implements IInstaller.

func (*AptInstaller) Validate added in v1.9.0

func (i *AptInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type AptOpts added in v1.3.0

type AptOpts struct {
	// Version pins the package to an exact version, appended as `=version`.
	// Ignored when Name already carries a `=version` suffix.
	Version *string
	// Flags is a string of additional flags to pass to the apt/apk command.
	Flags *string
	// InstallFlags is a string of additional flags to pass only during install.
	InstallFlags *string
	// UpdateFlags is a string of additional flags to pass only during update.
	UpdateFlags *string
}

AptOpts represents options for the AptInstaller.

type AptPackageManager added in v1.10.0

type AptPackageManager string

AptPackageManager represents a package manager type.

const (
	PackageManagerApk AptPackageManager = "apk" // PackageManagerApk represents the apk package manager.
	PackageManagerApt AptPackageManager = "apt" // PackageManagerApt represents the apt package manager.
)

Constants for supported package managers.

type BrewExitError added in v1.10.0

type BrewExitError struct {
	ExitCode int
}

BrewExitError represents a failure exit code from a simulated `brew` call.

func (*BrewExitError) Error added in v1.10.0

func (e *BrewExitError) Error() string

type BrewInstaller

type BrewInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
}

BrewInstaller is an installer for Homebrew packages.

func NewBrewInstaller

func NewBrewInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *BrewInstaller

NewBrewInstaller creates a new BrewInstaller.

func (*BrewInstaller) CheckIsInstalled

func (i *BrewInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*BrewInstaller) CheckNeedsUpdate

func (i *BrewInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*BrewInstaller) GetBinName

func (i *BrewInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it uses the installer name.

func (*BrewInstaller) GetData added in v1.5.0

func (i *BrewInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*BrewInstaller) GetFullName added in v1.9.4

func (i *BrewInstaller) GetFullName() string

GetFullName returns the full name of the package, including the tap if specified.

func (*BrewInstaller) GetOpts

func (i *BrewInstaller) GetOpts() *BrewOpts

GetOpts returns the parsed options for the BrewInstaller.

func (*BrewInstaller) GetPackageName added in v1.33.0

func (i *BrewInstaller) GetPackageName() string

GetPackageName returns the formula name, including the `@version` suffix when opts.version selects a versioned formula.

func (*BrewInstaller) Install

func (i *BrewInstaller) Install() error

Install implements IInstaller.

func (*BrewInstaller) IsCask added in v1.11.0

func (i *BrewInstaller) IsCask() bool

func (*BrewInstaller) Update

func (i *BrewInstaller) Update() error

Update implements IInstaller.

func (*BrewInstaller) Validate added in v1.9.0

func (i *BrewInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type BrewOpts

type BrewOpts struct {
	// Version selects a versioned formula, appended as `@version` (e.g. `node@20`).
	// Homebrew only carries the versions that are published as their own formula.
	// Ignored when Name already carries a `@version` suffix.
	Version *string
	// Tap is the Homebrew tap to use for the package.
	Tap *string
	// Cask installs the formula as a cask instead of a regular package.
	Cask *bool
	// Flags is a string of additional flags to pass to the brew command.
	Flags *string
	// InstallFlags is a string of additional flags to pass only during install.
	InstallFlags *string
	// UpdateFlags is a string of additional flags to pass only during update.
	UpdateFlags *string
}

BrewOpts represents options for the BrewInstaller.

type CargoInstaller added in v1.24.0

type CargoInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
}

CargoInstaller is an installer for Rust cargo packages.

func NewCargoInstaller added in v1.24.0

func NewCargoInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *CargoInstaller

NewCargoInstaller creates a new CargoInstaller.

func (*CargoInstaller) CheckIsInstalled added in v1.24.0

func (i *CargoInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*CargoInstaller) CheckNeedsUpdate added in v1.24.0

func (i *CargoInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*CargoInstaller) GetBinName added in v1.24.0

func (i *CargoInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it uses the installer name.

func (*CargoInstaller) GetData added in v1.24.0

func (i *CargoInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*CargoInstaller) GetOpts added in v1.24.0

func (i *CargoInstaller) GetOpts() *CargoOpts

GetOpts returns the parsed options for the CargoInstaller.

func (*CargoInstaller) GetPinnedVersion added in v1.33.0

func (i *CargoInstaller) GetPinnedVersion() string

GetPinnedVersion implements IVersionPinned.

func (*CargoInstaller) GetVersionArgs added in v1.33.0

func (i *CargoInstaller) GetVersionArgs() []string

GetVersionArgs returns the `--version` arguments for the pinned version, or nil when the crate is not pinned.

func (*CargoInstaller) Install added in v1.24.0

func (i *CargoInstaller) Install() error

Install implements IInstaller.

func (*CargoInstaller) Update added in v1.24.0

func (i *CargoInstaller) Update() error

Update implements IInstaller.

func (*CargoInstaller) Validate added in v1.24.0

func (i *CargoInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type CargoOpts added in v1.24.0

type CargoOpts struct {
	// Version pins the crate to an exact version, passed as `--version`.
	// Accepts any cargo version requirement (e.g. `1.2.3`, `~1.2`).
	Version *string
	// Flags is a string of additional flags to pass to the cargo command.
	Flags *string
	// InstallFlags is a string of additional flags to pass only during install.
	InstallFlags *string
	// UpdateFlags is a string of additional flags to pass only during update.
	UpdateFlags *string
}

CargoOpts represents options for the CargoInstaller.

type DockerInstaller added in v1.10.0

type DockerInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
}

DockerInstaller is an installer for Docker images.

func NewDockerInstaller added in v1.10.0

func NewDockerInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *DockerInstaller

NewDockerInstaller creates a new DockerInstaller.

func (*DockerInstaller) CheckIsInstalled added in v1.10.0

func (i *DockerInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*DockerInstaller) CheckNeedsUpdate added in v1.10.0

func (i *DockerInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*DockerInstaller) GetContainerName added in v1.10.0

func (i *DockerInstaller) GetContainerName() string

GetContainerName returns the name of the Docker container. It uses the BinName from the installer data if provided, otherwise it uses the installer name.

func (*DockerInstaller) GetData added in v1.10.0

func (i *DockerInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*DockerInstaller) GetImage added in v1.33.0

func (i *DockerInstaller) GetImage() string

GetImage returns the image reference to pull and run, as `<name>:<version>` when a version is pinned.

func (*DockerInstaller) GetOpts added in v1.10.0

func (i *DockerInstaller) GetOpts() *DockerOpts

GetOpts returns the parsed options for the DockerInstaller.

func (*DockerInstaller) GetPinnedVersion added in v1.33.0

func (i *DockerInstaller) GetPinnedVersion() string

GetPinnedVersion implements IVersionPinned. Only opts.version counts as a pin — a tag written into the image name may well be a moving one (`:main`, `:latest`), which keeps following the registry.

func (*DockerInstaller) Install added in v1.10.0

func (i *DockerInstaller) Install() error

Install implements IInstaller.

func (*DockerInstaller) Update added in v1.10.0

func (i *DockerInstaller) Update() error

Update implements IInstaller.

func (*DockerInstaller) Validate added in v1.10.0

func (i *DockerInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type DockerManifestList added in v1.10.0

type DockerManifestList struct {
	SchemaVersion int    `json:"schemaVersion"`
	MediaType     string `json:"mediaType"`
	Manifests     []struct {
		Digest   string `json:"digest"`
		Platform struct {
			Architecture string `json:"architecture"`
			OS           string `json:"os"`
		} `json:"platform"`
	} `json:"manifests"`
}

DockerManifestList represents the structure of a Docker manifest list.

type DockerOpts added in v1.10.0

type DockerOpts struct {
	// Version pins the image to a tag, appended as `:version`.
	// Ignored when Name already carries a tag or digest.
	Version *string
	// Flags is a string of flags to pass to the `docker run` command.
	Flags *string
	// Platform is a platform-specific map of Docker platform strings (e.g., "linux/amd64").
	Platform *platform.PlatformMap[string]
	// SkipIfUnavailable indicates whether to skip installation if Docker is unavailable.
	SkipIfUnavailable *bool
}

DockerOpts represents options for the DockerInstaller.

type GitHubReleaseBinLink struct {
	// Source is the path to the binary inside the extracted tree. If relative, it is
	// resolved against ExtractTo; absolute paths are also accepted.
	Source string
	// Target is the absolute path where the symlink (or copied file, on Windows) is placed.
	Target string
}

GitHubReleaseBinLink describes a single binary exposed from a tree-mode install.

type GitHubReleaseInstallStrategy added in v1.8.0

type GitHubReleaseInstallStrategy string

GitHubReleaseInstallStrategy represents the installation strategy for a GitHub release.

const (
	GitHubReleaseInstallStrategyNone   GitHubReleaseInstallStrategy = "none"   // GitHubReleaseInstallStrategyNone means no special handling, just download the file.
	GitHubReleaseInstallStrategyTar    GitHubReleaseInstallStrategy = "tar"    // GitHubReleaseInstallStrategyTar means extract a tar archive.
	GitHubReleaseInstallStrategyZip    GitHubReleaseInstallStrategy = "zip"    // GitHubReleaseInstallStrategyZip means extract a zip archive.
	GitHubReleaseInstallStrategyGzip   GitHubReleaseInstallStrategy = "gzip"   // GitHubReleaseInstallStrategyGzip means decompress a single gzip-compressed file (not a tar archive).
	GitHubReleaseInstallStrategyCustom GitHubReleaseInstallStrategy = "custom" // GitHubReleaseInstallStrategyCustom runs a user-provided shell command to extract the asset.
)

Constants for GitHub release installation strategies.

type GitHubReleaseInstaller added in v1.8.0

type GitHubReleaseInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
}

GitHubReleaseInstaller is an installer for GitHub releases.

func NewGitHubReleaseInstaller added in v1.8.0

func NewGitHubReleaseInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *GitHubReleaseInstaller

NewGitHubReleaseInstaller creates a new GitHubReleaseInstaller.

func (*GitHubReleaseInstaller) CheckIsInstalled added in v1.8.0

func (i *GitHubReleaseInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*GitHubReleaseInstaller) CheckNeedsUpdate added in v1.8.0

func (i *GitHubReleaseInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*GitHubReleaseInstaller) CopyExtractedFile added in v1.8.0

func (i *GitHubReleaseInstaller) CopyExtractedFile(out *os.File, tmpDir string, vars *TemplateVars) (bool, error)

CopyExtractedFile copies the extracted file from a temporary directory to the final destination. vars is used to render template tokens inside archive_bin_name; pass nil to skip templating.

func (*GitHubReleaseInstaller) GetArchiveBinName added in v1.21.0

func (i *GitHubReleaseInstaller) GetArchiveBinName(vars *TemplateVars) string

GetArchiveBinName returns the name of the binary file inside the archive. It uses ArchiveBinName from opts if provided (resolved for the current platform when a per-platform map was supplied), otherwise falls back to GetBinName(). When vars is non-nil, the resolved value is rendered through ApplyTemplate so template tokens like {{ .Tag }} or {{ .Arch }} are substituted.

func (*GitHubReleaseInstaller) GetBinName added in v1.8.0

func (i *GitHubReleaseInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it uses the base name of the installer name.

func (*GitHubReleaseInstaller) GetCachedTag added in v1.8.0

func (i *GitHubReleaseInstaller) GetCachedTag() (string, error)

GetCachedTag retrieves the cached tag for the release from the cache directory.

func (*GitHubReleaseInstaller) GetData added in v1.8.0

GetData implements IInstaller.

func (*GitHubReleaseInstaller) GetDestination added in v1.8.0

func (i *GitHubReleaseInstaller) GetDestination() string

GetDestination returns the destination directory for the release asset. It uses the Destination from the installer options if provided, otherwise it defaults to the current working directory.

func (*GitHubReleaseInstaller) GetFilename added in v1.8.0

func (i *GitHubReleaseInstaller) GetFilename() string

GetFilename returns the filename to download from the release, resolved for the current platform.

func (*GitHubReleaseInstaller) GetInstallDir added in v1.8.0

func (i *GitHubReleaseInstaller) GetInstallDir() string

GetInstallDir returns the installation directory for the release asset. In tree mode it returns extract_to; otherwise it falls back to destination.

func (*GitHubReleaseInstaller) GetLatestTag added in v1.8.0

func (i *GitHubReleaseInstaller) GetLatestTag() (string, error)

func (*GitHubReleaseInstaller) GetOpts added in v1.8.0

GetOpts returns the parsed options for the GitHubReleaseInstaller.

func (*GitHubReleaseInstaller) GetPinnedVersion added in v1.33.0

func (i *GitHubReleaseInstaller) GetPinnedVersion() string

GetPinnedVersion implements IVersionPinned. The pin is the release tag to install.

func (*GitHubReleaseInstaller) GetTag added in v1.33.0

func (i *GitHubReleaseInstaller) GetTag() (string, error)

GetTag returns the release tag to install: the pinned opts.version when set, otherwise the repository's latest release tag.

func (*GitHubReleaseInstaller) Install added in v1.8.0

func (i *GitHubReleaseInstaller) Install() error

Install implements IInstaller.

func (*GitHubReleaseInstaller) Update added in v1.8.0

func (i *GitHubReleaseInstaller) Update() error

Update implements IInstaller.

func (*GitHubReleaseInstaller) UpdateCache added in v1.8.0

func (i *GitHubReleaseInstaller) UpdateCache(tag string) error

UpdateCache updates the cached tag for the release in the cache directory.

func (*GitHubReleaseInstaller) Validate added in v1.9.0

func (i *GitHubReleaseInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type GitHubReleaseOpts added in v1.8.0

type GitHubReleaseOpts struct {
	// Repository is the GitHub repository (e.g., "owner/repo").
	Repository *string
	// Version pins the installer to a release tag, exactly as it is named on GitHub
	// (e.g. "v1.2.3"). Without it, the repository's latest release is installed.
	Version *string
	// Destination is the directory where the release asset will be installed.
	Destination *string
	// DownloadFilename is a platform-specific map of the filename to download from the release.
	// Supports Go template syntax with variables: {{ .Tag }}, {{ .Version }}, {{ .Arch }}, {{ .ArchAlias }}, {{ .ArchGnu }}, {{ .OS }}.
	// Legacy placeholders {tag}, {version}, {arch}, {arch_alias}, {arch_gnu}, {os} are deprecated but still supported.
	DownloadFilename *platform.PlatformMap[string]
	// Strategy is the installation strategy to use (none, tar, zip, gzip).
	Strategy *GitHubReleaseInstallStrategy
	// GithubToken is the GitHub personal access token for authenticated API requests.
	// Supports environment variable expansion (e.g., "$GITHUB_TOKEN" or "${GITHUB_TOKEN}").
	GithubToken *string
	// ArchiveBinName is the name of the binary file inside the archive (tar/zip).
	// Use this when the filename inside the archive differs from the desired output bin_name.
	// Accepts either a string or a per-platform map. Supports Go template syntax with the
	// usual variables ({{ .Tag }}, {{ .Version }}, {{ .Arch }}, {{ .OS }}, ...).
	// If not set, falls back to bin_name (or the installer name).
	ArchiveBinName *platform.PlatformMap[string]
	// ExtractTo, when set, switches the installer to "tree mode": the full archive contents
	// are extracted to this directory, preserving sibling files (lib/, share/, etc.) that
	// many toolchains rely on at runtime. Requires strategy 'tar' or 'zip'. When tree mode
	// is active, Destination and ArchiveBinName are ignored.
	ExtractTo *string
	// StripComponents drops this many leading path components from each archive entry, the
	// same way `tar --strip-components=N` does. Useful because release tarballs typically
	// wrap their contents in a single versioned directory. Only meaningful with ExtractTo.
	StripComponents *int
	// BinLinks lists binaries to expose from inside ExtractTo. On unix, each entry becomes
	// a symlink at Target pointing to Source; on Windows, the file is copied instead (since
	// symlinks require elevated privileges). Only meaningful with ExtractTo.
	BinLinks []GitHubReleaseBinLink
	// ExtractCommand is a user-provided shell command that performs the extraction when
	// Strategy is "custom". The command is run through Go template substitution with these
	// extra variables available (in addition to the usual .OS, .Arch, .Tag, ...):
	//   {{ .DownloadFile }}   - absolute path to the downloaded asset
	//   {{ .ExtractDir }}     - temp directory where the command should place extracted files
	//   {{ .Destination }}    - final destination directory
	//   {{ .BinName }}        - expected binary name (matches GetBinName())
	//   {{ .ArchiveBinName }} - the filename sofmani will copy from ExtractDir to Destination
	// After the command finishes, sofmani copies ExtractDir/ArchiveBinName to
	// Destination/BinName, the same way the tar and zip strategies do.
	ExtractCommand *string
}

GitHubReleaseOpts represents options for the GitHubReleaseInstaller.

type GitInstaller added in v1.4.0

type GitInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
}

GitInstaller is an installer for Git repositories.

func NewGitInstaller added in v1.4.0

func NewGitInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *GitInstaller

NewGitInstaller creates a new GitInstaller.

func (*GitInstaller) CheckIsInstalled added in v1.4.0

func (i *GitInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*GitInstaller) CheckNeedsUpdate added in v1.4.0

func (i *GitInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*GitInstaller) GetData added in v1.5.0

func (i *GitInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*GitInstaller) GetDestination added in v1.4.0

func (i *GitInstaller) GetDestination() string

GetDestination returns the destination directory for the Git repository. It uses the Destination from the installer options if provided, otherwise it defaults to the current working directory.

func (*GitInstaller) GetInstallDir added in v1.4.0

func (i *GitInstaller) GetInstallDir() string

GetInstallDir returns the full path to the directory where the repository will be cloned. This is a combination of the destination directory and the base name of the repository.

func (*GitInstaller) GetOpts added in v1.4.0

func (i *GitInstaller) GetOpts() *GitOpts

GetOpts returns the parsed options for the GitInstaller.

func (*GitInstaller) GetRepositoryUrl added in v1.4.0

func (i *GitInstaller) GetRepositoryUrl() string

GetRepositoryUrl returns the URL of the Git repository. If the name in the installer data is a valid Git URL, it's returned directly. Otherwise, it's assumed to be a GitHub repository name (e.g., "owner/repo").

func (*GitInstaller) Install added in v1.4.0

func (i *GitInstaller) Install() error

Install implements IInstaller.

func (*GitInstaller) Update added in v1.4.0

func (i *GitInstaller) Update() error

Update implements IInstaller.

func (*GitInstaller) Validate added in v1.9.0

func (i *GitInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type GitOpts added in v1.4.0

type GitOpts struct {
	// Destination is the directory where the repository will be cloned.
	Destination *string
	// Ref is the Git reference (branch, tag, or commit) to checkout.
	Ref *string
	// Flags is a string of additional flags to pass to git commands.
	Flags *string
	// InstallFlags is a string of additional flags to pass only to git clone.
	InstallFlags *string
	// UpdateFlags is a string of additional flags to pass only to git pull.
	UpdateFlags *string
}

GitOpts represents options for the GitInstaller.

type GoInstaller added in v1.30.1

type GoInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
}

GoInstaller is an installer for Go packages installed via `go install`.

func NewGoInstaller added in v1.30.1

func NewGoInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *GoInstaller

NewGoInstaller creates a new GoInstaller.

func (*GoInstaller) CheckIsInstalled added in v1.30.1

func (i *GoInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*GoInstaller) CheckNeedsUpdate added in v1.30.1

func (i *GoInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*GoInstaller) GetBinName added in v1.30.1

func (i *GoInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it derives one from the last path component of the package name.

func (*GoInstaller) GetData added in v1.30.1

func (i *GoInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*GoInstaller) GetOpts added in v1.30.1

func (i *GoInstaller) GetOpts() *GoOpts

GetOpts returns the parsed options for the GoInstaller.

func (*GoInstaller) GetPackageRef added in v1.30.1

func (i *GoInstaller) GetPackageRef() string

GetPackageRef returns the package reference to pass to `go install`, in the form `<pkg>@<version>`. If Name already contains an `@` the version is taken from there; otherwise opts.version (or "latest") is used.

func (*GoInstaller) GetPinnedVersion added in v1.33.0

func (i *GoInstaller) GetPinnedVersion() string

GetPinnedVersion implements IVersionPinned. A module tracking `latest` is not pinned — it follows whatever the module proxy serves.

func (*GoInstaller) Install added in v1.30.1

func (i *GoInstaller) Install() error

Install implements IInstaller.

func (*GoInstaller) Update added in v1.30.1

func (i *GoInstaller) Update() error

Update implements IInstaller.

func (*GoInstaller) Validate added in v1.30.1

func (i *GoInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type GoOpts added in v1.30.1

type GoOpts struct {
	// Version is the module version to install (appended as `@version`).
	// Defaults to "latest" when neither this nor an inline `@version` on Name is set.
	Version *string
	// Flags is a string of additional flags to pass to the go install command.
	Flags *string
	// InstallFlags is a string of additional flags to pass only during install.
	InstallFlags *string
	// UpdateFlags is a string of additional flags to pass only during update.
	UpdateFlags *string
}

GoOpts represents options for the GoInstaller.

type GroupInstaller

type GroupInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Data is the installer data.
	Data *appconfig.InstallerData
	// contains filtered or unexported fields
}

GroupInstaller is an installer that groups other installers.

func NewGroupInstaller

func NewGroupInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *GroupInstaller

NewGroupInstaller creates a new GroupInstaller.

func (*GroupInstaller) CheckIsInstalled

func (i *GroupInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*GroupInstaller) CheckNeedsUpdate

func (i *GroupInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*GroupInstaller) GetBinName

func (i *GroupInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it uses the installer name.

func (*GroupInstaller) GetChildResults added in v1.17.0

func (i *GroupInstaller) GetChildResults() []summary.InstallResult

GetChildResults implements IChildResultsProvider.

func (*GroupInstaller) GetData added in v1.5.0

func (i *GroupInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*GroupInstaller) GetOpts

func (i *GroupInstaller) GetOpts() *GroupOpts

GetOpts returns the parsed options for the GroupInstaller.

func (*GroupInstaller) Install

func (i *GroupInstaller) Install() error

Install implements IInstaller.

func (*GroupInstaller) Update

func (i *GroupInstaller) Update() error

Update implements IInstaller.

func (*GroupInstaller) Validate added in v1.9.0

func (i *GroupInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type GroupOpts

type GroupOpts struct {
}

GroupOpts represents options for the GroupInstaller.

type IChildResultsProvider added in v1.17.0

type IChildResultsProvider interface {
	// GetChildResults returns the results from nested installers.
	GetChildResults() []summary.InstallResult
}

IChildResultsProvider is an optional interface for installers that have nested results.

type IInstaller

type IInstaller interface {
	// GetData returns the installer data.
	GetData() *appconfig.InstallerData
	// CheckIsInstalled checks if the software is already installed.
	CheckIsInstalled() (bool, error)
	// CheckNeedsUpdate checks if an update is available for the software.
	CheckNeedsUpdate() (bool, error)
	// Install installs the software.
	Install() error
	// Update updates the software.
	Update() error
	// Validate validates the installer configuration.
	Validate() []ValidationError
	// SetTemplateVars sets the template variables for string expansion.
	SetTemplateVars(vars *TemplateVars)
	// GetTemplateVars returns the template variables.
	GetTemplateVars() *TemplateVars
}

IInstaller defines the interface for all installers.

func GetInstaller

func GetInstaller(config *appconfig.AppConfig, data *appconfig.InstallerData) (IInstaller, error)

GetInstaller returns an IInstaller instance based on the installer type.

type IVersionPinned added in v1.33.0

type IVersionPinned interface {
	// GetPinnedVersion returns the pinned version, or an empty string when the installer
	// follows the newest available version.
	GetPinnedVersion() string
}

IVersionPinned is implemented by installers whose package manager can install an exact version. A pinned installer does not follow the newest release: sofmani records the version it installed, and reports an update only once the pin in the manifest changes.

type InstallerBase added in v1.8.0

type InstallerBase struct {
	// Data is the installer data.
	Data *appconfig.InstallerData
	// TemplateVars holds template variables for string expansion in commands and hooks.
	TemplateVars *TemplateVars
}

InstallerBase provides a base implementation for common installer functionality.

func (*InstallerBase) BaseValidate added in v1.9.0

func (i *InstallerBase) BaseValidate() []ValidationError

BaseValidate performs basic validation common to all installers.

func (*InstallerBase) GetData added in v1.8.0

func (i *InstallerBase) GetData() *appconfig.InstallerData

GetData returns the installer data.

func (*InstallerBase) GetTemplateVars added in v1.22.0

func (i *InstallerBase) GetTemplateVars() *TemplateVars

GetTemplateVars returns the template variables.

func (*InstallerBase) HasCustomInstallCheck added in v1.8.0

func (i *InstallerBase) HasCustomInstallCheck() bool

HasCustomInstallCheck checks if a custom install check command is defined.

func (*InstallerBase) HasCustomUpdateCheck added in v1.8.0

func (i *InstallerBase) HasCustomUpdateCheck() bool

HasCustomUpdateCheck checks if a custom update check command is defined.

func (*InstallerBase) IsVerbose added in v1.23.0

func (i *InstallerBase) IsVerbose() bool

IsVerbose returns true if verbose output is enabled for this installer.

func (*InstallerBase) RunCmdAsFile added in v1.8.0

func (i *InstallerBase) RunCmdAsFile(command string) error

RunCmdAsFile runs a command as a temporary file. Template variables are applied to the command before execution.

func (*InstallerBase) RunCmdGetOutput added in v1.8.0

func (i *InstallerBase) RunCmdGetOutput(command string, args ...string) ([]byte, error)

RunCmdGetOutput runs a command and returns its output.

func (*InstallerBase) RunCmdGetSuccess added in v1.8.0

func (i *InstallerBase) RunCmdGetSuccess(command string, args ...string) (bool, error)

RunCmdGetSuccess runs a command and returns true if it succeeds (exit code 0).

func (*InstallerBase) RunCmdGetSuccessPassThrough added in v1.9.4

func (i *InstallerBase) RunCmdGetSuccessPassThrough(command string, args ...string) (bool, error)

RunCmdGetSuccessPassThrough runs a command, passes through its output, and returns true if it succeeds.

func (*InstallerBase) RunCmdPassThrough added in v1.8.0

func (i *InstallerBase) RunCmdPassThrough(command string, args ...string) error

RunCmdPassThrough runs a command and passes through its output.

func (*InstallerBase) RunCustomInstallCheck added in v1.8.0

func (i *InstallerBase) RunCustomInstallCheck() (bool, error)

RunCustomInstallCheck runs a custom command to check if the software is installed.

func (*InstallerBase) RunCustomUpdateCheck added in v1.8.0

func (i *InstallerBase) RunCustomUpdateCheck() (bool, error)

RunCustomUpdateCheck runs a custom command to check for updates.

func (*InstallerBase) SetTemplateVars added in v1.22.0

func (i *InstallerBase) SetTemplateVars(vars *TemplateVars)

SetTemplateVars sets the template variables for string expansion.

type ManifestInherit added in v1.35.0

type ManifestInherit struct {
	// Env covers both `env` and `platform_env`.
	Env            bool `yaml:"env"`
	Defaults       bool `yaml:"defaults"`
	RepoUpdate     bool `yaml:"repo_update"`
	MachineAliases bool `yaml:"machine_aliases"`
	CheckUpdates   bool `yaml:"check_updates"`
}

ManifestInherit selects which global settings a loaded manifest inherits. In YAML it is either a boolean covering every setting, or a map of setting name to boolean where omitted settings are not inherited. A manifest inherits nothing unless asked to, so a remote manifest never sees the loading config's env by accident.

type ManifestInstaller added in v1.4.0

type ManifestInstaller struct {
	InstallerBase
	// Config is the main application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data for this manifest installer.
	Info *appconfig.InstallerData
	// ManifestConfig is the configuration loaded from the manifest file.
	ManifestConfig *appconfig.AppConfig
	// contains filtered or unexported fields
}

ManifestInstaller is an installer that installs software based on another sofmani manifest file.

func NewManifestInstaller added in v1.4.0

func NewManifestInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *ManifestInstaller

func (*ManifestInstaller) CheckIsInstalled added in v1.4.0

func (i *ManifestInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*ManifestInstaller) CheckNeedsUpdate added in v1.4.0

func (i *ManifestInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*ManifestInstaller) FetchManifest added in v1.4.0

func (i *ManifestInstaller) FetchManifest() error

FetchManifest fetches and parses the manifest file. It handles local files, Git repository URLs, and raw HTTP URLs.

func (*ManifestInstaller) GetChildResults added in v1.17.0

func (i *ManifestInstaller) GetChildResults() []summary.InstallResult

GetChildResults implements IChildResultsProvider.

func (*ManifestInstaller) GetData added in v1.5.0

GetData implements IInstaller.

func (*ManifestInstaller) GetOpts added in v1.4.0

func (i *ManifestInstaller) GetOpts() *ManifestOpts

GetOpts returns the parsed options for the ManifestInstaller.

func (*ManifestInstaller) Install added in v1.4.0

func (i *ManifestInstaller) Install() error

Install implements IInstaller.

func (*ManifestInstaller) Update added in v1.4.0

func (i *ManifestInstaller) Update() error

Update implements IInstaller.

func (*ManifestInstaller) Validate added in v1.9.0

func (i *ManifestInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type ManifestOpts added in v1.4.0

type ManifestOpts struct {
	// Source is the source of the manifest file. It can be a local path or a Git URL.
	Source *string
	// Path is the path to the manifest file within the source (if applicable, e.g., in a Git repository).
	Path *string
	// Ref is the Git reference (branch, tag, or commit) to use if the source is a Git URL.
	Ref *string
	// Inherit selects which global settings the loaded manifest receives from the config that loads it.
	Inherit ManifestInherit
	// Overrides holds global settings applied on top of everything else the loaded manifest ends up with.
	Overrides *ManifestSettings
}

ManifestOpts represents options for the ManifestInstaller.

type ManifestSettings added in v1.35.0

type ManifestSettings struct {
	CheckUpdates   *bool                                                 `yaml:"check_updates"`
	RepoUpdate     *map[appconfig.InstallerType]appconfig.RepoUpdateMode `yaml:"repo_update"`
	Defaults       *appconfig.AppConfigDefaults                          `yaml:"defaults"`
	Env            *map[string]string                                    `yaml:"env"`
	PlatformEnv    *platform.PlatformMap[map[string]string]              `yaml:"platform_env"`
	MachineAliases *map[string]string                                    `yaml:"machine_aliases"`
}

ManifestSettings are the global settings a manifest installer can pass to the manifest it loads.

type MockInstaller added in v1.10.0

type MockInstaller struct {
	// contains filtered or unexported fields
}

MockInstaller is a mock implementation of the IInstaller interface for testing.

func (*MockInstaller) CheckIsInstalled added in v1.10.0

func (m *MockInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled simulates checking if the software is installed.

func (*MockInstaller) CheckNeedsUpdate added in v1.10.0

func (m *MockInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate simulates checking if an update is needed.

func (*MockInstaller) GetData added in v1.10.0

func (m *MockInstaller) GetData() *appconfig.InstallerData

GetData returns the installer data for the mock installer.

func (*MockInstaller) GetTemplateVars added in v1.22.0

func (m *MockInstaller) GetTemplateVars() *TemplateVars

GetTemplateVars returns the template variables for the mock installer.

func (*MockInstaller) Install added in v1.10.0

func (m *MockInstaller) Install() error

Install simulates installing the software.

func (*MockInstaller) SetTemplateVars added in v1.22.0

func (m *MockInstaller) SetTemplateVars(vars *TemplateVars)

SetTemplateVars sets the template variables for the mock installer.

func (*MockInstaller) Update added in v1.10.0

func (m *MockInstaller) Update() error

Update simulates updating the software.

func (*MockInstaller) Validate added in v1.10.0

func (m *MockInstaller) Validate() []ValidationError

Validate simulates validating the installer configuration.

type NpmInstaller added in v1.1.0

type NpmInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// PackageManager is the package manager to use (npm, pnpm, or yarn).
	PackageManager NpmPackageManager
	// Info is the installer data.
	Info *appconfig.InstallerData
}

NpmInstaller is an installer for npm, pnpm, and yarn packages.

func NewNpmInstaller added in v1.1.0

func NewNpmInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *NpmInstaller

NewNpmInstaller creates a new NpmInstaller.

func (*NpmInstaller) CheckIsInstalled added in v1.1.0

func (i *NpmInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*NpmInstaller) CheckNeedsUpdate added in v1.1.0

func (i *NpmInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*NpmInstaller) GetBinName added in v1.1.0

func (i *NpmInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it uses the installer name with any `@version` suffix stripped.

func (*NpmInstaller) GetData added in v1.5.0

func (i *NpmInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*NpmInstaller) GetOpts added in v1.1.0

func (i *NpmInstaller) GetOpts() *NpmOpts

GetOpts returns the parsed options for the NpmInstaller.

func (*NpmInstaller) GetPackageSpec added in v1.33.0

func (i *NpmInstaller) GetPackageSpec() string

GetPackageSpec returns the package argument passed to the package manager, as `<name>@<version>` when a version is pinned.

func (*NpmInstaller) GetPinnedVersion added in v1.33.0

func (i *NpmInstaller) GetPinnedVersion() string

GetPinnedVersion implements IVersionPinned. The version may come from opts.version or from a `@version` suffix on the package name.

func (*NpmInstaller) Install added in v1.1.0

func (i *NpmInstaller) Install() error

Install implements IInstaller.

func (*NpmInstaller) Update added in v1.1.0

func (i *NpmInstaller) Update() error

Update implements IInstaller.

func (*NpmInstaller) Validate added in v1.9.0

func (i *NpmInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type NpmOpts added in v1.1.0

type NpmOpts struct {
	// Version pins the package to an exact version, appended as `@version`.
	// Ignored when Name already carries a `@version` suffix.
	Version *string
	// Flags is a string of additional flags to pass to the npm/pnpm/yarn command.
	Flags *string
	// InstallFlags is a string of additional flags to pass only during install.
	InstallFlags *string
	// UpdateFlags is a string of additional flags to pass only during update.
	UpdateFlags *string
}

NpmOpts represents options for the NpmInstaller.

type NpmPackageManager added in v1.10.0

type NpmPackageManager string

NpmPackageManager represents a Node.js package manager type. This type is also defined in apt_installer.go. Consider refactoring to a common location if appropriate.

const (
	PackageManagerNpm  NpmPackageManager = "npm"  // PackageManagerNpm represents the npm package manager.
	PackageManagerYarn NpmPackageManager = "yarn" // PackageManagerYarn represents the yarn package manager.
	PackageManagerPnpm NpmPackageManager = "pnpm" // PackageManagerPnpm represents the pnpm package manager.
)

Constants for supported Node.js package managers.

type PacmanInstaller added in v1.12.0

type PacmanInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
	// PackageManager is the package manager to use (pacman or yay).
	PackageManager PacmanPackageManager
}

PacmanInstaller is an installer for pacman and yay packages.

func NewPacmanInstaller added in v1.12.0

func NewPacmanInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *PacmanInstaller

NewPacmanInstaller creates a new PacmanInstaller.

func (*PacmanInstaller) CheckIsInstalled added in v1.12.0

func (i *PacmanInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*PacmanInstaller) CheckNeedsUpdate added in v1.12.0

func (i *PacmanInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*PacmanInstaller) GetBinName added in v1.12.0

func (i *PacmanInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it uses the installer name.

func (*PacmanInstaller) GetData added in v1.12.0

func (i *PacmanInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*PacmanInstaller) GetOpts added in v1.12.0

func (i *PacmanInstaller) GetOpts() *PacmanOpts

GetOpts returns the parsed options for the PacmanInstaller.

func (*PacmanInstaller) Install added in v1.12.0

func (i *PacmanInstaller) Install() error

Install implements IInstaller.

func (*PacmanInstaller) Update added in v1.12.0

func (i *PacmanInstaller) Update() error

Update implements IInstaller.

func (*PacmanInstaller) Validate added in v1.12.0

func (i *PacmanInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type PacmanOpts added in v1.12.0

type PacmanOpts struct {
	// Needed skips reinstalling up-to-date packages (--needed flag).
	Needed *bool
	// Flags is a string of additional flags to pass to the pacman/yay command.
	Flags *string
	// InstallFlags is a string of additional flags to pass only during install.
	InstallFlags *string
	// UpdateFlags is a string of additional flags to pass only during update.
	UpdateFlags *string
}

PacmanOpts represents options for the PacmanInstaller.

type PacmanPackageManager added in v1.12.0

type PacmanPackageManager string

PacmanPackageManager represents an Arch Linux package manager type.

const (
	PackageManagerPacman PacmanPackageManager = "pacman" // PackageManagerPacman represents the pacman package manager.
	PackageManagerYay    PacmanPackageManager = "yay"    // PackageManagerYay represents the yay AUR helper.
)

Constants for supported Arch Linux package managers.

type PipxInstaller added in v1.7.0

type PipxInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
}

PipxInstaller is an installer for pipx packages.

func NewPipxInstaller added in v1.7.0

func NewPipxInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *PipxInstaller

NewPipxInstaller creates a new PipxInstaller.

func (*PipxInstaller) CheckIsInstalled added in v1.7.0

func (i *PipxInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*PipxInstaller) CheckNeedsUpdate added in v1.7.0

func (i *PipxInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*PipxInstaller) GetBinName added in v1.7.0

func (i *PipxInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it uses the installer name with any version requirement stripped.

func (*PipxInstaller) GetData added in v1.7.0

func (i *PipxInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*PipxInstaller) GetOpts added in v1.7.0

func (i *PipxInstaller) GetOpts() *PipxOpts

GetOpts returns the parsed options for the PipxInstaller.

func (*PipxInstaller) GetPackageSpec added in v1.33.0

func (i *PipxInstaller) GetPackageSpec() string

GetPackageSpec returns the package argument passed to pipx, as `<name>==<version>` when a version is pinned.

func (*PipxInstaller) GetPinnedVersion added in v1.33.0

func (i *PipxInstaller) GetPinnedVersion() string

GetPinnedVersion implements IVersionPinned.

func (*PipxInstaller) Install added in v1.7.0

func (i *PipxInstaller) Install() error

Install implements IInstaller.

func (*PipxInstaller) Update added in v1.7.0

func (i *PipxInstaller) Update() error

Update implements IInstaller.

func (*PipxInstaller) Validate added in v1.9.0

func (i *PipxInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type PipxOpts added in v1.7.0

type PipxOpts struct {
	// Version pins the package to an exact version, appended as `==version`.
	// Ignored when Name already carries a version specifier.
	Version *string
	// Flags is a string of additional flags to pass to the pipx command.
	Flags *string
	// InstallFlags is a string of additional flags to pass only during install.
	InstallFlags *string
	// UpdateFlags is a string of additional flags to pass only during update.
	UpdateFlags *string
}

PipxOpts represents options for the PipxInstaller.

type RsyncInstaller

type RsyncInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
}

RsyncInstaller is an installer that uses rsync to copy files.

func NewRsyncInstaller

func NewRsyncInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *RsyncInstaller

NewRsyncInstaller creates a new RsyncInstaller.

func (*RsyncInstaller) CheckIsInstalled

func (i *RsyncInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*RsyncInstaller) CheckNeedsUpdate

func (i *RsyncInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*RsyncInstaller) GetBinName

func (i *RsyncInstaller) GetBinName() string

GetBinName returns the binary name for the installer. For rsync, this is typically not applicable as it's a file transfer, not a binary installation. It defaults to the installer name.

func (*RsyncInstaller) GetData added in v1.5.0

func (i *RsyncInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*RsyncInstaller) GetOpts

func (i *RsyncInstaller) GetOpts() *RsyncOpts

GetOpts returns the parsed options for the RsyncInstaller.

func (*RsyncInstaller) Install

func (i *RsyncInstaller) Install() error

Install implements IInstaller.

func (*RsyncInstaller) Update

func (i *RsyncInstaller) Update() error

Update implements IInstaller.

func (*RsyncInstaller) Validate added in v1.9.0

func (i *RsyncInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type RsyncOpts

type RsyncOpts struct {
	// Source is the source directory or file.
	Source *string
	// Destination is the destination directory or file.
	Destination *string
	// Flags is a string of flags to pass to the rsync command.
	Flags *string
}

RsyncOpts represents options for the RsyncInstaller.

type ShellInstaller

type ShellInstaller struct {
	InstallerBase
	// Config is the application configuration.
	Config *appconfig.AppConfig
	// Info is the installer data.
	Info *appconfig.InstallerData
}

ShellInstaller is an installer that runs shell commands.

func NewShellInstaller

func NewShellInstaller(cfg *appconfig.AppConfig, installer *appconfig.InstallerData) *ShellInstaller

NewShellInstaller creates a new ShellInstaller.

func (*ShellInstaller) CheckIsInstalled

func (i *ShellInstaller) CheckIsInstalled() (bool, error)

CheckIsInstalled implements IInstaller.

func (*ShellInstaller) CheckNeedsUpdate

func (i *ShellInstaller) CheckNeedsUpdate() (bool, error)

CheckNeedsUpdate implements IInstaller.

func (*ShellInstaller) GetBinName

func (i *ShellInstaller) GetBinName() string

GetBinName returns the binary name for the installer. It uses the BinName from the installer data if provided, otherwise it uses the installer name.

func (*ShellInstaller) GetData added in v1.5.0

func (i *ShellInstaller) GetData() *appconfig.InstallerData

GetData implements IInstaller.

func (*ShellInstaller) GetOpts

func (i *ShellInstaller) GetOpts() *ShellOpts

GetOpts returns the parsed options for the ShellInstaller.

func (*ShellInstaller) Install

func (i *ShellInstaller) Install() error

Install implements IInstaller.

func (*ShellInstaller) Update

func (i *ShellInstaller) Update() error

Update implements IInstaller.

func (*ShellInstaller) Validate added in v1.9.0

func (i *ShellInstaller) Validate() []ValidationError

Validate validates the installer configuration.

type ShellOpts

type ShellOpts struct {
	// Command is the shell command to run for installation.
	Command *string
	// UpdateCommand is the shell command to run for updating. If not provided, the install command is used.
	UpdateCommand *string
}

ShellOpts represents options for the ShellInstaller.

type TemplateVarDescription added in v1.30.0

type TemplateVarDescription struct {
	// Name is the Go template form, e.g., "{{ .Arch }}".
	Name string
	// Value is the resolved value for the current platform, or "" when not applicable.
	Value string
	// Note explains when a value is unset (e.g., "set at install time").
	Note string
}

TemplateVarDescription describes a single template variable for display purposes (e.g., the --vars CLI output).

func DescribeTemplateVars added in v1.30.0

func DescribeTemplateVars(vars *TemplateVars) []TemplateVarDescription

DescribeTemplateVars returns a stable, ordered list of all template variables along with their current values for the calling platform. Variables that only have a value at install time (Tag/Version, custom extract context) carry an explanatory Note instead.

type TemplateVars added in v1.13.0

type TemplateVars struct {
	// Tag is the full tag name (e.g., "v1.0.0").
	Tag string
	// Version is the version without the leading "v" (e.g., "1.0.0").
	Version string
	// Arch is the system architecture in Go format (e.g., "amd64", "arm64").
	Arch string
	// ArchAlias is the system architecture in common alias format (e.g., "x86_64", "arm64").
	ArchAlias string
	// ArchGnu is the system architecture in GNU/Linux format (e.g., "x86_64", "aarch64").
	ArchGnu string
	// OS is the current operating system (e.g., "macos", "linux", "windows").
	OS string
	// DeviceID is the unique machine identifier (truncated SHA-256 hash).
	DeviceID string
	// DeviceIDAlias is the friendly alias for the current machine, if one is defined in machine_aliases.
	DeviceIDAlias string
	// DownloadFile is the absolute path to the downloaded asset. Only populated for
	// github-release custom extract commands.
	DownloadFile string
	// ExtractDir is the temp directory where a custom extract command should place
	// extracted files. Only populated for github-release custom extract commands.
	ExtractDir string
	// Destination is the final destination directory. Only populated for github-release
	// custom extract commands.
	Destination string
	// BinName is the expected output binary name. Only populated for github-release
	// custom extract commands.
	BinName string
	// ArchiveBinName is the filename sofmani will copy from ExtractDir to Destination
	// after the custom extract command finishes. Only populated for github-release
	// custom extract commands.
	ArchiveBinName string
}

TemplateVars holds variables available for template replacement.

func NewTemplateVars added in v1.13.0

func NewTemplateVars(tag string, machineAliases map[string]string) *TemplateVars

NewTemplateVars creates a new TemplateVars with the provided tag and current system info. The machineAliases parameter is a map of friendly names to machine IDs, used to resolve DeviceIDAlias.

type ValidationError added in v1.9.0

type ValidationError struct {
	// FieldName is the name of the field that failed validation.
	FieldName string
	// Message is a description of the validation error.
	Message string
	// InstallerName is the name of the installer where the validation error occurred.
	InstallerName string
}

ValidationError represents a validation error for an installer configuration.

func (ValidationError) Error added in v1.9.0

func (v ValidationError) Error() string

Error returns a string representation of the validation error.

Jump to

Keyboard shortcuts

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