Skip to content
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

terraform_docs generated output incorrect when output.file is configured #697

Closed
sworisbreathing opened this issue Aug 16, 2024 · 3 comments · Fixed by #698
Closed

terraform_docs generated output incorrect when output.file is configured #697

sworisbreathing opened this issue Aug 16, 2024 · 3 comments · Fixed by #698
Labels

Comments

@sworisbreathing
Copy link
Contributor

Describe the bug

When output.file is specified, terraform-docs directly updates this file and prints the message: README.md updated successfully (or similar) to stdout. Because the terraform_docs hook always redirects stdout to the file, we end up with the below:

<!-- BEGIN_TF_DOCS -->
README.md updated successfully
<!-- END_TF_DOCS -->

How can we reproduce it?

in .terraform-docs.yml:

output:
  file: "./README.md"
  # ... other settings as required

in .pre-commit-config.yaml:

repos:
  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: v1.92.1
    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

Environment information

  • OS: Windows 10
  • uname -a and/or systeminfo | Select-String "^OS" output:
OS Name:                   Microsoft Windows 10 Enterprise
OS Version:                10.0.19045 N/A Build 19045
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Member Workstation
OS Build Type:             Multiprocessor Free
  • Tools availability and versions:
GNU bash, version 5.2.26(1)-release (x86_64-pc-msys)
pre-commit 3.8.0
/usr/bin/bash: line 3: tofu: command not found
Terraform v1.5.5
Python 3.10.11
Python 3.10.11
checkov 3.2.223
infracost SKIPPED
terraform-docs version v0.18.0 228c7a7 windows/amd64
terragrunt SKIPPED
terrascan SKIPPED
TFLint version 0.52.0
+ ruleset.terraform (0.9.1)
+ ruleset.aws (0.32.0)
tfsec v1.28.10
trivy Version: 0.54.1
Check Bundle:
  Digest: sha256:ef2d9ad4fce0f933b20a662004d7e55bf200987c180e7f2cd531af631f408bb3
  DownloadedAt: 2024-08-15 02:35:34.5007199 +0000 UTC
tfupdate SKIPPED
hcledit SKIPPED
  • .pre-commit-config.yaml:
file content
# See http://pre-commit.com for more information
# See http://pre-commit.com/hooks.html for more hooks

repos:
  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: v1.92.1
    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
@MaxymVlasov
Copy link
Collaborator

Minimum reproducible config:

.pre-commit-config.yaml

repos:
  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: v1.92.1
    hooks:
      - id: terraform_docs
        args:
          - --hook-config=--use-standard-markers=true
          - --args=--config=.terraform-docs.yml

.terraform-docs.yml

formatter: "md"

output:
  file: "./README.md"

@MaxymVlasov
Copy link
Collaborator

Relates to #382 (comment)

@antonbabenko
Copy link
Owner

This issue has been resolved in version 1.92.2 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants