-
-
Notifications
You must be signed in to change notification settings - Fork 545
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
Validate doesn't work for projects with nested sub-directories #341
Comments
What hook version do you use?
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.64.0
hooks:
- id: terraform_validate
args:
- --init-args=-upgrade
- --init-args=-get=true
- --envs=AWS_DEFAULT_REGION="us-west-2"
- --envs=AWS_ACCESS_KEY_ID="anaccesskey"
- --envs=AWS_SECRET_ACCESS_KEY="asecretkey"
Feel free to reopen issue if will not works with latest version. And provide details specified in bug report template |
Seems like I'm having sort of the same behavior as reporter (or I might be misinterpreting how this hook should work 🤔):
Obviously I'd expect
|
16:24 341 git:(main +)
➜ git status
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .pre-commit-config.yaml
new file: broken/test.tf
new file: broken/tf/code/test.tf
new file: broken/tf/test.tf
16:24 341 git:(main +)
➜ tree
.
└── broken
├── test.tf
└── tf
├── code
│ └── test.tf
└── test.tf
3 directories, 3 files
16:24 341 git:(main +)
➜ cat .pre-commit-config.yaml
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.64.0
hooks:
- id: terraform_validate
args:
- --init-args=-upgrade
- --init-args=-get=true
- --envs=AWS_DEFAULT_REGION="us-west-2"
- --envs=AWS_ACCESS_KEY_ID="anaccesskey"
- --envs=AWS_SECRET_ACCESS_KEY="asecretkey"
16:24 341 git:(main +)
➜ pre-commit run -a
Terraform validate.......................................................Failed
- hook id: terraform_validate
- exit code: 1
Init before validation failed: broken
There are some problems with the configuration, described below.
The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
Error: Argument or block definition required
on test.tf line 1:
1: fsdsdf
An argument or block definition is required here. To set an argument, use the
equals sign "=" to introduce the argument value.
Init before validation failed: broken/tf
There are some problems with the configuration, described below.
The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
Error: Argument or block definition required
on test.tf line 1:
1: fsdsdf
An argument or block definition is required here. To set an argument, use the
equals sign "=" to introduce the argument value.
Init before validation failed: broken/tf/code
There are some problems with the configuration, described below.
The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
Error: Argument or block definition required
on test.tf line 1:
1: fsdsdf
An argument or block definition is required here. To set an argument, use the
equals sign "=" to introduce the argument value.
$ find broken/ -type f | while read F; do ls $F && cat $F && echo ====; done
broken/tf/code/test.tf
fsdsdf
====
broken/tf/test.tf
fsdsdf
====
broken/test.tf
fsdsdf
==== |
Weird. This just doesn't behave like on your end:
|
Did you run |
Oh my god 🤦🏻 The most important step was missing from my setup 🤦🏻 Seems like topicstarter most probably has the same "issue". |
pre-commit can't check files that are not already added to git :) |
That’s not the issue I’m having - my entire directory has been added to
git. I’m testing this pre-commit on all files and intentionally making a
change that should return a error from terraform validate.
…On Wed, Feb 16, 2022 at 10:20 AM Maksym Vlasov ***@***.***> wrote:
pre-commit can't check files that are not already added to git :)
—
Reply to this email directly, view it on GitHub
<#341 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFCT74GELT5G7UMKCABQ56LU3O6CRANCNFSM5OCH76GQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@jamiedick Please provide further info since what you provided initially didn't have any detailed info: show us |
What problem are you facing?
When running
pre-commit run --all-files
or when its run automatically on acommit
, i get the following result, even when some terraform code is note valid:My terraform code is nested in various folders throughout my repo, but in this specific case i have the following folder structure:
How could pre-commit-terraform help solve your problem?
Reviewing this PR, it appears that this hook should work, but for some reason, I can't replicate
The text was updated successfully, but these errors were encountered: