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

Allow use of --chdir and --recursive together #2051

Open
rdimartino opened this issue May 18, 2024 · 1 comment
Open

Allow use of --chdir and --recursive together #2051

rdimartino opened this issue May 18, 2024 · 1 comment

Comments

@rdimartino
Copy link

Introduction

Terraform allows using both the -chdir and -recursive flags, e.g. terraform -chdir=infra/ fmt -check -recursive

I expected to be able to do something similar with TFLint, but got an error

Failed to find workspaces; cannot use --recursive and --chdir at the same time

I am running my formatters/linters from the project root for other tools but am having trouble doing that with TFLint.

My directory structure looks similar to

▷ app/
▷ tmp/
▷ node_modules/
▽ infra/
  main.tf
  .tflint.hcl
  ▽ modules/
    ▽ deployment/
    main.tf
    outputs.tf
    variables.tf

The specifics are not important, but the general problem is that running tflint --chdir infra/ seems to only check infra/main.tf, but running tflint --recursive ends up wasting a ton of time scanning node_modules/, tmp/, and other large directories without any terraform configuration.

As a work-around, I can cd into the infra/ directory before running tflint --recursive, but I would expect this tool to work similarly to terraform and allow me to specify --chdir infra/ and --recursive to tell TFLint to start recursing from the infra/ directory.

Proposal

Allow the use of both --chdir and --recursive together.

Recursion should start from the directory specified by the --chdir flag.

References

#1304 (comment)

https://developer.hashicorp.com/terraform/cli/commands/fmt#recursive

@wata727
Copy link
Member

wata727 commented May 19, 2024

Related discussions: #1920 #1960

If terraform fmt can use --chdir and --recursive together, I support this proposal in terms of interface consistency.

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

No branches or pull requests

2 participants