-
-
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: Add terraform_graph
hook
#589
base: master
Are you sure you want to change the base?
Conversation
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.
Please add hook and it deps to Dockerfile
And double-check https://github.com/antonbabenko/pre-commit-terraform/blob/master/.github/CONTRIBUTING.md#add-new-hook - you could miss something else
local -a -r args=("$@") | ||
|
||
if [[ ! $(command -v dot) ]]; then | ||
echo "ERROR: dot is required by terraform_graph pre-commit hook but is not installed or in the system's PATH." |
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.
Let's add some colors
echo "ERROR: dot is required by terraform_graph pre-commit hook but is not installed or in the system's PATH." | |
common::colorify "red" "ERROR: dot is required by terraform_graph pre-commit hook but is not installed or in the system's PATH." |
@@ -926,6 +930,16 @@ If the generated name is incorrect, set them by providing the `module-repo-short | |||
Check [`tfupdate` usage instructions](https://github.com/minamijoyo/tfupdate#usage) for other available options and usage examples. | |||
No need to pass `--recursive .` as it is added automatically. | |||
|
|||
### terraform_graph | |||
`terraform_graph` utilizes Terraform's built-in [`graph` command](https://developer.hashicorp.com/terraform/cli/commands/graph) and `dot` from [GraphViz](https://www.graphviz.org/) to generate charts of your configuration. | |||
|
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.
Would be nice to have an example image of resulting graph here
You can populate it inside assets/
dir
@MaxymVlasov, awesome, I'll work on this. Thanks for your help. |
@jrdnbradford howdy. Do you plan to continue working on this PR? Do you need any help from our side? |
I’m really crossing my fingers that @jrdnbradford pulls off this new feature! . I'm looking forward to using it. |
Put an
x
into the box if that apply:Description of your changes
This adds a
terraform_graph
hook that generates charts usingterraform graph
and GraphViz. My org finds something like this helpful to upkeep documentation.Test results
200 runs '
terraform_graph
v0.0.1:'Run details
TEST_NUM
200
TEST_COMMAND
pre-commit try-repo -a /home/$user/Desktop/pre-commit-terraform terraform_graph
TEST_DIR
/home/$user/$repo
TEST_DESCRIPTION
200 runs '
terraform_graph
v0.0.1:'RAW_TEST_RESULTS_FILE_NAME
terraform_graph_results
Memory info (
head -n 6 /proc/meminfo
):CPU info:
How can we test changes
Testing can be performed by running against a repo with
*.tf
files and ensuring that the correct*.svg
files are output in each directory:The most important configs for the hook are
-type
and a hook config--path-to-file
that sets the name of the output*.svg
.I cannot say that I'm a particularly good shell scripter, so if there's interest in adding this please feel free to edit.