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

runner: clean Terraform source path for comparison #999

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

bendrucker
Copy link
Member

When TFLint is called with a relative path formatted with a leading ./, results are empty from Files(). The logs I added for the rule that reproduced this printed:

$ tflint ./my/module
...
19:14:55 terraform_standard_module_structure.go:73: [DEBUG] 0 files found: map[]

Clean is called internally by Dir, meaning the comparison was "my/module" == "./my/module". Cleaning both paths ensures the values are normalized for comparison.

The tests methods also call Dir to process a map of path -> file so adding a basic test didn't actually add coverage.

But I did verify that it works as expected:

19:17:00 terraform_standard_module_structure.go:73: [DEBUG] 6 files found: map[backend.tf:0xc0001a0b40 main.tf:0xc0001a0f00 outputs.tf:0xc0001a0f80 providers.tf:0xc0001a1000 variables.tf:0xc0001a1080 versions.tf:0xc0001a0ac0]

@bendrucker
Copy link
Member Author

This will affect any rule that uses Files() for users passing in a path (typically monorepos)

@bendrucker bendrucker merged commit 13f913a into master Dec 10, 2020
@wata727 wata727 deleted the clean-source-path branch May 2, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant