-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
Normalize path usage to use forward slashes to make things more platform agnostic #100
Normalize path usage to use forward slashes to make things more platform agnostic #100
Conversation
Here's the latest test run with all the changes in this PR thus far. |
Almost all of these test failures have to do with concurrent modifications to DynamoDB. We generate a random name for the table and the odds of collision should be very low, and yet, the test output shows multiple tests using the exact same name. Here's the code used to generate a unique ID for the table: func uniqueId() string {
const BASE_62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
const UNIQUE_ID_LENGTH = 6 // Should be good for 62^6 = 56+ billion combinations
var out bytes.Buffer
random := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < UNIQUE_ID_LENGTH; i++ {
out.WriteByte(BASE_62_CHARS[random.Intn(len(BASE_62_CHARS))])
}
return out.String()
} Perhaps |
BTW, this is an interesting approach! Is the idea here to replace all path separators with a "/"? I assume Windows can handle forward slashes as well as backslashes when loading things from the file system? |
Effectively, yes. I did some testing and have had no issues in windows with both slashes. Additionally, the path/filepath pkg in Go does the OS mangling for you already anyway. The path pkg on its own does not. |
Awesome. In that case, I think this approach makes sense. The only thing left to figure out is why the DynamoDB stuff is failing, including even a panic in some cases. Do those tests pass if you run just one of them? E.g. |
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.
Overall code looks good. Just one minor comment.
return filepath.ToSlash(filepath.Join(elem...)) | ||
} | ||
|
||
func CleanPath(path string) string { |
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.
Could you add comments to these two methods explaining what they do and why the should be used (i.e. for cross-OS compatibility).
They seem to, yes. So this definitely has something to do with the parallelization of the tests. I'll take a look at the uniqueid function. |
Fixed! |
@cstavro You rock. This is awesome work! Thank you! Merging now :) |
Just created a new release here: https://github.com/gruntwork-io/terragrunt/releases/tag/v0.9.0. If the build passes, the new binaries should show up in a few minutes. |
For your consideration, this is a different approach that fixes #89 .
I've changed the relevant filepath calls to route through a helper method which calls filepath.ToSlash to convert them to forward slashes.
The path/filepath pkg will convert slashes back and forth dependent upon the underlying OS so converting them all to forward slashes for the purposes of manipulating them within the application should be okay and also passes the tests!
I think this is a better approach than trying to explicitly handle two different path types throughout the app.
There are a few test failures around concurrency with dynamodb and deleting tables that are still in use.