antonbabenko / pre-commit-terraform

pre-commit git hooks to take care of Terraform configurations 🇺🇦

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Merge `terraform_docs_replace` functionality to `terraform_docs`

MaxymVlasov opened this issue · comments

What problem are you facing?

It's mostly the same hooks, that need to be maintained separately.

How could pre-commit-terraform help solve your problem?

Decrease maintainability flow, like this #177

If this idea is already accepted, can it have a short-term fix to mark terraform_docs_replace as deprecated? I started using these hooks last week, and went with terraform_docs_replace because of wanting for the Readme to be completely managed by it. However, right now, the shortcomings of going with this hook aren't listed (mainly, unsupported terraform-docs flags).

commented

Can you please document how to use terraform_docs hook to have identical behavior to terraform_docs_replace since it is now deprecated? I couldn't seem to find any documentation on this as you'd expect with a deprecation.

Hi, sure we do. But for me, firstly need to understand what the terraform_docs_replace hook does.
Those plans were postponed during all our team members now at war with Russia, during their full-scale invasion of our homeland, Ukraine.
So, it deprecated, but not to be removed until summer, I guess.

Feel free to send your PR with this doc

commented

Hi, sure we do. But for me, firstly need to understand what the terraform_docs_replace hook does. Those plans were postponed during all our team members now at war with Russia, during their full-scale invasion of our homeland, Ukraine. So, it deprecated, but not to be removed until summer, I guess.

Feel free to send your PR with this doc

I didn't know they were from there. I will try and understand how it works with some testing on my end and submit some docs then. Slava Ukraini!!!

This is how I did replicate the functionality of terraform_docs_replace with terraform_docs

Add .terraform-docs.yml to the root of the project

formatter: "markdown"

output:
  file: "README.md"
  mode: replace
  template: |-
    {{ .Content }}
    {{/** End of file fixer */}}

Update the hook version

repos:
  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: v1.76.0
    hooks:
      - id: terraform_docs
        args:
          - --args=--config=.terraform-docs.yml

Other versions
Terraform: 1.3.2
terraform-docs: terraform-docs version v0.16.0 1f686b1 linux/amd64

@carlosjgp Amazing!
Now we can add .terraform-docs.yml instructions to README, and print out the link to the replacement instruction ( https://github.com/antonbabenko/pre-commit-terraform/issues/248#issuecomment-1290829226) in terraform_docs_replace hook here

Would you like to make PR? If not - I'll create it

This issue has been resolved in version 1.76.1 🎉