Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyPlatformOverrides(tool *registry.Tool)
- 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 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) GetResolver() ToolResolver
- func (i *Installer) Install(owner, repo, version string) (string, 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 )
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 EnsureWindowsExeExtension ¶ added in v1.205.0
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 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.
Types ¶
type DefaultToolResolver ¶
type DefaultToolResolver struct {
AtmosConfig *schema.AtmosConfiguration
}
DefaultToolResolver implements ToolResolver using configured aliases and registry search.
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 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) 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 ¶ added in v1.205.0
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 ¶
ToolResolver defines an interface for resolving tool names to owner/repo pairs This allows for mocking in tests and flexible resolution in production.