Repository navigation
Support Atmos Toolchain for 3rd Party Tools - #1466
Sam Tholiya (samtholiya) wants to merge 136 commits into
Conversation
|
Warning This PR exceeds the recommended limit of 1,000 lines.Large PRs are difficult to review and may be rejected due to their size. Please verify that this PR does not address multiple issues. |
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
There was a problem hiding this comment.
golangci-lint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis PR introduces a complete toolchain subsystem for Atmos that installs and manages CLI binaries from the Aqua registry. It adds schema definitions, CLI command structure, registry clients, installer logic with asset downloading and extraction, local configuration management, and extensive test coverage across all components. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CLI as atmos toolchain
participant Installer
participant Resolver
participant Registry as Aqua Registry
participant GitHub
participant FS as Filesystem
User->>CLI: atmos toolchain install [email protected]
CLI->>Installer: NewInstaller()
Installer->>Resolver: Resolve("terraform")
Resolver-->>Installer: ("hashicorp", "terraform")
Installer->>Registry: GetToolWithVersion("hashicorp", "terraform", "1.11.4")
Registry->>GitHub: FetchReleases("hashicorp", "terraform")
GitHub-->>Registry: ["1.11.4", "1.9.8", ...]
Registry-->>Installer: Tool{Asset:"...", Format:"zip", ...}
Installer->>Installer: BuildAssetURL(tool, "1.11.4")
Installer->>FS: Download asset
Installer->>FS: Extract archive
Installer->>FS: Install to .tools/bin/hashicorp/terraform/1.11.4/
Installer->>FS: CreateLatestFile(latest=1.11.4)
Installer->>FS: Update .tool-versions
CLI-->>User: ✓ terraform 1.11.4 installed
sequenceDiagram
participant RootCmd as cmd/root.go
participant InitCliConfig as InitCliConfig()
participant ToolchainCmd as toolchain package
participant SubCmds as Subcommands
RootCmd->>InitCliConfig: Execute
InitCliConfig-->>RootCmd: atmosConfig
RootCmd->>ToolchainCmd: SetAtmosConfig(&atmosConfig)
ToolchainCmd->>ToolchainCmd: Store config globally
activate ToolchainCmd
SubCmds->>ToolchainCmd: GetToolsDirPath(), GetToolVersionsFilePath()
ToolchainCmd-->>SubCmds: Configured paths
deactivate ToolchainCmd
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Rationale: This PR introduces a substantial new subsystem with significant logic density across multiple domains (HTTP clients, registry parsing, file extraction, version resolution, CLI command wiring). While the changes are well-structured and homogeneous within each module, the breadth—spanning installer logic, registry clients, config management, 13+ command implementations, and 40+ test files—demands careful review. The logic for URL templating, version constraint resolution, asset extraction, and error handling requires attention. However, the extensive test coverage and clear architectural separation mitigate complexity somewhat. Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (28)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1466 +/- ##
==========================================
- Coverage 66.04% 65.81% -0.24%
==========================================
Files 350 373 +23
Lines 39912 43176 +3264
==========================================
+ Hits 26361 28416 +2055
- Misses 11540 12563 +1023
- Partials 2011 2197 +186
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 146
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
website/src/components/Screengrabs/demo-stacks/define-your-stacks.html (1)
1-53: Sanitize Screengrabs for leaked local paths and script errors
All files underwebsite/src/components/Screengrabs/demo-stacks/*(e.g.define-your-stacks.html,start-your-project.html,write-your-components.*) contain hardcoded/home/.../cloudposse/atmosor/Users/...paths and “bat: command not found” output. Remove or replace these placeholders with neutral paths or properly rendered content.go.mod (1)
3-3: Update devcontainer Dockerfile Go image
- .devcontainer/Dockerfile line 1: change
FROM golang:1.22 AS confettytoFROM golang:1.24.6 AS confetty.
(GitHub workflows already useactions/setup-gowithgo-version-file: go.mod, so they’ll pick up Go 1.24.6 automatically.)cmd/toolchain.go (1)
1-75: Replace hardcoded “.tool-versions” in install.go with GetToolVersionsFilePath()
toolchain/install.go still calls
- LoadToolVersions(".tool-versions") (≈ line 79)
- AddToolToVersionsAsDefault(".tool-versions", …) (≈ line 123)
- AddToolToVersions(".tool-versions", …) (≈ line 127)
- AddToolToVersions(".tool-versions", …) in progress loop (≈ line 171)
All should use GetToolVersionsFilePath() for consistency and configurability.
| import ( | ||
| "github.com/cloudposse/atmos/toolchain" | ||
| "github.com/spf13/cobra" | ||
| ) |
Describe the Feature
Atmos should automatically add the packages base-path as a priority search PATH when executing any commands.
Expected Behavior
Packages are automatically installed and available to atmos components, custom commands, and workflows.
When running
atmos terraform planand it depends on[email protected], if not installed it should automatically install it (if it's configured).When running a custom command, that needs
tflint, it should be able to automatically install it.When running a workflow that needs
tfsec, it should automatically install it.Use Case
usekeywordDescribe Ideal Solution
Atmos Commands
Atmos Configuration
The
usekeyword will installatmosat version1.183.1, then callsyscall.Execto replace the current process with the atmos at the correct version, if the current version is not already 1.183.1.Aliases
Aliases map a short name like
opentofuto a registry configuration ofopentofu/opentofuorterraformto something likehashicorp/terraformTool Versions
We should use the simple
.tool-versionsconvention popularized byasdfThe first semver is the default version, when nothing is specified
This file is consulted when calling install/uninstall/add/remove.
We should use aliases in this file to refer to toolchain tools. This is so we can change the mapping in the future.
Aqua Registry Configuration
We're going to add partial Aqua support for registries and expand the implementation over time. To start, we want to support the essential packages we depend on.
Local Configuration
We also want a local toolchain configuration, when not depending on the Aqua registry.
Stack Configuration
When the
commandis evaluated, it's first checked against the toolchain, and if it's not installed, it will be automatically installed.The
PATHfor exec will be updated to use the directory containingterraformfor version1.11.4Workflows
Custom Commands
Alternatives Considered
Using
aquadirectly. However, the aims of the Aqua Project are different than our aims and Aqua does not expose an SDK or stable interfaces for other CLIs to use Aqua.https://github.com/suzuki-shunsuke
Summary by CodeRabbit
New Features
Documentation