toolchain

package
v1.204.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
var (
	DefaultToolVersionsFilePath = ".tool-versions"
	DefaultInstallPath          = ".tools"
)
View Source
var BuiltinAliases = installer.BuiltinAliases

BuiltinAliases are always available and can be overridden in atmos.yaml.

Functions

func AddToolToVersions

func AddToolToVersions(filePath, tool, version string) error

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

func AddToolToVersionsAsDefault(filePath, tool, version string) error

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

func AddToolVersion(tool, version string) error

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

func CleanToolsAndCaches(toolsDir, cacheDir, tempCacheDir string) error

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

func EmitEnv(format string, relativeFlag bool) error

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

func EmitPath(exportFlag, jsonFlag, relativeFlag bool) error

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 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 InfoExec

func InfoExec(toolName, outputFormat string) error

InfoExec handles the core logic for retrieving and formatting tool information.

func InstallSingleTool

func InstallSingleTool(owner, repo, version string, opts InstallOptions) error

func ListToolVersions

func ListToolVersions(showAll bool, limit int, toolName string) error

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 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

func ParseToolVersionArg(arg string) (string, string, error)

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

func RemoveToolFromVersions(filePath, tool, version string) error

RemoveToolFromVersions removes a tool from the .tool-versions file.

func RemoveToolVersion

func RemoveToolVersion(filePath, tool, version string) error

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

func RunInstall(toolSpec string, setAsDefault, reinstallFlag, showHint, showProgressBar bool) error

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. The showHint parameter controls whether to show the PATH export hint message. The showProgressBar parameter controls whether to show spinner and success messages.

func RunInstallBatch added in v1.204.0

func RunInstallBatch(toolSpecs []string, reinstallFlag bool) error

RunInstallBatch installs multiple tools with batch progress display. Shows status messages scrolling up with a single progress bar at bottom. For single tools, delegates to RunInstall for simpler output.

func RunList

func RunList() error

RunList prints a table of tools from .tool-versions, marking installed/default versions.

func RunListAtmosVersions

func RunListAtmosVersions() ([]string, error)

RunListAtmosVersions lists all installed versions of Atmos (returns version strings).

func RunListInstalledAtmosVersions

func RunListInstalledAtmosVersions(currentVersion string) error

RunListInstalledAtmosVersions prints a formatted table of installed Atmos versions.

func RunUninstall

func RunUninstall(toolSpec string) error

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

func SetToolVersion(toolName, version string, scrollSpeed int) error

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).

func WhichExec

func WhichExec(toolName string) error

WhichExec prints the absolute path to the resolved tool binary for toolName (optionally with @version). Returns an error if the tool is not configured or not installed.

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 = installer.DefaultToolResolver

DefaultToolResolver is a type alias for installer.DefaultToolResolver for backward compatibility.

type File

type File = registry.File

File is a type alias for registry.File for backward compatibility.

type GitHubAPI

type GitHubAPI interface {
	FetchReleases(owner, repo string, limit int) ([]string, error)
}

GitHubAPI defines the interface for GitHub API operations.

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 InstallOptions added in v1.204.0

type InstallOptions struct {
	IsLatest               bool // Whether this is a "latest" version install.
	ShowProgressBar        bool // Whether to show spinner during install.
	ShowInstallDetails     bool // Whether to show detailed install messages (path, size, registered).
	ShowHint               bool // Whether to show PATH export hint after install.
	SkipToolVersionsUpdate bool // Skip .tool-versions update (caller handles it).
}

InstallOptions configures the behavior of InstallSingleTool.

type Installer

type Installer = installer.Installer

Installer is a type alias for installer.Installer for backward compatibility. New code should import and use toolchain/installer.Installer directly.

func NewInstaller

func NewInstaller(opts ...Option) *Installer

NewInstaller creates a new Installer with the given options. This is a wrapper around installer.New() for backward compatibility. It automatically injects the real registry factory and loads registries. Configuration is read from atmos.yaml.

func NewInstallerWithBinDir added in v1.204.0

func NewInstallerWithBinDir(binDir string) *Installer

NewInstallerWithBinDir creates an installer with a specific bin directory. This is a convenience wrapper for testing.

func NewInstallerWithResolver

func NewInstallerWithResolver(resolver ToolResolver, binDir string) *Installer

NewInstallerWithResolver creates an installer with a custom resolver. Deprecated: Use NewInstaller() with WithResolver() option instead.

type ModelI

type ModelI interface {
	Items() []list.Item
}

ModelI is the minimal list model interface used by customDelegate.

type Option added in v1.204.0

type Option = installer.Option

Option is a type alias for installer.Option for backward compatibility.

func WithAtmosConfig added in v1.204.0

func WithAtmosConfig(config *schema.AtmosConfiguration) Option

WithAtmosConfig sets the AtmosConfig for alias resolution.

func WithBinDir added in v1.204.0

func WithBinDir(binDir string) Option

WithBinDir sets the binary installation directory.

func WithCacheDir added in v1.204.0

func WithCacheDir(cacheDir string) Option

WithCacheDir sets the cache directory.

func WithConfiguredRegistry added in v1.204.0

func WithConfiguredRegistry(reg registry.ToolRegistry) Option

WithConfiguredRegistry sets a pre-configured registry.

func WithRegistryFactory added in v1.204.0

func WithRegistryFactory(factory RegistryFactory) Option

WithRegistryFactory sets the factory for creating registry instances.

func WithResolver added in v1.204.0

func WithResolver(resolver ToolResolver) Option

WithResolver sets the tool resolver.

type Override

type Override = registry.Override

Override is a type alias for registry.Override for backward compatibility.

type RegistryFactory added in v1.204.0

type RegistryFactory = installer.RegistryFactory

RegistryFactory is a type alias for installer.RegistryFactory for backward compatibility.

type Tool

type Tool = registry.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

type ToolResolver = installer.ToolResolver

ToolResolver is a type alias for installer.ToolResolver for backward compatibility.

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

type ToolVersions struct {
	Tools map[string][]string
}

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 ...]).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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