Repository navigation
Update dry run for atmos vendor pull to support ssh + detailed SCP urls alignment - #1076
Conversation
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
… only in dry mode
|
Listener430 (@Listener430) please resolve the conflicts |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
internal/exec/copy_glob.go (1)
423-423: Log statement simplified for better readabilityGood simplification of the debug log message. Removing the extra parameters (likely source and finalTarget) makes the output cleaner while maintaining the essential information.
I noticed the log statement at line 428 still includes detailed parameters. Consider whether maintaining this consistency is important for debugging in the context of your dry run improvements.
website/docs/cli/configuration/configuration.mdx (1)
727-733: Improve Shell Environment Variables DocumentationThe new entries for environment variables used in the spawned shell context (i.e.
ATMOS_COMPONENT,ATMOS_SHLVL,ATMOS_TERRAFORM_WORKSPACE, andTF_CLI_ARGS_*) provide useful clarity for users running interactive shells. One small nitpick: in the description forATMOS_TERRAFORM_WORKSPACE(line 731), "Terraform comamnds" should be corrected to "Terraform commands."
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
internal/exec/copy_glob.go(1 hunks)internal/exec/go_getter_utils.go(9 hunks)internal/exec/vendor_model.go(1 hunks)internal/exec/vendor_utils.go(1 hunks)tests/snapshots/TestCLICommands_atmos_vendor_pull_with_custom_detector_and_handling_credentials_leakage.stderr.golden(1 hunks)website/docs/cli/configuration/configuration.mdx(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- internal/exec/vendor_model.go
- tests/snapshots/TestCLICommands_atmos_vendor_pull_with_custom_detector_and_handling_credentials_leakage.stderr.golden
- internal/exec/vendor_utils.go
- internal/exec/go_getter_utils.go
🧰 Additional context used
🧠 Learnings (1)
internal/exec/copy_glob.go (1)
Learnt from: Listener430
PR: cloudposse/atmos#984
File: internal/exec/vendor_model.go:0-0
Timestamp: 2025-03-25T07:54:00.731Z
Learning: The function `copyToTarget` is being replaced with `copyToTargetWithPatterns` to support enhanced glob pattern matching for vendoring, but is temporarily kept for reference until the new implementation is fully confirmed.
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Acceptance Tests (macos-latest, macos)
- GitHub Check: Acceptance Tests (windows-latest, windows)
- GitHub Check: Acceptance Tests (ubuntu-latest, linux)
- GitHub Check: [localstack] demo-localstack
- GitHub Check: Summary
🔇 Additional comments (2)
internal/exec/copy_glob.go (1)
417-417: Log statement removed for cleaner outputYou've removed a log statement that likely included detailed parameters like sourceKey, sourceDir, finalTargetKey, and finalTarget. This aligns with the PR's goal of enhancing the dry run output by making it more streamlined.
website/docs/cli/configuration/configuration.mdx (1)
718-722: Clarify New Authentication Environment VariablesThe added rows for
ATMOS_BITBUCKET_TOKEN,ATMOS_BITBUCKET_USERNAME, andATMOS_GITLAB_TOKENclearly document their purposes and help users understand the authentication flow. Please double-check that the documented precedence (e.g. using theATMOS_prefixed variables over the fallback ones) corresponds with the actual implementation.
Thanks, done Andriy Knysh (@aknysh) |
|
Listener430 (@Listener430) please resolve the conflicts (this is the last PR for vendoring) |
|
💥 This pull request now has conflicts. Could you fix it Listener430 (@Listener430)? 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
tests/snapshots/TestCLICommands_atmos_vendor_pull_ssh.stderr.golden (1)
1-23:⚠️ Potential issueResolve merge conflict markers
There are merge conflict markers in this file that need to be resolved before merging. The content between both versions appears to be the same, so you can simply remove the conflict markers and keep one version.
Apply this change:
-<<<<<<< HEAD DEBU Using command line argument '--logs-level=Debug' DEBU processStoreConfig atmosConfig.StoresConfig=map[] DEBU processStoreConfig atmosConfig.StoresConfig=map[] DEBU processStoreConfig atmosConfig.StoresConfig=map[] INFO Vendoring from 'vendor.yaml' WARN No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined. INFO ✓ terrafrom-null-label (0.25.0) INFO Done! Dry run completed. No components vendored. INFO Vendored 1 components. -======= -DEBU Using command line argument '--logs-level=Debug' -DEBU processStoreConfig atmosConfig.StoresConfig=map[] -DEBU processStoreConfig atmosConfig.StoresConfig=map[] -DEBU processStoreConfig atmosConfig.StoresConfig=map[] -INFO Vendoring from 'vendor.yaml' -WARN No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined. -INFO ✓ terrafrom-null-label (0.25.0) -INFO Done! Dry run completed. No components vendored. - -INFO Vendored 1 components. ->>>>>>> main
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
tests/fixtures/scenarios/vendor-creds-sanitize/vendor.yaml(0 hunks)tests/fixtures/scenarios/vendor-pulls-ssh/atmos.yaml(1 hunks)tests/fixtures/scenarios/vendor-pulls-ssh/vendor.yaml(1 hunks)tests/snapshots/TestCLICommands_atmos_vendor_pull_custom_detector_credentials_leakage.stderr.golden(2 hunks)tests/snapshots/TestCLICommands_atmos_vendor_pull_ssh.stderr.golden(2 hunks)tests/test-cases/vendoring-ssh-dryrun.yaml(1 hunks)
💤 Files with no reviewable changes (1)
- tests/fixtures/scenarios/vendor-creds-sanitize/vendor.yaml
✅ Files skipped from review due to trivial changes (2)
- tests/fixtures/scenarios/vendor-pulls-ssh/atmos.yaml
- tests/fixtures/scenarios/vendor-pulls-ssh/vendor.yaml
🧰 Additional context used
🧠 Learnings (1)
tests/snapshots/TestCLICommands_atmos_vendor_pull_ssh.stderr.golden (2)
Learnt from: Listener430
PR: cloudposse/atmos#1061
File: tests/snapshots/TestCLICommands_atmos_vendor_pull_ssh.stderr.golden:8-8
Timestamp: 2025-03-25T20:35:13.779Z
Learning: Test snapshots in the Atmos project, particularly for dry run scenarios, may be updated during the development process, and temporary inconsistencies in their content should not be flagged as issues.
Learnt from: Listener430
PR: cloudposse/atmos#1149
File: tests/snapshots/TestCLICommands_atmos_vendor_pull_ssh.stderr.golden:7-7
Timestamp: 2025-03-25T20:35:18.271Z
Learning: In the Atmos project, typos or inconsistencies in test snapshot files (such as "terrafrom" instead of "terraform") may be intentional as they capture the exact output of commands and should not be flagged as issues requiring correction.
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (3)
tests/test-cases/vendoring-ssh-dryrun.yaml (1)
21-38: Good addition of SSH component test caseThis new test case complements the existing generic SSH test case and aligns well with the PR objectives to enhance dry run output. It specifically tests component vendoring with SSH, which is a valuable addition to test coverage.
tests/snapshots/TestCLICommands_atmos_vendor_pull_custom_detector_credentials_leakage.stderr.golden (2)
33-33: Terminology: "file" vs "path" for directoriesThis was previously flagged by Erik Osterman (Cloud Posse) (@osterman). The debug logs refer to directories like "docs" as files, while they're actually paths. I see this inconsistency remains present in this snapshot.
Also applies to: 89-91
10-12: Great work on credential sanitization in logsThe debug logs now properly mask sensitive credentials with "xxx:xxx" placeholders in the URL, which aligns with the PR objective of displaying injected tokens in a sanitized format.
Andriy Knysh (@aknysh) thanks, could you please hold on with the merge as I need to do some additional testing. |
…not the one from the list
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/exec/vendor_component_utils.go (1)
389-389: Consider adding a comment explaining why custom detection might be needed.The function call to
needsCustomDetectionis clear but the conditions that would trigger it aren't immediately obvious from the code alone.- if needsCustomDetection(p.uri) { + // Check if URI requires custom detection (e.g., SSH/SCP-style URLs) + if needsCustomDetection(p.uri) {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
internal/exec/go_getter_utils.go(1 hunks)internal/exec/vendor_component_utils.go(1 hunks)internal/exec/vendor_model.go(3 hunks)tests/fixtures/scenarios/vendor-creds-sanitize/vendor.yaml(2 hunks)tests/snapshots/TestCLICommands_atmos_vendor_pull_component_using_SSH.stderr.golden(1 hunks)tests/snapshots/TestCLICommands_atmos_vendor_pull_using_SSH.stderr.golden(1 hunks)tests/snapshots/TestCLICommands_atmos_vendor_pull_with_custom_detector_and_handling_credentials_leakage.stderr.golden(1 hunks)tests/test-cases/vendoring-ssh-dryrun.yaml(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
- tests/snapshots/TestCLICommands_atmos_vendor_pull_using_SSH.stderr.golden
- internal/exec/go_getter_utils.go
- tests/snapshots/TestCLICommands_atmos_vendor_pull_component_using_SSH.stderr.golden
- tests/snapshots/TestCLICommands_atmos_vendor_pull_with_custom_detector_and_handling_credentials_leakage.stderr.golden
- tests/fixtures/scenarios/vendor-creds-sanitize/vendor.yaml
- internal/exec/vendor_model.go
🧰 Additional context used
🧬 Code Definitions (1)
internal/exec/vendor_component_utils.go (1)
internal/exec/go_getter_utils.go (1)
CustomGitDetector(74-77)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (10)
internal/exec/vendor_component_utils.go (5)
388-401: Enhanced dry-run mode with detection logic looks solid.The added code properly handles different URI scenarios in dry-run mode by checking if custom detection is needed and providing detailed debug output. The implementation aligns with the PR objective to improve diagnostic information during dry runs.
390-390: Helpful debug logging for troubleshooting vendor operations.The detailed debug message includes both the component name and URI, which will help when diagnosing issues with custom detection.
393-398: Good error handling for detection failures.The error message provides clear context about which component failed and includes the underlying error, making troubleshooting easier.
399-401: Useful debug output for default go-getter path.This log clearly indicates when the URI is already in a format that go-getter can handle directly, which helps understand the decision flow during dry runs.
391-392:Details
✅ Verification successful
Verify CustomGitDetector initialization with empty source.
The detector is initialized with empty source but then
p.uriis passed to the Detect method. While this appears to work correctly (based on the tests), it's worth confirming this behavior is intentional.
🏁 Script executed:
#!/bin/bash # Check if CustomGitDetector is meant to have an empty source during initialization ast-grep --pattern 'type CustomGitDetector struct { $$$ source $$$ }' # Check how the Detect method uses the source field ast-grep --pattern 'func ($$$) Detect($$$) { $$$ }'Length of output: 368
CustomGitDetector source initialization confirmed – no changes required.
After verifying the struct definition ininternal/exec/go_getter_utils.go(which clearly declaressourceas a string), and noting that tests pass when an empty source is used at initialization (withp.urisubsequently provided toDetect), it appears this behavior is intentional. If desired, consider a brief inline comment to clarify that thesourcefield is expected to be empty initially, with the URI passed later.tests/test-cases/vendoring-ssh-dryrun.yaml (5)
8-8: Clear test description update for SSH vendoring test.The updated description better explains what the test is actually verifying - testing both paths where custom detection is and isn't needed.
22-39: Good addition of component-specific SSH test case.This new test case complements the existing generic vendoring test by specifically testing the component vendoring path with SSH URLs. This ensures both vendoring approaches are properly tested with the enhanced dry-run output.
45-45: Expanded test description for credentials handling.The updated description correctly reflects that the test now covers multiple credential types (GitHub, GitLab, Bitbucket), making the test purpose clearer.
54-57: Comprehensive credential testing across multiple providers.Good enhancement to test credential sanitization for multiple git providers, not just GitHub. This ensures the implementation handles all credential types properly.
61-67: Thorough validation of credential sanitization.The test now explicitly checks that none of the credentials appear in the output, which is critical for security.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/exec/vendor_model.go (1)
415-417: Fix typo in comment.There's a minor typo in the comment.
-// Thie is a replica of getForce method from go getter library, had to make it as it is not exported. +// This is a replica of getForce method from go getter library, had to make it as it is not exported.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/exec/vendor_model.go(4 hunks)
🧰 Additional context used
🧠 Learnings (1)
internal/exec/vendor_model.go (1)
Learnt from: samtholiya
PR: cloudposse/atmos#1077
File: pkg/downloader/custom_github_detector.go:0-0
Timestamp: 2025-02-21T20:56:05.539Z
Learning: The `github.com/charmbracelet/log` package should be imported with the alias `log` according to the project's import alias configuration.
🧬 Code Definitions (1)
internal/exec/vendor_model.go (3)
pkg/schema/schema.go (1)
AtmosConfiguration(13-45)internal/exec/go_getter_utils.go (1)
CustomGitDetector(74-77)pkg/utils/file_utils.go (2)
FileExists(27-33)IsDirectory(18-24)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (5)
internal/exec/vendor_model.go (5)
5-5: Good addition ofnet/urlimport.Adding this import is necessary for URL parsing in the new
needsCustomDetectionfunction, which aligns with the PR objective of supporting SSH and SCP-style URLs in the dry run output.
335-335: Improved logging for better visibility.Adding this debug log statement enhances observability during package installation, making it easier to track the downloading process in logs.
391-407: Good implementation of dry-run flow with custom detection.The updated implementation adds important functionality to handle different URI formats during dry runs. The changes successfully:
- Log the dry-run status for better visibility
- Check if custom detection is needed for the URI
- Use the CustomGitDetector for SSH and SCP-style URLs
- Handle errors properly for detection failures
This change directly addresses the PR objective to enhance the dry run output with detailed information on SCP-style links.
418-460: Well-structured custom detection implementation.The
needsCustomDetectionfunction is a solid implementation that:
- Accurately determines when URIs need custom detection
- Properly handles different URI formats including local paths and URLs
- Supports a comprehensive list of schemes including SSH-related ones
- Provides good error handling for URL parsing failures
This implementation is crucial for the PR objective of supporting SSH and detailed SCP URLs alignment in dry run output.
441-453: Comprehensive scheme support for URL detection.The map of supported schemes is thorough and includes all necessary protocols, especially
ssh,git+ssh, andgit+httpswhich are required for the SSH and SCP URL support mentioned in the PR objectives.
|
These changes were released in v1.168.0. |
what
This PR upgrades the output of dry run mode for vendor pull command.
After the change is applied, the dry run mode shows
yet there's no actual files download.
Dry run output
Non-dry run output (actual vendoring)
Testing
go test -v -run '^TestCLICommands/(atmos_vendor_pull_using_SSH|atmos_vendor_pull_component_using_SSH|atmos_vendor_pull_with_custom_detector_and_handling_credentials_leakage)$' github.com/cloudposse/atmos/testswhy
Received feedback from in the parent PR
references
Upscopes from #1061
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Tests
Chores