Documentation
¶
Index ¶
- Variables
- func AddToolToVersions(filePath, tool, version string) error
- func AddToolToVersionsAsDefault(filePath, tool, version string) error
- func AddToolVersion(tool, version string) error
- func AddVersionToTool(toolVersions *ToolVersions, tool, version string, asDefault bool)
- func CleanToolsAndCaches(toolsDir, cacheDir, tempCacheDir string) error
- func DuExec() error
- func EmitEnv(format string, relativeFlag bool) error
- func EmitPath(exportFlag, jsonFlag, relativeFlag bool) error
- func ExtractTarGz(src, dest string) error
- func GetAllVersions(toolVersions *ToolVersions, tool string) []string
- func GetAtmosConfig() *schema.AtmosConfiguration
- func GetDefaultVersion(toolVersions *ToolVersions, tool string) (string, bool)
- func GetInstallPath() string
- func GetToolVersionsFilePath() string
- func InfoExec(toolName, outputFormat string) error
- func InstallSingleTool(owner, repo, version string, isLatest bool, showProgressBar bool) error
- func ListToolVersions(showAll bool, limit int, toolName string) error
- func LookupToolVersion(tool string, toolVersions *ToolVersions, resolver ToolResolver) (resolvedKey, version string, found bool)
- func MoveFile(src, dst string) error
- func NewAquaRegistry() registry.ToolRegistry
- func NewRegistry(atmosConfig *schema.AtmosConfiguration) (registry.ToolRegistry, error)
- func ParseToolVersionArg(arg string) (string, string, error)
- func RemoveToolFromVersions(filePath, tool, version string) error
- func RemoveToolVersion(filePath, tool, version string) error
- func ResetGitHubAPI()
- func RunExecCommand(installer ToolRunner, args []string) error
- func RunInstall(toolSpec string, setAsDefault, reinstallFlag bool) error
- func RunList() error
- func RunListAtmosVersions() ([]string, error)
- func RunListInstalledAtmosVersions(currentVersion string) error
- func RunUninstall(toolSpec string) error
- func SaveToolVersions(filePath string, toolVersions *ToolVersions) error
- func SetAtmosConfig(config *schema.AtmosConfiguration)
- func SetGitHubAPI(api GitHubAPI)
- func SetToolVersion(toolName, version string, scrollSpeed int) error
- func Unzip(src, dest string) error
- func WhichExec(toolName string) error
- type AquaRegistry
- type DefaultToolResolver
- type File
- type GitHubAPI
- type GitHubAPIClient
- type Installer
- func (i *Installer) CreateLatestFile(owner, repo, version string) error
- func (i *Installer) FindBinaryPath(owner, repo, version string, binaryName ...string) (string, error)
- 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) ReadLatestFile(owner, repo string) (string, error)
- func (i *Installer) Uninstall(owner, repo, version string) error
- type ModelI
- type Override
- type Tool
- type ToolPath
- type ToolResolver
- type ToolRunner
- type ToolVersionLookupResult
- type ToolVersions
Constants ¶
This section is empty.
Variables ¶
var ( // 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 for backward compatibility. New code should import and use toolchain/registry errors directly.
var ( DefaultToolVersionsFilePath = ".tool-versions" DefaultInstallPath = ".tools" )
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 AddToolToVersions ¶
AddToolToVersions adds a tool/version combination to the .tool-versions file If the tool already exists, it updates the version If the aliased version already exists, it skips adding the non-aliased version to prevent duplicates.
func AddToolToVersionsAsDefault ¶
AddToolToVersionsAsDefault adds a tool and version to the .tool-versions file as the default If the tool already exists, it updates the version and sets it as default.
func AddToolVersion ¶
AddToolVersion contains the actual business logic for adding/updating a tool.
func AddVersionToTool ¶
func AddVersionToTool(toolVersions *ToolVersions, tool, version string, asDefault bool)
AddVersionToTool adds a version to a tool, optionally as default (front of list).
func CleanToolsAndCaches ¶
CleanToolsAndCaches handles the business logic for cleaning tools and cache directories. It performs file counting, deletion, and writes UI messages to stderr.
func DuExec ¶
func DuExec() error
DuExec calculates and displays the total disk space used by installed tools.
func EmitEnv ¶
EmitEnv outputs the PATH entries for installed toolchain binaries in shell-specific format. The format parameter specifies the output format (bash, fish, powershell, json, dotenv), and relativeFlag uses relative paths instead of absolute.
func EmitPath ¶
EmitPath outputs the PATH entries for installed toolchain binaries. The exportFlag outputs in shell export format, jsonFlag outputs JSON, and relativeFlag uses relative paths instead of absolute.
func ExtractTarGz ¶
ExtractTarGz extracts a .tar.gz file to the given destination directory.
func GetAllVersions ¶
func GetAllVersions(toolVersions *ToolVersions, tool string) []string
GetAllVersions returns all versions for a tool.
func GetAtmosConfig ¶
func GetAtmosConfig() *schema.AtmosConfiguration
GetAtmosConfig returns the current Atmos configuration. Returns nil if not yet initialized.
func GetDefaultVersion ¶
func GetDefaultVersion(toolVersions *ToolVersions, tool string) (string, bool)
GetDefaultVersion returns the default (first) version for a tool.
func GetInstallPath ¶
func GetInstallPath() string
GetInstallPath returns the path where tools are installed. By default, it uses XDG Data directory (~/.local/share/atmos/toolchain on Linux/macOS). Falls back to .tools if XDG directory cannot be created.
func GetToolVersionsFilePath ¶
func GetToolVersionsFilePath() string
GetToolVersionsFilePath returns the path to the tool-versions file.
func InstallSingleTool ¶
func ListToolVersions ¶
ListToolVersions handles the logic for listing tool versions.
func LookupToolVersion ¶
func LookupToolVersion(tool string, toolVersions *ToolVersions, resolver ToolResolver) (resolvedKey, version string, found bool)
LookupToolVersion attempts to find the version for a tool, trying both the raw name and its resolved alias. Returns the key found (raw or alias), the version, and whether it was found.
func MoveFile ¶
MoveFile tries os.Rename, but if that fails due to cross-device link, it falls back to a copy+remove.
func NewAquaRegistry ¶
func NewAquaRegistry() registry.ToolRegistry
NewAquaRegistry creates a new Aqua registry client. This is a convenience wrapper that returns the default Aqua implementation.
func NewRegistry ¶
func NewRegistry(atmosConfig *schema.AtmosConfiguration) (registry.ToolRegistry, error)
NewRegistry creates a ToolRegistry from the given Atmos configuration. If registries are configured, returns a CompositeRegistry. Otherwise, returns the default Aqua registry for backward compatibility.
func ParseToolVersionArg ¶
ParseToolVersionArg parses a CLI argument in the form tool, tool@version, or owner/repo@version. Returns tool (or owner/repo), version (may be empty), and error if invalid.
func RemoveToolFromVersions ¶
RemoveToolFromVersions removes a tool from the .tool-versions file.
func RemoveToolVersion ¶
RemoveToolVersion removes either the entire tool or a specific version from the file. If version is empty, removes all versions of the tool.
func ResetGitHubAPI ¶
func ResetGitHubAPI()
ResetGitHubAPI resets the global GitHub API client to the default.
func RunExecCommand ¶
func RunExecCommand(installer ToolRunner, args []string) error
RunExecCommand contains business logic for executing tools. It does not depend on cobra.Command, only raw args.
func RunInstall ¶
RunInstall installs the specified tool (owner/repo@version or alias@version). If toolSpec is empty, installs all tools from .tool-versions file. The setAsDefault parameter controls whether to set the installed version as default. The reinstallFlag parameter forces reinstallation even if already installed.
func RunList ¶
func RunList() error
RunList prints a table of tools from .tool-versions, marking installed/default versions.
func RunListAtmosVersions ¶
RunListAtmosVersions lists all installed versions of Atmos (returns version strings).
func RunListInstalledAtmosVersions ¶
RunListInstalledAtmosVersions prints a formatted table of installed Atmos versions.
func RunUninstall ¶
RunUninstall removes tools by spec (owner/repo, tool, or ).
func SaveToolVersions ¶
func SaveToolVersions(filePath string, toolVersions *ToolVersions) error
SaveToolVersions saves a ToolVersions struct to a .tool-versions file (asdf-compatible).
func SetAtmosConfig ¶
func SetAtmosConfig(config *schema.AtmosConfiguration)
SetAtmosConfig injects the current Atmos configuration into the toolchain package.
func SetGitHubAPI ¶
func SetGitHubAPI(api GitHubAPI)
SetGitHubAPI sets the global GitHub API client (for testing).
func SetToolVersion ¶
SetToolVersion handles the core logic of setting a tool version. If version is empty, it will prompt the user interactively (for GitHub release type tools).
Types ¶
type AquaRegistry ¶
type AquaRegistry = aqua.AquaRegistry
AquaRegistry is a type alias for backward compatibility. New code should use toolchain/registry.ToolRegistry interface.
type DefaultToolResolver ¶
type DefaultToolResolver struct {
// contains filtered or unexported fields
}
DefaultToolResolver implements ToolResolver using configured aliases and registry search.
type GitHubAPIClient ¶
type GitHubAPIClient struct{}
GitHubAPIClient implements GitHubAPI using pkg/github.
func NewGitHubAPIClient ¶
func NewGitHubAPIClient() *GitHubAPIClient
NewGitHubAPIClient creates a new GitHub API client.
func (*GitHubAPIClient) FetchReleases ¶
func (g *GitHubAPIClient) FetchReleases(owner, repo string, limit int) ([]string, error)
FetchReleases fetches all available versions from GitHub API.
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
Installer handles the installation of CLI binaries.
func NewInstaller ¶
func NewInstaller() *Installer
NewInstaller uses the default resolver with alias support from atmosConfig.
func NewInstallerWithResolver ¶
func NewInstallerWithResolver(resolver ToolResolver) *Installer
NewInstallerWithResolver allows injecting a custom ToolResolver (for tests).
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) 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) ReadLatestFile ¶
ReadLatestFile reads the version from a "latest" file.
type Tool ¶
Tool is a type alias for registry.Tool for backward compatibility. New code should import and use toolchain/registry.Tool directly.
type ToolPath ¶
type ToolPath struct {
Tool string `json:"tool"`
Version string `json:"version"`
Path string `json:"path"`
}
ToolPath represents a tool with its version and path.
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.
type ToolRunner ¶
type ToolRunner interface {
FindBinaryPath(owner, repo, version string, binaryName ...string) (string, error)
GetResolver() ToolResolver
CreateLatestFile(owner, repo, version string) error
ReadLatestFile(owner, repo string) (string, error)
}
ToolRunner defines the interface for running and resolving tools (for real and mock installers).
type ToolVersionLookupResult ¶
type ToolVersionLookupResult struct {
ResolvedKey string // The key found (raw tool name or owner/repo alias).
Version string // The version string.
Found bool // Whether the tool was found in toolVersions.
UsedLatest bool // Whether 'latest' was used as a fallback.
}
ToolVersionLookupResult holds the result of looking up a tool version.
func LookupToolVersionOrLatest ¶
func LookupToolVersionOrLatest(tool string, toolVersions *ToolVersions, resolver ToolResolver) ToolVersionLookupResult
LookupToolVersionOrLatest attempts to find the version for a tool, trying both the raw name and its resolved alias. If not found, but the alias resolves, returns 'latest' as the version and usedLatest=true.
type ToolVersions ¶
ToolVersions represents the .tool-versions file format (asdf-compatible: tool -> list of versions, first is default).
func LoadToolVersions ¶
func LoadToolVersions(filePath string) (*ToolVersions, error)
LoadToolVersions loads a .tool-versions file (asdf-compatible: tool version1 [version2 ...]).
Source Files
¶
- add.go
- aqua_registry.go
- atmos_registry.go
- clean.go
- du.go
- env.go
- errors.go
- exec.go
- get.go
- github.go
- info.go
- info_helpers.go
- info_table_helpers.go
- install.go
- install_helpers.go
- install_validation_helpers.go
- installer.go
- installer_asset.go
- installer_download.go
- installer_extract.go
- installer_version.go
- list.go
- list_helpers.go
- list_table.go
- path.go
- path_helpers.go
- progress.go
- remove.go
- remove_helpers.go
- set.go
- set_helpers.go
- setup.go
- testing.go
- tool_versions.go
- types.go
- uninstall.go
- which.go