Skip to content

Update dry run for atmos vendor pull to support ssh + detailed SCP urls alignment - #1076

Merged
Andriy Knysh (aknysh) merged 198 commits into
mainfrom
DEV-2964_vendoring-dry-run
Mar 27, 2025
Merged

Andriy Knysh (aknysh) merged 198 commits into
mainfrom
DEV-2964_vendoring-dry-run

Conversation

@Listener430

@Listener430 Listener430 (Listener430) commented Feb 19, 2025 •

Copy link
Copy Markdown
Contributor

what

This PR upgrades the output of dry run mode for vendor pull command.
After the change is applied, the dry run mode shows

  1. details on the SCP-style links converion,
  2. Injected tokens
  3. urls being vendored in a santized format
    yet there's no actual files download.

Dry run output

dry_run_output

Non-dry run output (actual vendoring)

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

why

Received feedback from in the parent PR

references

Upscopes from #1061

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced logging now displays informative messages during package download and installation.
    • Introduced new configuration scenarios for improved vendor credential handling and component dry-run execution via SSH.
    • Added new components and updated existing ones in configuration files for better clarity and functionality.
  • Tests

    • Expanded test coverage with additional cases validating SSH-based component vendoring and dry-run functionality.
    • Added tests for handling local file paths and unsupported hosts in the custom Git detection process.
  • Chores

    • Made formatting improvements to configuration files for enhanced consistency.

@Listener430 Listener430 (Listener430) changed the title Upgrade dry run mode for vendoring Update dry run mode for vendoring to show custom detectors vendoring URL parsing logs Feb 19, 2025
@Listener430 Listener430 (Listener430) changed the title Update dry run mode for vendoring to show custom detectors vendoring URL parsing logs Update dry run for atmos vendor pull to support ssh + detailed SCP urls alignment Feb 19, 2025
coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Feb 19, 2025
coderabbitai[bot]

This comment was marked as outdated.

@aknysh

Copy link
Copy Markdown
Member

Listener430 (@Listener430) please resolve the conflicts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
internal/exec/copy_glob.go (1)

423-423: Log statement simplified for better readability

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

The new entries for environment variables used in the spawned shell context (i.e. ATMOS_COMPONENT, ATMOS_SHLVL, ATMOS_TERRAFORM_WORKSPACE, and TF_CLI_ARGS_*) provide useful clarity for users running interactive shells. One small nitpick: in the description for ATMOS_TERRAFORM_WORKSPACE (line 731), "Terraform comamnds" should be corrected to "Terraform commands."

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e874678 and cfc002b.

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

You'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 Variables

The added rows for ATMOS_BITBUCKET_TOKEN, ATMOS_BITBUCKET_USERNAME, and ATMOS_GITLAB_TOKEN clearly document their purposes and help users understand the authentication flow. Please double-check that the documented precedence (e.g. using the ATMOS_ prefixed variables over the fallback ones) corresponds with the actual implementation.

@Listener430

Copy link
Copy Markdown
Contributor Author

Listener430 (@Listener430) please resolve the conflicts

Thanks, done Andriy Knysh (@aknysh)

@aknysh

Copy link
Copy Markdown
Member

Listener430 (@Listener430) please resolve the conflicts (this is the last PR for vendoring)

@mergify

mergify Bot commented Mar 25, 2025

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Listener430 (@Listener430)? 🙏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
tests/snapshots/TestCLICommands_atmos_vendor_pull_ssh.stderr.golden (1)

1-23: ⚠️ Potential issue

Resolve 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

📥 Commits

Reviewing files that changed from the base of the PR and between cfc002b and 42d8d21.

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

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

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

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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 26, 2025
@Listener430

Listener430 (Listener430) commented Mar 26, 2025 •

Copy link
Copy Markdown
Contributor Author

Listener430 (@Listener430) please resolve the conflicts (this is the last PR for vendoring)

Andriy Knysh (@aknysh) thanks, could you please hold on with the merge as I need to do some additional testing.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 27, 2025
coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 27, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ffb395a and 7d49313.

📒 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.uri is 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 in internal/exec/go_getter_utils.go (which clearly declares source as a string), and noting that tests pass when an empty source is used at initialization (with p.uri subsequently provided to Detect), it appears this behavior is intentional. If desired, consider a brief inline comment to clarify that the source field 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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 27, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7d49313 and ce34848.

📒 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 of net/url import.

Adding this import is necessary for URL parsing in the new needsCustomDetection function, 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:

  1. Log the dry-run status for better visibility
  2. Check if custom detection is needed for the URI
  3. Use the CustomGitDetector for SSH and SCP-style URLs
  4. 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 needsCustomDetection function is a solid implementation that:

  1. Accurately determines when URIs need custom detection
  2. Properly handles different URI formats including local paths and URLs
  3. Supports a comprehensive list of schemes including SSH-related ones
  4. 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, and git+https which are required for the SSH and SCP URL support mentioned in the PR objectives.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.168.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants