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

Implement -chdir option to mimic terraform behaviour #1315

Closed
sergei-ivanov opened this issue Feb 14, 2022 · 2 comments · Fixed by #1612
Closed

Implement -chdir option to mimic terraform behaviour #1315

sergei-ivanov opened this issue Feb 14, 2022 · 2 comments · Fixed by #1612

Comments

@sergei-ivanov
Copy link

tflint --help says:

Usage:
  tflint [OPTIONS] [FILE or DIR...]

...and I assumed that if I pass a directory to it, that directory will be considered root for scanning. But apparently it's not the case, the root is still the current directory, which means I always need to cd into the target directory before running tflint.

I guess we need a separate option like -chdir in Terraform, as was also mentioned here. It would also allow scripting recursive checks without the need for cd or pushd/popd for every module.

@bendrucker bendrucker changed the title Implement -chdir option to mimic terraform behaviour Implement -chdir option to mimic terraform behaviour Feb 15, 2022
@bendrucker
Copy link
Member

Of note, Terraform handles this option different than all the rest of its command options. While command options follow the command (e.g., terraform apply -target), -chdir modifies all commands and comes first (terraform -chdir=./foo apply). IIRC Terraform does some custom flag parsing to achieve this and we'd probably borrow that code.

@bendrucker
Copy link
Member

See #1580 for an instance of this difference in behavior tripping up users. In Terraform, file("./foo") works when you call terraform -chdir=/my/module apply. In TFLint, where the working directory is not actually changed, this call fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants