Skip to content
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 relative paths to an absolute path #44

Merged
merged 2 commits into from
Aug 18, 2023

Conversation

sebasslash
Copy link
Contributor

@sebasslash sebasslash commented Aug 8, 2023

Description

This issue regarding dereferencing symlinks has plagued Terraform v1.3.0+ (reported for several versions here). The first issue, dereferencing symlinks whose targets resolve to symlinks outside of the src directory was resolved in #37. The second issue, when the src directory itself is a symlink was resolved in #36. The last issue, and the focus of this PR, deals with normalizing paths when attempting to traverse the src directory. My change is simple: before attempting to traverse the src normalize the path representation to its absolute form.

Big thank you to @willhughes-au and @calvinbui for providing the fixture used to test that paths are normalized.

If you'd like to test that this works with Terraform, you will need to go install . from main, replacing the indirect dependency for go-slug with a repo containing these changes.

cd /path/to/terraform
go mod edit -replace github.com/hashicorp/go-slug=/path/to/your/go-slug
go install .

@sebasslash sebasslash changed the title Normalize relative paths to absolute path Normalize relative paths to an absolute path Aug 9, 2023
slug.go Outdated Show resolved Hide resolved
slug.go Outdated Show resolved Hide resolved
@sebasslash sebasslash force-pushed the sebasslash/ipl-4553_failed-to-get-relative-path branch from d73a664 to 9efbcf5 Compare August 15, 2023 18:33
slug_test.go Outdated Show resolved Hide resolved
slug.go Outdated Show resolved Hide resolved
slug.go Outdated Show resolved Hide resolved
slug_test.go Show resolved Hide resolved
@sebasslash sebasslash force-pushed the sebasslash/ipl-4553_failed-to-get-relative-path branch from 9efbcf5 to 33ba34b Compare August 16, 2023 17:32
@sebasslash sebasslash merged commit 7f973de into main Aug 18, 2023
2 checks passed
@xiehan xiehan deleted the sebasslash/ipl-4553_failed-to-get-relative-path branch May 8, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants