pre-commit-terraform: The `terraform-docs` hook no longer generated since the pre-commit-terraform v1.95.0

The version description says that terraform-doc versions less than v0.12 are no longer supported. However, I have terraform-docs v0.19 in $PATH and README.md is not generated. If I revert pre-commit-terraform to v1.94.3 everything works.

.pre-commit-config.yaml:

repos:
  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: v1.95.0
    hooks:
      - id: terraform_docs
        args:
          - --hook-config=--path-to-file=README.md
          - --hook-config=--add-to-existing-file=true
          - --hook-config=--create-file-if-not-exist=true
          - --hook-config=--use-standard-markers=true
          - --args=--config=.terraform-docs.yml

.terraform-docs.yml:

---
formatter: markdown table
output:
  file: README.md
  mode: inject

sort:
  enabled: true
  by: required

settings:
  anchor: true
  color: true
  default: true
  description: false
  escape: true
  hide-empty: false
  html: true
  indent: 2
  lockfile: true
  read-comments: true
  required: true
  sensitive: true
  type: true

Environment information

  • OS: Win11 with Ubuntu 24.04 on WSL2
Linux 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Description: Ubuntu 22.04.3 LTS
  • Tools availability and versions:
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
pre-commit 3.6.2
bash: line 3: tofu: command not found
Terraform v1.5.3
python SKIPPED
Python 3.10.12
checkov SKIPPED
infracost SKIPPED
terraform-docs version v0.19.0 linux/amd64
terragrunt version v0.54.15
terrascan SKIPPED
TFLint version 0.53.0
+ ruleset.terraform (0.9.1-bundled)
tfsec SKIPPED
trivy SKIPPED
tfupdate SKIPPED
hcledit SKIPPED

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 18 (1 by maintainers)

Most upvoted comments

Confirm that new README.md not generated for 1.95.0 and 1.96.2 with

        id: terraform_docs
        args:
          - --hook-config=--add-to-existing-file=true
          - --hook-config=--create-file-if-not-exist=true  # <---- This one broken?
          - --args=--lockfile=false
          - --hook-config=--parallelism-ci-cpu-cores=4 # DinD, can't calculate CPU cores

v1.94.3 works.

The workaround doesn’t work for me either. I had to revert to v1.94.2.

The code: .pre-commit-config.yaml .terraform-docs.yml

So, I can confirm that removing the line with - --hook-config=--path-to-file=README.md helped and README.md started generating. With this line, the generation did not start and no errors were displayed.

I will not close the Issue, as I can see that obviously work will be done on it. Thank you so much for your help!