Closed leowei0129 closed 2 years ago
Do you think this is an issue?
That's by GIT design: https://github.com/observing/pre-commit/issues/62
You may want to try to redirect tty directly into read
like this https://stackoverflow.com/a/45495062/5093149
(the exec
thing seemingly should do the work too, though since it fails you, it's worth to try the read ... < /dev/tty
approach maybe)
I try read ... < /dev/tty
but still not work. I think it should not be a bug from this repo but related to pre-commit? So far I'm not very sure what the root cause is..
but related to pre-commit?
It's even not pre-commit
but GIT: it doesn't expect hooks to use standard input.
Also there might be some another culprit somewhere on the way granted read ... < /dev/tty
didn't work for you π€ Maybe try and simplify your hook as much as possible for testing, replace everything with just a few lines of code to echo and read input, turn on trace output (set -x
), an so on β since others report redirecting tty works for them, there might be something we don't see here.
Please let us know the outcome of your findings.
A few notes:
tf plan
does not mean that you will get success with tf apply
tf plan
takes much time, which violates the idea of "quick check before committing". That's can be a problem when you'll try to force usage of this hook across the team.tf plan
outputtf plan
is not much different from tf validate
. Also, you are already able to check remote API by tflint with --deep
option, much quicker than run tf plan
By the way, it still can work for your case, but I highly recommend to check https://github.com/terraform-linters/tflint-ruleset-google/blob/master/docs/deep_checking.md
Hi team,
Maybe I should mark this issue as feature request? I create my own hook terraform_plan locally for the purpose to review all the changes before commit. My idea is to check if things defined in main.tf are ok through this hook, then user input yes or no. If yes, pre-commit will pass otherwise pre-commit will fail.
To achieve this, I add
exec < /dev/tty
in this hook. The snippet looks like this. I create this hook based on terraform_fmt.sh.I expect that the output of
terraform plan ...
and the promptDo you agree this plan? (Y/N)
should appear before I can enter my answer. But actually nothing shown and it just hangs there waiting for the input.Until I give an input "Y", every output string defined in this hook (ex: output string through
echo
,terraform plan
) comes out.Do you think this is an issue? or anything else I miss or wrong?
Thanks.