pre-commit-terraform icon indicating copy to clipboard operation
pre-commit-terraform copied to clipboard

Merge `terraform_docs_replace` functionality to `terraform_docs`

Open MaxymVlasov opened this issue 4 years ago β€’ 4 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

MaxymVlasov avatar Oct 15 '21 12:10 MaxymVlasov

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).

adamantike avatar Nov 08 '21 19:11 adamantike

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.

sharkymcdongles avatar Mar 01 '22 08:03 sharkymcdongles

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

MaxymVlasov avatar Mar 02 '22 14:03 MaxymVlasov

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!!!

sharkymcdongles avatar Mar 02 '22 15:03 sharkymcdongles

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 avatar Oct 25 '22 16:10 carlosjgp

@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

MaxymVlasov avatar Nov 04 '22 20:11 MaxymVlasov

This issue has been resolved in version 1.76.1 :tada:

antonbabenko avatar Nov 26 '22 18:11 antonbabenko