Base
provide.foundation.tools.base
¶
Base classes for tool management.
This module provides the foundation for tool managers, including the base manager class and metadata structures.
Classes¶
BaseToolManager
¶
Bases: ABC
Abstract base class for tool managers.
Provides common functionality for downloading, verifying, and installing development tools. Subclasses must implement platform-specific logic.
Attributes:
| Name | Type | Description |
|---|---|---|
config |
Configuration object. |
|
tool_name |
str
|
Name of the tool being managed. |
executable_name |
str
|
Name of the executable file. |
supported_platforms |
list[str]
|
List of supported platforms. |
Initialize the tool manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BaseConfig
|
Configuration object containing settings. |
required |
Source code in provide/foundation/tools/base.py
Attributes¶
Functions¶
get_available_versions
abstractmethod
¶
get_install_path
¶
get_metadata
abstractmethod
¶
Get metadata for a specific version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
Version string to get metadata for. |
required |
Returns:
| Type | Description |
|---|---|
ToolMetadata
|
ToolMetadata object with download URLs and checksums. |
Source code in provide/foundation/tools/base.py
get_platform_info
¶
Get current platform information.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary with platform and arch keys. |
Source code in provide/foundation/tools/base.py
install
async
¶
Install a specific version of the tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
Version to install (default: "latest"). |
'latest'
|
force
|
bool
|
Force reinstall even if cached. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the installed tool. |
Raises:
| Type | Description |
|---|---|
ToolInstallError
|
If installation fails. |
Source code in provide/foundation/tools/base.py
is_installed
¶
resolve_version
¶
Resolve a version specification to a concrete version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
str
|
Version specification (e.g., "latest", "~1.5.0"). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Concrete version string. |
Raises:
| Type | Description |
|---|---|
ToolNotFoundError
|
If version cannot be resolved. |
Source code in provide/foundation/tools/base.py
uninstall
¶
Uninstall a specific version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
Version to uninstall. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if uninstalled, False if not found. |
Source code in provide/foundation/tools/base.py
ToolError
¶
ToolError(
message: str,
*,
code: str | None = None,
context: dict[str, Any] | None = None,
cause: Exception | None = None,
**extra_context: Any
)
Bases: FoundationError
Base exception for tool-related errors.
Source code in provide/foundation/errors/base.py
ToolInstallError
¶
ToolInstallError(
message: str,
*,
code: str | None = None,
context: dict[str, Any] | None = None,
cause: Exception | None = None,
**extra_context: Any
)
Bases: ToolError
Raised when tool installation fails.
Source code in provide/foundation/errors/base.py
ToolMetadata
¶
Metadata about a tool version.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Tool name (e.g., "terraform"). |
version |
str
|
Version string (e.g., "1.5.0"). |
platform |
str
|
Platform identifier (e.g., "linux", "darwin"). |
arch |
str
|
Architecture (e.g., "amd64", "arm64"). |
checksum |
str | None
|
Optional checksum for verification. |
signature |
str | None
|
Optional GPG/PGP signature. |
download_url |
str | None
|
URL to download the tool. |
checksum_url |
str | None
|
URL to download checksums file. |
install_path |
Path | None
|
Where the tool is/will be installed. |
env_vars |
dict[str, str]
|
Environment variables to set. |
dependencies |
list[str]
|
Other tools this depends on. |
executable_name |
str | None
|
Name of the executable file. |
ToolNotFoundError
¶
ToolNotFoundError(
message: str,
*,
code: str | None = None,
context: dict[str, Any] | None = None,
cause: Exception | None = None,
**extra_context: Any
)
Bases: ToolError
Raised when a tool or version cannot be found.
Source code in provide/foundation/errors/base.py
ToolVerificationError
¶
ToolVerificationError(
message: str,
*,
code: str | None = None,
context: dict[str, Any] | None = None,
cause: Exception | None = None,
**extra_context: Any
)
Bases: ToolError
Raised when tool verification fails.