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

feat: added ignore dir #1787

Closed
wants to merge 1 commit into from
Closed

feat: added ignore dir #1787

wants to merge 1 commit into from

Conversation

noelgass
Copy link

Added the functionality to ignore directories.

@noelgass
Copy link
Author

Maybe you guys can push me into the right direction to fix the checks. I've no experience with go tbh.

@wata727
Copy link
Member

wata727 commented Jun 20, 2023

Thank you for working on this.

But I'm wondering if --ignore-dir is the right solution for your issue. I believe this probably generalizes to #1536.
What kind of directories do you want to ignore with this option?

@bendrucker
Copy link
Member

Similar thought, if not recursive configuration, a more generic --exclude flag seems worth considering:

#1638 (comment)

That would allow you to --exclude one-file.tf but also --exclude ./many/modules/**.

@noelgass
Copy link
Author

Hey everyone,

Let me summarize what I aim to accomplish.

While developing Terraform modules, I provide an example directory to provide usage examples for the modules. To improve convenience, I would like to exclude the examples directory from recursive scraping. This is because it does not need to adhere to the default linting settings applied to the rest of the project, such as the requirement for outputs.tf or versions.tf files.

I believe there is room for improvement in terms of naming, and we should adopt a more generic approach, as suggested by @bendrucker. For instance, Checkov has a useful flag called --skip-path that allows skipping specific paths (files or directories). I would like to achieve a similar functionality in this case.

Unfortunately, I am relatively new to Go and this is my first attempt at writing Go code. Therefore, I would greatly appreciate your assistance.

Cheers

Noël

@wata727
Copy link
Member

wata727 commented Jun 22, 2023

Thank you for sharing your use case. I understand what you want to achieve.
In this case, as Ben said, implementing the --exclude flag would be appropriate.

Perhaps #1638 will be helpful. Instead of restricting the directories to walk, just filter the issues, much like --filter.
If you have any questions, please feel free to ask.

@noelgass
Copy link
Author

Thanks @wata727.

@bendrucker are you yet implementing this?

If not, I might take a look into it, but due to my lack of knowledge, in terms of go, it might take some time and might not be as good as other solutions.

@wata727
Copy link
Member

wata727 commented Jun 23, 2023

Sorry. I was a little misunderstood.
The --filter is an option that applies to each module, so you cannot specify a specific module like --filter=path/to/dir. This is the same for --exclude, which is the inverse of --filter. It may not be suitable for your use case.

However, it may be inconvenient that --filter cannot be used across modules. It might be worth considering changing the behavior of --filter. Or, as originally suggested, add new flags like --ignore-dir, or define a way to declare inspection settings for multiple modules.

Either way, we probably need to think from the design.

@noelgass noelgass closed this by deleting the head repository Nov 26, 2023
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.

4 participants