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

Add --filter option #1638

Merged
merged 2 commits into from
Jan 7, 2023
Merged

Add --filter option #1638

merged 2 commits into from
Jan 7, 2023

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Dec 30, 2022

See also #1636

This PR introduces the --filter option as an alternative to file arguments. This is the same as the file argument, except that it doesn't check for the existence of the file:

$ tflint main.tf
$ tflint --filter=main.tf

Introduction of this option deprecates all arguments. It can be replaced as follows:

$ tflint --chdir=dir                  # replacement of "tflint dir"
$ tflint --filter=main.tf             # replacement of "tflint main.tf"
$ tflint --chdir=dir --filter=main.tf # replacement of "tflint dir/main.tf"

Arguments are still available, but will be removed in a future version, so early migration to --chdir/--filter is recommended.

@bendrucker
Copy link
Member

This should probably be paired with an --exclude flag. And maybe should support glob patterns. Filtering out *.tf.json or some local convention like *-generated.tf seems like something users would want. It's possible to do in a shell script with find and repeated flags but the general idea with these flags is to avoid writing those wrapper scripts.

@wata727
Copy link
Member Author

wata727 commented Jan 4, 2023

Good suggestion. Agreed that glob patterns are needed.
The original goal was to deprecate arguments, so I didn't include it that far, but I'll investigate if this PR addresses it.
The --exclude flag would be worth considering implementing in another PR.

@bendrucker bendrucker closed this Jan 5, 2023
@bendrucker bendrucker reopened this Jan 5, 2023
@bendrucker
Copy link
Member

Accidentally clicked close 🤦🏻‍♂️

@bendrucker
Copy link
Member

Yeah --exclude can definitely be separate, happy to tackle that if you don't get to it. The reason globs seem essential is that we're steering people away from shell, and before users might have been relying on glob expansion in their shell:

tflint *.tf

@wata727
Copy link
Member Author

wata727 commented Jan 7, 2023

Makes sense. I'm working on something else right now, so I'm happy if you could tackle implementing --exclude.

@wata727 wata727 merged commit 9ab5262 into master Jan 7, 2023
@wata727 wata727 deleted the add_filter_option branch January 7, 2023 07:52
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.

2 participants