-
-
Notifications
You must be signed in to change notification settings - Fork 541
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
How to run terraform-docs for code inside a sub folder #181
Comments
I found the problem, pre-commit-terraform/terraform_docs.sh Line 128 in d303bff
And I have found the workaround using EDIT: I have updated the code to point to the correct version |
Can you share the workaround please? We also have terraform in sub folders |
@sajid-khan-js We simply switched to using the following that will create TFDOC.md file for each module (including nested modules).
|
Thanks @maulik-vimond.
Strangely, switching to I've only tested locally, so not sure if it's my setup. Once I get this added to our CI environment I can confirm the odd result. |
@sajid-khan-js yes of course. We came to a compromise of having a separate doc for terraform. I think pre-commit-terraform/terraform_docs.sh Line 139 in fa3859e
|
Is this still not working? I can't figure out how to get a single subfolder to work. Ideally, I want two "global" & "regional" -
pre-commit 2.13.0 |
I still have the same issue (empty markdown file in subfolders) with: The workaround below does not work for me
Workaround that worked for me (although it is not sorts):
and removal of '--sort-by-required' |
This issue has been automatically marked as stale because it has been open 30 days |
If I rightly understand this issue, here is few things that should be done:
|
Hi @maulik-vimond @brettcurtis @sajid-khan-js @ilyagorban-codefresh |
@MaxymVlasov - thanks for the update. I'm not sure that PR is addressing the issue I have of being able to populate the README with values from multiple terraform subfolders? |
Hmm, it's an interesting issue. @brettcurtis can you please create new feature request for that and provide details like:
├── dev
│ ├── README.md
│ └── dirs...
├── prod
│ ├── README.md
│ └── dirs...
|
Yes I agree with @brettcurtis. The core issue is that the current version checks for files in the current folder only. In our project we had all our terraform configuration inside a sub-folder. If you have multiple sub-folders as in your last example, that also needs to be addressed in this case. |
@maulik-vimond What do you mean by "current folder"? #245 introduce the ability to change the name and location of docfile, so after release, you'll be able to use constructions like: .
├── TFDOC.md
├── somefolder
│ ├── main.tf
│ ├── vars.tf that populates info about .tf files in
Well, I still need more details about this flow, as I mentioned above |
@MaxymVlasov By current folder, I meant the root folder where you have defined the pre-commit config file. I tested the |
I've tested this too and in my case I have no .tf file in my root but .tf files in multiple subfolders like so:
If I do this: - repo: git://github.com/antonbabenko/pre-commit-terraform
rev: c7835fe7151e844416d2fb42a729a18e4043de27
hooks:
- id: terraform_docs
args:
- --hook-config=--add-to-exiting-file=true # Boolean. true or false my root level README.md only populates from my infra folder and not my app folder. I would expect my root level README.md to populate with both I guess. That being said this works and populates a README.md in each folder: - repo: git://github.com/antonbabenko/pre-commit-terraform
rev: c7835fe7151e844416d2fb42a729a18e4043de27
hooks:
- id: terraform_docs
args:
- --hook-config=--path-to-file=README.md # Valid UNIX path. I.e. ../TFDOC.md or docs/README.md etc.
- --hook-config=--add-to-exiting-file=true # Boolean. true or false
- --hook-config=--create-file-if-not-exist=true # Boolean. true or false This is nice and what I can do is link from my root README.md to these individual folder README.md - Thanks for working on this! |
I am trying to run terraform-docs hook for the terraform configuration inside a subfolder called "terraform". When I run
pre-commit run terraform_docs -a
no documentation is generated. The output says "Passed" for terraform docs.But if I run terraform-docs manually it works using
terraform-docs md ./terraform
Here is my config file:
I am using,
pre-commit=
2.10.1
terraform-docs=
0.11.2
pre-commit-terraform=
1.47.0
The text was updated successfully, but these errors were encountered: