-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Revert "Replace path.Join with filepath.Join (#856)" #887
base: main
Are you sure you want to change the base?
Changes from 9 commits
ce9ce95
0c56cbc
ddf1af2
6b3b946
b6e0a54
1bceaa9
ac1a504
0ba32ea
bec23de
157fe12
235a2fd
1abd947
adecd10
d3b699d
8708089
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import ( | |
"fmt" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
"path" | ||
|
||
"github.com/google/go-containerregistry/pkg/name" | ||
"github.com/google/go-containerregistry/pkg/v1/remote" | ||
|
@@ -30,7 +30,7 @@ func processOciImage(atmosConfig schema.AtmosConfiguration, imageName string, de | |
defer removeTempDir(atmosConfig, tempDir) | ||
|
||
// Temp tarball file name | ||
tempTarFileName := filepath.Join(tempDir, uuid.New().String()) + ".tar" | ||
tempTarFileName := path.Join(tempDir, uuid.New().String()) + ".tar" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Use filepath.Join instead of path.Join for cross-platform compatibility
🔗 Analysis chainTemporary tar file path might fail on Windows Let me verify this by checking the codebase for platform-specific code and usage patterns. This will help us understand:
Let me check for Windows-specific handling in this file and related OCI functionality. This will help us understand if there's any platform-specific handling in the OCI-related code and surrounding files. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script: #!/bin/bash
# Check if there are any platform-specific imports or conditions for Windows
rg -l "runtime.GOOS" --type go
# Check for filepath package usage
rg "filepath\." --type go
# Look for the specific file content
cat internal/exec/oci_utils.go
Length of output: 11289 Script: #!/bin/bash
# Check for Windows-specific handling in the package
rg "windows" internal/exec/ -i
# Check for platform-specific path handling in the package
rg "os.(PathSeparator|PathListSeparator)" internal/exec/
# Check if this file or related files use filepath package
rg "\"path/filepath\"" internal/exec/
Length of output: 1220 |
||
|
||
// Get the image reference from the OCI registry | ||
ref, err := name.ParseReference(imageName) | ||
|
@@ -91,7 +91,7 @@ func processOciImage(atmosConfig schema.AtmosConfiguration, imageName string, de | |
|
||
// Extract the layers into the destination directory | ||
for _, l := range manifest.Layers { | ||
layerPath := filepath.Join(tempDir, l) | ||
layerPath := path.Join(tempDir, l) | ||
|
||
err = extractTarball(atmosConfig, layerPath, destDir) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,7 +357,7 @@ func ProcessYAMLConfigFile( | |
|
||
found := false | ||
for _, extension := range extensions { | ||
testPath := filepath.Join(basePath, imp+extension) | ||
testPath := path.Join(basePath, imp+extension) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Use filepath.Join instead of path.Join for OS-agnostic path handling The code shows mixed usage of
The evidence shows that:
🔗 Analysis chainReview the glob logic with path vs filepath. Let me verify this by checking the codebase for the usage context and platform-specific handling. This will help us understand:
🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script: #!/bin/bash
# Check the context of the testPath usage and any platform-specific handling
rg -B 5 -A 5 "testPath :=" internal/exec/stack_processor_utils.go
# Look for any filepath package usage in the same file
rg "filepath\." internal/exec/stack_processor_utils.go
# Check if there's any platform-specific path handling
rg -g "*.go" "path[./]Join|filepath[./]Join"
Length of output: 14588 |
||
if _, err := os.Stat(testPath); err == nil { | ||
impWithExt = imp + extension | ||
found = true | ||
|
@@ -372,12 +372,12 @@ func ProcessYAMLConfigFile( | |
} else if ext == u.YamlFileExtension || ext == u.YmlFileExtension { | ||
// Check if there's a template version of this file | ||
templatePath := impWithExt + u.TemplateExtension | ||
if _, err := os.Stat(filepath.Join(basePath, templatePath)); err == nil { | ||
if _, err := os.Stat(path.Join(basePath, templatePath)); err == nil { | ||
impWithExt = templatePath | ||
} | ||
} | ||
|
||
impWithExtPath := filepath.Join(basePath, impWithExt) | ||
impWithExtPath := path.Join(basePath, impWithExt) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Path comparison needs Windows compatibility fixes
🔗 Analysis chainEnsure self-import check accounts for Windows paths. Let me gather information about path handling in the codebase to verify this concern. This will help us understand:
Let me check how the file paths are actually compared in the codebase to better understand the self-import check implementation. This will help us understand if there's proper path normalization before comparison and how the self-import check is implemented. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script: #!/bin/bash
# Search for path-related operations and separator handling
rg -U "path\.(Join|Clean|Separator|filepath\.|\\\\|/)" internal/exec/stack_processor_utils.go -A 2
# Look for any path-related tests that might handle Windows paths
fd ".*test.*\.go" internal/exec/ --exec rg -l "path|filepath|windows|separator"
# Search for any Windows-specific path handling
ast-grep --pattern 'if runtime.GOOS == "windows" { $$$ }'
Length of output: 3165 Script: #!/bin/bash
# Search for the self-import check implementation
rg -U "self.*import|impWithExtPath.*filePath" internal/exec/stack_processor_utils.go -B 5 -A 5
# Check if filepath package is used anywhere in the file
rg "filepath\." internal/exec/stack_processor_utils.go
# Look for path normalization or cleaning
rg "Clean|ToSlash|FromSlash" internal/exec/stack_processor_utils.go
Length of output: 623 |
||
|
||
if impWithExtPath == filePath { | ||
errorMessage := fmt.Sprintf("invalid import in the manifest '%s'\nThe file imports itself in '%s'", | ||
|
@@ -2180,7 +2180,7 @@ func ProcessBaseComponentConfig( | |
if checkBaseComponentExists { | ||
// Check if the base component exists as Terraform/Helmfile component | ||
// If it does exist, don't throw errors if it is not defined in YAML config | ||
componentPath := filepath.Join(componentBasePath, baseComponent) | ||
componentPath := path.Join(componentBasePath, baseComponent) | ||
componentPathExists, err := u.IsDirectory(componentPath) | ||
if err != nil || !componentPathExists { | ||
return errors.New("The component '" + component + "' inherits from the base component '" + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package exec | |
import ( | ||
"errors" | ||
"fmt" | ||
"path" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Importing “path” might cause cross-platform file path issues |
||
"path/filepath" | ||
"strings" | ||
|
||
|
@@ -160,7 +161,7 @@ func ExecuteTerraformGenerateBackends( | |
} | ||
|
||
// Path to the terraform component | ||
terraformComponentPath := filepath.Join( | ||
terraformComponentPath := path.Join( | ||
atmosConfig.BasePath, | ||
atmosConfig.Components.Terraform.BasePath, | ||
terraformComponent, | ||
|
@@ -290,7 +291,7 @@ func ExecuteTerraformGenerateBackends( | |
|
||
processedTerraformComponents[terraformComponent] = terraformComponent | ||
|
||
backendFilePath = filepath.Join( | ||
backendFilePath = path.Join( | ||
terraformComponentPath, | ||
"backend.tf", | ||
) | ||
|
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.
💡 Codebase verification
Switch to filepath.Join for cross-platform compatibility
The codebase shows consistent Windows support patterns and platform-specific handling. In
file_utils.go
and other core utilities,filepath.Join
is predominantly used for system paths, whilepath.Join
is used for URL-like paths. Since this code incmd/docs.go
deals with filesystem paths, usingfilepath.Join
would be more appropriate for cross-platform compatibility.path.Join(componentPath, "README.md")
withfilepath.Join(componentPath, "README.md")
🔗 Analysis chain
Ensure path usage aligns with your platform needs
"filepath.Join" might be safer if Windows is a target.
Let me verify this by checking the codebase for platform-specific considerations and path handling patterns.
This will help us understand:
Let me check specifically how paths are handled in this codebase, particularly focusing on the file utils and path utilities.
🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
Length of output: 1264
Script:
Length of output: 5601