Skip to content

Add support for specifying --chdir multiple times#2513

Open
amartani wants to merge 1 commit into
terraform-linters:masterfrom
amartani:martani/multi-chdir
Open

Add support for specifying --chdir multiple times#2513
amartani wants to merge 1 commit into
terraform-linters:masterfrom
amartani:martani/multi-chdir

Conversation

@amartani

Copy link
Copy Markdown

Add support for specifying --chdir multiple times. This reuses the current support for running multiple subprocesses in parallel, used by --recursive. With this option, we can now run multiple --chdir without running all --chdir, which is useful, for example, in pre-commit or CI systems on PRs where you may want to run on all modified roots rather than all roots.

@wata727

wata727 commented Apr 29, 2026

Copy link
Copy Markdown
Member

Since the --chdir is not originally intended to be used in multiple times, integrity with other features is important. For example, what happens if you use the --filter or --recursive with multiple --chdir commands?

Furthermore, the validity of allowing multiple --chdir needs to be considered. While --chdir follows the design of Terraform, Terraform only allows one --chdir. Unlike Terraform, is there a design justification for allowing multiple --chdir?

@amartani

amartani commented May 1, 2026

Copy link
Copy Markdown
Author

The justification for multiple --chdir is the same as for --recursive: you generally want to run tflint on many roots (in CI for example), while when running raw terraform, you want to be more specific. This implementation is just adding more flexibility to that - instead of every root with --recursive, you may want to run only on a subset of roots.

Multiple --chdir with --filter works in the same way as --recursive with --filter - each worker independently resolves the filter on their own directory.

Multiple --chdir with --recursive will run on the union of all the directories under all --chdirs.

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