-
-
Notifications
You must be signed in to change notification settings - Fork 540
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
feat: Support set custom TF/OpenTofu binary. | If you use a custom Docker image build, please note that TERRAFORM_VERSION
now must be provided
#670
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: George L. Yermulnik <[email protected]>
Co-authored-by: George L. Yermulnik <[email protected]>
Co-authored-by: George L. Yermulnik <[email protected]>
Co-authored-by: George L. Yermulnik <[email protected]>
Co-authored-by: George L. Yermulnik <[email protected]>
Co-authored-by: George L. Yermulnik <[email protected]>
Co-authored-by: George L. Yermulnik <[email protected]>
Co-authored-by: George L. Yermulnik <[email protected]>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Ah, it discared full readme, not just this commit, meh, 1 min |
825b7f0
to
35e7f1b
Compare
Pushed final README fixes. Missed the broken README part the last time when I was reverting back to |
35e7f1b
to
bc2766c
Compare
hooks/_common.sh
Outdated
# Maybe there is a similar setting for Terragrunt already | ||
elif [[ $TERRAGRUNT_TFPATH ]]; then | ||
echo "${TERRAGRUNT_TFPATH}" | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it
According to https://terragrunt.gruntwork.io/docs/reference/cli-options/#terragrunt-tfpath it will be automatically specified for terragrunt => for terragrunt hooks too.
Why do we need to set Terragrunt path for vanilla TF hooks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imagine you are working in some environment that already uses TERRAGRUNT_TFPATH
env variable (global env, using direnv, or any other method)
So if a variable already exists and serves exactly the same purposes, why not to check it and reuse it, why to have other args/vars/etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I'm following the gist of the question, though probably (I'm purely guesstimating) this way it would be easier for people using both TF and TG hooks to specify custom binary only once using TG's method but covering also TF? 🤔 And from this point of view it makes sense to me.
@den-is What's your idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I'm following the gist of the question, though probably (I'm purely guesstimating) this way it would be easier for people using both TF and TG hooks to specify custom binary only once using TG's method but covering also TF? 🤔 And from this point of view it makes sense to me.
@yermulnik Erm... this was already replied to by me yesterday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Folks that use terragrunt should use terragrunt
hooks, not terraform
hooks - terraform
will just not work in most cases. It's hard to imagine that someone uses both terragrunt and vanilla terraform, but if so - why do we think that folks would be happy with interference between "prj1 with TG and OpenTofu" and "prj2 with vanilla TF"?
And another question: do we need to specify $tf_path
for terragrunt hooks?
Like terragrunt validate --terragrunt-tfpath "$tf_path" "${args[@]}"
terragrunt validate "${args[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erm... this was already replied to by me yesterday.
@den-is My bad. I missed that comment (found it now). Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to imagine that someone uses both terragrunt and vanilla terraform
I don't in particular, but a fellow squad in my project — does. And I'd imagine there are people in the wild who do the same and hence they may like using TERRAGRUNT_TFPATH
to cover both use cases if they use pre-commit-terraform
.
And another question: do we need to specify
$tf_path
for terragrunt hooks?
That's a good question. We probably should. But only when it is provided via TG hook config. In the rest of use cases TG should rely upon its own logic, including TERRAGRUNT_TFPATH
and others described at https://terragrunt.gruntwork.io/docs/reference/cli-options/#terragrunt-tfpath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a conversation with @den-is
TL;DR: we assume that it will no break anything in 99% of cases. And if such a thing happened - I'll mention Den is such an issue :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me 👍🏻
I'll mention Den is such an issue :D
I feel like is
should be in
, but with is
the sentence sounds fabulous 🤣
TERRAFORM_VERSION
now must be provided
hooks/_common.sh
Outdated
# Maybe there is a similar setting for Terragrunt already | ||
elif [[ $TERRAGRUNT_TFPATH ]]; then | ||
echo "${TERRAGRUNT_TFPATH}" | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I'm following the gist of the question, though probably (I'm purely guesstimating) this way it would be easier for people using both TF and TG hooks to specify custom binary only once using TG's method but covering also TF? 🤔 And from this point of view it makes sense to me.
@den-is What's your idea?
Co-authored-by: George L. Yermulnik <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from #670 (comment) that I didn't get why TF switched from latest
to exact version.
README.md
Outdated
@@ -103,7 +115,7 @@ All available tags [here](https://github.com/antonbabenko/pre-commit-terraform/p | |||
**Build from scratch**: | |||
|
|||
> [!IMPORTANT] | |||
> To build image you need to have [`docker buildx`](https://docs.docker.com/build/install-buildx/) enabled as default builder. | |||
> To build image you need to have [`docker buildx`](https://docs.docker.com/build/install-buildx/) enabled as default builder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was fixed by VSCode automatically.
Will check for workaround
hooks/_common.sh
Outdated
# Maybe there is a similar setting for Terragrunt already | ||
elif [[ $TERRAGRUNT_TFPATH ]]; then | ||
echo "${TERRAGRUNT_TFPATH}" | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imagine you are working in some environment that already uses TERRAGRUNT_TFPATH
env variable (global env, using direnv, or any other method)
So if a variable already exists and serves exactly the same purposes, why not to check it and reuse it, why to have other args/vars/etc?
hooks/_common.sh
Outdated
# Maybe there is a similar setting for Terragrunt already | ||
elif [[ $TERRAGRUNT_TFPATH ]]; then | ||
echo "${TERRAGRUNT_TFPATH}" | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I'm following the gist of the question, though probably (I'm purely guesstimating) this way it would be easier for people using both TF and TG hooks to specify custom binary only once using TG's method but covering also TF? 🤔 And from this point of view it makes sense to me.
@yermulnik Erm... this was already replied to by me yesterday.
Add the below to config of VSCode of yours: "[markdown]": {
"files.trimTrailingWhitespace": false
} Other common useful settings VSCode usually is missing from what I've found from experience of others using it: "files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true, |
lol dude... i always have this setting in all my editors... for years... you basically copy pasted my snippets which I add to different projects were noobs can't solve their whitespace issues. Only thing I was not able to find correct settings for VSCode to fix |
Space trimming and so on should be done by TOC is not supported by built-in MD engine, for this I use https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one With "markdownlint.config": {
"MD029": false,
"MD012": {
"maximum": 5
}
},
"markdown.extension.toc.unorderedList.marker": "*",
"markdown.extension.toc.levels": "2..6", I'll check vanilla VS Code settings and then will send PR which will add needed configs and/or rewrite MD file |
In case if person uses VSCode, most of .editorconfig settings are supported natively. Otherwise you have to install another extension. But yea, addined |
It's probably not the VSCode per se, but an extension. Like some of these: https://github.com/yzhang-gh/vscode-markdown or https://github.com/prettier/prettier-vscode BTW FWIW: yzhang-gh/vscode-markdown#145
It's not ours. It's Markdown language specification. Unless you prove otherwise. PS: I looked at |
# [1.90.0](v1.89.1...v1.90.0) (2024-05-23) ### Features * Support set custom TF/OpenTofu binary. | If you use a custom Docker image build, please note that `TERRAFORM_VERSION` now must be provided ([#670](#670)) ([c7011c0](c7011c0))
This PR is included in version 1.90.0 🎉 |
Put an
x
into the box if that apply:Description of your changes
Allow setting custom TF binary.
--hook-config=--tf-path=<path_to_binary_or_binary_name>
PCT_TFPATH=<path_to_binary_or_binary_name>
TERRAGRUNT_TFPATH=<path_to_binary_or_binary_name>
terraform
binary found in the user's $PATHtofu
binary found in the user's $PATHexit 1
with error messageSide feature. Fixes bad README.md
I'm open to any suggestion and contributions.
Fixes #570
How can we test changes
Create dummy repository with a dummy terraform module
test
Add files to
test/
:.pre-commit-config.yaml
main.tf
Run in the test module directory: