-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace path.Join with filepath.Join #856
Replace path.Join with filepath.Join #856
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe pull request focuses on systematically replacing Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
internal/exec/terraform_generate_backend.go (1)
5-5
: Excellent path handling for backend configuration!The change to
filepath.Join
is crucial here as it ensures the backend configuration file path will be correctly constructed across all platforms where Terraform might run. The multi-segment path construction is now properly handled.Consider adding a test case that specifically validates the path construction on Windows-style paths. This would help ensure the backend configuration works seamlessly in Windows environments.
Example test path to validate:
expectedPath := "C:\\BasePath\\Components\\Terraform\\ComponentPrefix\\FinalComponent\\backend.tf.json"Also applies to: 78-84
pkg/vender/vendor_config_test.go (1)
7-7
: Great work on improving cross-platform compatibility!The systematic replacement of path.Join with filepath.Join across these files enhances the codebase's ability to handle filesystem paths correctly across different operating systems. This change aligns with Go best practices for filesystem operations.
Consider adding this guidance to your team's Go style guide to ensure consistent usage of filepath.Join for filesystem operations across the codebase.
pkg/config/config.go (1)
128-128
: LGTM! Comprehensive filepath.Join migration with proper Windows supportThe changes thoroughly implement filepath.Join across all configuration path scenarios, including:
- System directory configuration
- Home directory paths
- Current directory paths
- Environment variable paths
- Absolute path construction
The implementation properly handles Windows-specific paths and maintains cross-platform compatibility.
Consider adding cross-platform path handling tests to verify the behavior on different operating systems, especially for Windows-specific paths.
Also applies to: 143-143, 157-157, 170-170, 184-184, 260-260, 282-282, 290-290
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (25)
cmd/cmd_utils.go
(2 hunks)cmd/docs.go
(3 hunks)internal/exec/atlantis_generate_repo_config.go
(1 hunks)internal/exec/aws_eks_update_kubeconfig.go
(2 hunks)internal/exec/describe_affected_utils.go
(4 hunks)internal/exec/helmfile.go
(3 hunks)internal/exec/oci_utils.go
(3 hunks)internal/exec/stack_processor_utils.go
(3 hunks)internal/exec/stack_utils.go
(2 hunks)internal/exec/terraform_generate_backend.go
(2 hunks)internal/exec/terraform_generate_backends.go
(2 hunks)internal/exec/terraform_generate_varfiles.go
(1 hunks)internal/exec/terraform_utils.go
(2 hunks)internal/exec/validate_component.go
(3 hunks)internal/exec/validate_stacks.go
(4 hunks)internal/exec/vendor_component_utils.go
(7 hunks)internal/exec/vendor_utils.go
(5 hunks)internal/exec/workflow.go
(1 hunks)internal/exec/workflow_utils.go
(2 hunks)pkg/config/config.go
(7 hunks)pkg/generate/terraform_generate_varfiles_test.go
(2 hunks)pkg/utils/file_utils.go
(2 hunks)pkg/utils/glob_utils.go
(2 hunks)pkg/vender/component_vendor_test.go
(3 hunks)pkg/vender/vendor_config_test.go
(6 hunks)
✅ Files skipped from review due to trivial changes (10)
- pkg/vender/component_vendor_test.go
- internal/exec/terraform_generate_backends.go
- internal/exec/validate_component.go
- cmd/cmd_utils.go
- internal/exec/oci_utils.go
- internal/exec/atlantis_generate_repo_config.go
- internal/exec/terraform_generate_varfiles.go
- internal/exec/validate_stacks.go
- internal/exec/vendor_component_utils.go
- internal/exec/stack_utils.go
🔇 Additional comments (20)
pkg/generate/terraform_generate_varfiles_test.go (1)
5-5
: Strong approval for cross-platform test compatibility!
The change from path.Join
to filepath.Join
is particularly important here as test file patterns need to work consistently across different CI/CD environments. The pattern varfiles/{tenant}-{environment}-{stage}-{component}.tfvars
will now be correctly constructed regardless of the operating system.
Also applies to: 31-31
pkg/utils/glob_utils.go (1)
6-6
: Excellent change for glob pattern handling!
The switch to filepath.Join
aligns perfectly with the cross-platform path handling in the doublestar package. This ensures consistent path handling throughout the glob matching process.
Let's verify the glob pattern handling remains consistent:
Also applies to: 39-39
✅ Verification successful
Path handling is rock-solid and consistent!
The code shows perfect alignment between filepath.Join
and doublestar
usage. The filepath.Join
is correctly used to construct full matches after doublestar.Glob
has done its work, maintaining consistent path handling across platforms. The implementation properly separates concerns:
doublestar.Glob
handles the pattern matchingfilepath.Join
handles the path construction for the final results
No issues were found in the glob pattern handling, and the code maintains cross-platform compatibility throughout.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining path.Join usage in glob-related code
# and verify consistency with doublestar usage
# Search for any remaining path.Join usage in glob-related files
rg -l 'path\.Join.*\*'
# Check for doublestar usage patterns to ensure consistency
ast-grep --pattern 'doublestar.Glob($_, $_)'
Length of output: 265
Script:
#!/bin/bash
# Let's examine the glob_utils.go file to understand the full context
cat pkg/utils/glob_utils.go
Length of output: 1798
internal/exec/workflow.go (1)
82-82
: LGTM! Correct usage of filepath.Join for filesystem operations.
The change from path.Join to filepath.Join is appropriate here since workflowPath is used for actual filesystem operations (os.ReadFile).
Let's verify no path.Join usage remains in this file:
✅ Verification successful
No remaining path.Join usage found, change is correctly implemented
The rg
search shows only the updated line using filepath.Join
, confirming that all path joining operations in this file are using the correct method for filesystem operations.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for any remaining path.Join usage
rg 'path\.Join' internal/exec/workflow.go
Length of output: 138
cmd/docs.go (2)
62-62
: LGTM! Appropriate use of filepath.Join for component directory path.
The change is correct as componentPath is used with IsDirectory for filesystem operations.
71-71
: LGTM! Correct usage of filepath.Join for README file path.
The change is appropriate as readmePath is used with os.Stat for filesystem operations.
pkg/vender/vendor_config_test.go (1)
31-31
: LGTM! Consistent usage of filepath.Join across test cases.
All path constructions have been correctly updated to use filepath.Join. This is appropriate as these paths are used with filesystem operations (os.MkdirAll, os.WriteFile).
Let's verify no path.Join usage remains in this test file:
Also applies to: 50-50, 87-87, 105-105, 129-129
✅ Verification successful
All path constructions correctly use filepath.Join
The verification confirms that all path constructions in vendor_config_test.go
consistently use filepath.Join
. No instances of path.Join
remain in the file, showing a complete and correct migration to filepath.Join
for cross-platform path handling in test cases.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for any remaining path.Join usage
rg 'path\.Join' pkg/vender/vendor_config_test.go
Length of output: 371
pkg/utils/file_utils.go (2)
72-72
: LGTM! Proper use of filepath.Join for filesystem paths.
The change from path.Join
to filepath.Join
enhances cross-platform compatibility by using the correct path separator for the operating system.
96-96
: LGTM! Proper use of filepath.Join for filesystem paths.
The change from path.Join
to filepath.Join
ensures correct path handling across different operating systems.
internal/exec/aws_eks_update_kubeconfig.go (1)
161-161
: LGTM! Proper use of filepath.Join for working directories.
The changes from path.Join
to filepath.Join
for both terraform and helmfile working directories ensure correct path handling across different operating systems.
Also applies to: 165-165
internal/exec/terraform_utils.go (1)
90-90
: LGTM! Proper use of filepath.Join for Terraform configuration files.
The changes from path.Join
to filepath.Join
for both backend and provider override file paths ensure correct path handling across different operating systems.
Also applies to: 123-123
internal/exec/workflow_utils.go (1)
149-149
: LGTM! Proper migration to filepath.Join
The changes correctly replace path.Join with filepath.Join for cross-platform path handling in the workflow directory construction. This will ensure proper path separators are used on all operating systems.
Also applies to: 166-166, 168-168
internal/exec/helmfile.go (1)
77-77
: LGTM! Complete filepath.Join migration with proper error handling
The changes correctly implement filepath.Join across all path construction scenarios, including component paths, error messages, and logging statements. This ensures consistent path handling across different operating systems.
Let's verify that we haven't missed any path.Join instances in the file:
Also applies to: 83-83, 90-90, 195-195
✅ Verification successful
All path.Join instances successfully migrated to filepath.Join
The verification confirms that all instances of path.Join
have been properly migrated to filepath.Join
. The grep results show only filepath.Join
usage in the file, indicating a complete and consistent migration.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining path.Join usage
rg 'path\.Join' internal/exec/helmfile.go
Length of output: 462
pkg/config/config.go (1)
Line range hint 1-1
: Verify complete migration across the codebase
Let's ensure we haven't missed any path.Join instances in the entire codebase:
✅ Verification successful
Migration to filepath.Join is complete and verified
The search results confirm that all path operations in the codebase are using filepath.Join
consistently. No instances of path.Join
were found in the Go files, except for a single usage in internal/exec/describe_affected_utils.go
where path.Dir
is used appropriately for path manipulation of a filename from a position object.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining path.Join usage in Go files
rg 'path\.Join' --type go
# Also check for any path package imports that might need updating
rg '^import.*"path"' --type go
Length of output: 14338
internal/exec/vendor_utils.go (4)
152-152
: LGTM! Path handling improvement for vendor config.
The change from path.Join
to filepath.Join
enhances cross-platform compatibility for vendor configuration paths.
395-395
: LGTM! Improved target path construction.
Using filepath.Join
ensures correct path separators on all platforms when constructing the target path.
444-444
: LGTM! Enhanced temporary directory path handling.
The changes correctly use filepath.Join
for temporary directory path construction, maintaining consistency with the platform-specific path separators.
Also applies to: 460-460
551-551
: LGTM! Proper path handling for target paths with base names.
The change ensures correct path construction when joining target paths with base names across different platforms.
internal/exec/describe_affected_utils.go (2)
435-437
: LGTM! Improved path handling for stacks and components.
The changes correctly use filepath.Join
for constructing absolute paths to stacks and components directories, ensuring proper path separators across platforms.
440-440
: LGTM! Enhanced stack config file path handling.
Using filepath.Join
for stack config file paths ensures correct path separators on all platforms.
internal/exec/stack_processor_utils.go (1)
2183-2183
: LGTM! Improved component path construction.
The change correctly uses filepath.Join
for constructing component paths, ensuring proper path separators across platforms.
…athjoin-in-atmos-code
…athjoin-in-atmos-code
…athjoin-in-atmos-code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @samtholiya
These changes were released in v1.128.0. |
* Revert "Replace path.Join with filepath.Join (#856)" This reverts commit 2051592. * fix some missing atmosConfig changes * get a go test report * attempt to fix vendor errors * revert to makefile as output is too large for summary * try to fix vendor test for windows * Try to sanitize filename on windows * sanitize filenames everywhere a URI is used to derive the filename * drop query string * try to fix globs * revert doublestar fix * fix vendor on windows * fix unit test replace path with filepath --------- Co-authored-by: Haitham Rageh <[email protected]>
What
path.Join
withfilepath.Join
in the codebase.path/filepath
package instead ofpath
.Why
path.Join
does not respect platform-specific path separators, causing potential issues on non-Unix systems (e.g., Windows).filepath.Join
is designed for working with filesystem paths, ensuring semantic correctness.References
Closes: Vendor Pull Operation Does Not Work on Windows #832
Go Documentation on
filepath.Join
issue: https://linear.app/cloudposse/issue/DEV-2817/replace-pathjoin-with-filepathjoin-in-atmos-code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
filepath.Join
for file path constructions, ensuring compatibility with different operating systems.