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

fix: return error if plugin is not a file #1169

Merged

Conversation

josh-barker-coles
Copy link
Contributor

Addresses #1168

Copy link
Member

@wata727 wata727 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

if os.IsNotExist(err) && runtime.GOOS != "windows" {
return "", os.ErrNotExist
} else if !os.IsNotExist(err) {
} else if !os.IsNotExist(err) && !info.IsDir() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add a condition here, it will cause unintended behavior in the following cases:

  • runtime.GOOS == "linux"
  • path exists, but it's a directory

In this case, findPluginPath searches for the .exe file, which should only be handled on Windows.
In order to organize the implementation, it may be better to first branch the process according to the runtime OS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @wata727, I've refactored it into a separate function to tidy up the intent and understanding.

@wata727 wata727 merged commit 4983b6b into terraform-linters:master Jul 23, 2021
@wata727
Copy link
Member

wata727 commented Jul 23, 2021

Thank you!

@josh-barker-coles
Copy link
Contributor Author

No worries @wata727 :-)

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.

None yet

2 participants