installer

package
v1.205.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VersionPrefix is the standard version prefix for tools.
	VersionPrefix = "v"
)

Variables

View Source
var (
	// ErrUnsupportedFormat indicates an unsupported archive or package format.
	ErrUnsupportedFormat = errors.New("unsupported format")

	// ErrToolNotFound indicates a tool was not found in the registry or local configuration.
	ErrToolNotFound = registry.ErrToolNotFound

	// ErrNoVersionsFound indicates no versions are available for a tool.
	ErrNoVersionsFound = registry.ErrNoVersionsFound

	// ErrInvalidToolSpec indicates the tool specification format is invalid.
	ErrInvalidToolSpec = registry.ErrInvalidToolSpec

	// ErrHTTPRequest indicates an HTTP request failed.
	ErrHTTPRequest = registry.ErrHTTPRequest

	// ErrHTTP404 indicates an HTTP 404 Not Found response.
	ErrHTTP404 = registry.ErrHTTP404

	// ErrRegistryParse indicates the registry file could not be parsed.
	ErrRegistryParse = registry.ErrRegistryParse

	// ErrNoPackagesInRegistry indicates the registry contains no packages.
	ErrNoPackagesInRegistry = registry.ErrNoPackagesInRegistry

	// ErrNoAssetTemplate indicates no asset template is defined for the tool.
	ErrNoAssetTemplate = registry.ErrNoAssetTemplate

	// ErrFileOperation indicates a file operation failed.
	ErrFileOperation = registry.ErrFileOperation

	// ErrToolAlreadyExists indicates the tool version already exists in .tool-versions.
	ErrToolAlreadyExists = registry.ErrToolAlreadyExists
)

Error re-exports from the registry package. These are the primary errors used by the installer package.

View Source
var BuiltinAliases = map[string]string{
	"atmos": "cloudposse/atmos",
}

BuiltinAliases are always available and can be overridden in atmos.yaml. These provide convenient shortcuts for common tools.

Functions

func ApplyPlatformOverrides

func ApplyPlatformOverrides(tool *registry.Tool)

ApplyPlatformOverrides applies platform-specific overrides to the tool configuration. If an override matches the current GOOS/GOARCH, it updates the tool's Asset, Format, Files, and Replacements fields accordingly. First matching override wins.

func EnsureWindowsExeExtension added in v1.205.0

func EnsureWindowsExeExtension(binaryName string) string

EnsureWindowsExeExtension appends .exe to the binary name on Windows if not already present. This follows Aqua's behavior where executables need the .exe extension on Windows to be found by os/exec.LookPath.

func ExtractTarGz

func ExtractTarGz(src, dest string) error

ExtractTarGz extracts a .tar.gz file to the given destination directory.

func FormatPlatformError added in v1.205.0

func FormatPlatformError(err *PlatformError) string

FormatPlatformError formats a PlatformError into a user-friendly string.

func MoveFile

func MoveFile(src, dst string) error

MoveFile tries os.Rename, but if that fails due to cross-device link, it falls back to a copy+remove.

func Unzip

func Unzip(src, dest string) error

Unzip extracts a zip archive to a destination directory. Works on Windows, macOS, and Linux.

Types

type DefaultToolResolver

type DefaultToolResolver struct {
	AtmosConfig *schema.AtmosConfiguration
}

DefaultToolResolver implements ToolResolver using configured aliases and registry search.

func (*DefaultToolResolver) Resolve

func (d *DefaultToolResolver) Resolve(toolName string) (string, string, error)

type Installer

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

Installer handles the installation of CLI binaries.

func New

func New(opts ...Option) *Installer

New creates a new Installer with the given options.

func NewInstallerWithResolver

func NewInstallerWithResolver(resolver ToolResolver, binDir string) *Installer

NewInstallerWithResolver allows injecting a custom ToolResolver (for tests). Deprecated: Use New() with WithResolver() option instead.

func (*Installer) BuildAssetURL

func (i *Installer) BuildAssetURL(tool *registry.Tool, version string) (string, error)

BuildAssetURL constructs the asset download URL based on tool configuration.

func (*Installer) CreateLatestFile

func (i *Installer) CreateLatestFile(owner, repo, version string) error

CreateLatestFile creates a "latest" file that contains a pointer to the actual version.

func (*Installer) FindBinaryPath

func (i *Installer) FindBinaryPath(owner, repo, version string, binaryName ...string) (string, error)

FindBinaryPath searches for a binary with the given owner, repo, and version. The binaryName parameter is optional - pass empty string to auto-detect.

func (*Installer) FindTool

func (i *Installer) FindTool(owner, repo, version string) (*registry.Tool, error)

FindTool searches for a tool in the registry.

func (*Installer) GetBinDir

func (i *Installer) GetBinDir() string

GetBinDir returns the binary installation directory.

func (*Installer) GetBinaryPath

func (i *Installer) GetBinaryPath(owner, repo, version, binaryName string) string

GetBinaryPath returns the path to a specific version of a binary. If binaryName is provided and non-empty, it will be used directly. Otherwise, it will search the version directory for an executable file, falling back to using the repo name as the binary name.

func (*Installer) GetResolver

func (i *Installer) GetResolver() ToolResolver

GetResolver returns the tool resolver used by this installer.

func (*Installer) Install

func (i *Installer) Install(owner, repo, version string) (string, error)

Install installs a tool from the registry.

func (*Installer) ListInstalledVersions

func (i *Installer) ListInstalledVersions(owner, repo string) ([]string, error)

ListInstalledVersions returns a list of installed versions for a specific tool.

func (*Installer) ParseToolSpec

func (i *Installer) ParseToolSpec(tool string) (string, string, error)

ParseToolSpec parses a tool specification (owner/repo or just repo).

func (*Installer) ReadLatestFile

func (i *Installer) ReadLatestFile(owner, repo string) (string, error)

ReadLatestFile reads the version from a "latest" file.

func (*Installer) Uninstall

func (i *Installer) Uninstall(owner, repo, version string) error

Uninstall removes a previously installed tool.

type Option

type Option func(*Installer)

Option is a functional option for configuring the Installer.

func WithAtmosConfig

func WithAtmosConfig(config *schema.AtmosConfiguration) Option

WithAtmosConfig sets the AtmosConfig on the default resolver for alias resolution. This must be called after the installer is created to update the default resolver.

func WithBinDir

func WithBinDir(binDir string) Option

WithBinDir sets the binary installation directory.

func WithCacheDir

func WithCacheDir(cacheDir string) Option

WithCacheDir sets the cache directory.

func WithConfiguredRegistry

func WithConfiguredRegistry(reg registry.ToolRegistry) Option

WithConfiguredRegistry sets a pre-configured registry.

func WithRegistryFactory

func WithRegistryFactory(factory RegistryFactory) Option

WithRegistryFactory sets the factory for creating registry instances.

func WithResolver

func WithResolver(resolver ToolResolver) Option

WithResolver sets the tool resolver.

type PlatformError added in v1.205.0

type PlatformError struct {
	Tool          string
	CurrentEnv    string
	SupportedEnvs []string
	Hints         []string
}

PlatformError represents a platform compatibility error with helpful hints.

func CheckPlatformSupport added in v1.205.0

func CheckPlatformSupport(tool *registry.Tool) *PlatformError

CheckPlatformSupport checks if the current platform is supported by the tool. Returns nil if supported, or a PlatformError with helpful hints if not.

func (*PlatformError) Error added in v1.205.0

func (e *PlatformError) Error() string

Error implements the error interface.

type RegistryFactory

type RegistryFactory interface {
	NewAquaRegistry() registry.ToolRegistry
}

RegistryFactory creates registry instances. This allows dependency injection.

type ToolResolver

type ToolResolver interface {
	Resolve(toolName string) (owner, repo string, err error)
}

ToolResolver defines an interface for resolving tool names to owner/repo pairs This allows for mocking in tests and flexible resolution in production.

Jump to

Keyboard shortcuts

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