Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyPlatformOverrides(tool *registry.Tool)
- func ApplyPlatformOverridesForPlatform(tool *registry.Tool, goos, goarch string)
- func EnsureWindowsExeExtension(binaryName string) string
- func ExtractTarGz(src, dest string) error
- func FormatPlatformError(err *PlatformError) string
- func MoveFile(src, dst string) error
- func Unzip(src, dest string) error
- type DefaultToolResolver
- type InstalledTool
- type Installer
- func (i *Installer) BuildAssetURL(tool *registry.Tool, version string) (string, error)
- func (i *Installer) CreateLatestFile(owner, repo, version string) error
- func (i *Installer) FindBinaryPath(owner, repo, version string, binaryName ...string) (string, error)
- func (i *Installer) FindTool(owner, repo, version string) (*registry.Tool, error)
- func (i *Installer) GetBinDir() string
- func (i *Installer) GetBinaryPath(owner, repo, version, binaryName string) string
- func (i *Installer) GetBinaryPaths(owner, repo, version string) []string
- func (i *Installer) GetResolver() ToolResolver
- func (i *Installer) Install(owner, repo, version string) (string, error)
- func (i *Installer) ListAllInstalledTools() ([]InstalledTool, error)
- func (i *Installer) ListInstalledVersions(owner, repo string) ([]string, error)
- func (i *Installer) ParseToolSpec(tool string) (string, string, error)
- func (i *Installer) ReadLatestFile(owner, repo string) (string, error)
- func (i *Installer) Uninstall(owner, repo, version string) error
- type Option
- func WithAtmosConfig(config *schema.AtmosConfiguration) Option
- func WithBinDir(binDir string) Option
- func WithCacheDir(cacheDir string) Option
- func WithConfiguredRegistry(reg registry.ToolRegistry) Option
- func WithRegistryFactory(factory RegistryFactory) Option
- func WithResolver(resolver ToolResolver) Option
- type PlatformError
- type RegistryFactory
- type ToolResolver
Constants ¶
const (
// VersionPrefix is the standard version prefix for tools.
VersionPrefix = "v"
)
Variables ¶
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 // ErrLockfileIO indicates a lockfile read/write operation failed. ErrLockfileIO = errors.New("toolchain lockfile I/O failed") // ErrLockfileParse indicates the lockfile contents could not be parsed. ErrLockfileParse = errors.New("toolchain lockfile parse failed") ErrVerifierVersionUnavailable = errors.New("verifier version unavailable") // ErrVerifierTrustFailed indicates Atmos could not mark a bootstrap-installed // verifier binary as locally trusted (macOS-only; not a fatal condition). ErrVerifierTrustFailed = errors.New("failed to mark verifier binary as trusted") )
Error re-exports from the registry package. These are the primary errors used by the installer package.
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 ¶
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 ApplyPlatformOverridesForPlatform ¶ added in v1.220.0
func EnsureWindowsExeExtension ¶
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 ¶
ExtractTarGz extracts a tar.gz archive, materializing hard links and discarding deferred symlinks (callers that preserve a tree use unpackTarGz).
func FormatPlatformError ¶
func FormatPlatformError(err *PlatformError) string
FormatPlatformError formats a PlatformError into a user-friendly string.
Types ¶
type DefaultToolResolver ¶
type DefaultToolResolver struct {
AtmosConfig *schema.AtmosConfiguration
}
DefaultToolResolver implements ToolResolver using configured aliases and registry search.
type InstalledTool ¶ added in v1.210.0
InstalledTool represents a tool found in the install directory with its versions.
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
Installer handles the installation of CLI binaries.
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 ¶
BuildAssetURL constructs the asset download URL based on tool configuration.
func (*Installer) CreateLatestFile ¶
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) GetBinaryPath ¶
GetBinaryPath returns the path to a specific version of a binary. If binaryName is provided and non-empty, it names the desired entrypoint; otherwise the tool's primary entrypoint is used. Onedir (multi-file) installs resolve the entrypoint's real (nested) path through the sidecar manifest; flat installs fall back to the version-dir root, auto-detecting an executable or using the repo name.
func (*Installer) GetBinaryPaths ¶ added in v1.223.0
GetBinaryPaths returns every installed entrypoint path for a version. A onedir (multi-file) package exposes multiple commands that may live in different directories inside the preserved .pkg tree, so all of them are returned (for example so callers can add each command's directory to PATH). It returns nil for a flat install (no manifest); callers should fall back to GetBinaryPath.
func (*Installer) GetResolver ¶
func (i *Installer) GetResolver() ToolResolver
GetResolver returns the tool resolver used by this installer.
func (*Installer) ListAllInstalledTools ¶ added in v1.210.0
func (i *Installer) ListAllInstalledTools() ([]InstalledTool, error)
ListAllInstalledTools scans the install directory and returns all installed tools. It walks two levels deep: binDir/{owner}/{repo}/ and collects version directories.
func (*Installer) ListInstalledVersions ¶
ListInstalledVersions returns a list of installed versions for a specific tool.
func (*Installer) ParseToolSpec ¶
ParseToolSpec parses a tool specification (owner/repo or just repo).
func (*Installer) ReadLatestFile ¶
ReadLatestFile reads the version from a "latest" file.
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 ¶
WithBinDir sets the binary installation directory.
func WithCacheDir ¶
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 ¶
PlatformError represents a platform compatibility error with helpful hints.
func CheckPlatformSupport ¶
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. Supports Rosetta 2 fallback (darwin/arm64 → darwin/amd64) and Windows ARM emulation.
func (*PlatformError) Error ¶
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 ¶
ToolResolver defines an interface for resolving tool names to owner/repo pairs This allows for mocking in tests and flexible resolution in production.