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

Allow to specify the version of terraform-docs for the hook to use

Open antonbabenko opened this issue 3 years ago β€’ 5 comments

Currently, terraform_docs (and similar) hooks will use the version of terraform-docs installed on the system.

With each major release of the terraform-docs the output format changes and users need to regenerate the docs.

We need to be able to pin a specific version in the hook so that we have more control over README.md.

Proposal:

  • Use args to define a specific version of docker image - https://terraform-docs.io/user-guide/installation/#docker

Sample:

repos:
  - repo: git://github.com/antonbabenko/pre-commit-terraform
    rev: v1.48.0
    hooks:
      - id: terraform_fmt
      - id: terraform_docs
        args: ['--version=0.12']

antonbabenko avatar Mar 26 '21 15:03 antonbabenko

@bryantbiggs I just want to link this one with the PR (eg, https://github.com/terraform-aws-modules/terraform-aws-alb/pull/190 ).

antonbabenko avatar Mar 27 '21 09:03 antonbabenko

Alternatively, you can directly use terraform-docs' version constraints instead of implementing the functionality in this pre-commit hook.

khos2ow avatar Jun 09 '21 18:06 khos2ow

Yes, this is a good option. If it would be implemented in pre-commit-terraform maybe we can also take care of installing the required version (not sure if it is a good idea though).

antonbabenko avatar Jun 09 '21 19:06 antonbabenko

In my opinion, since using .terraform-docs.yml as a single source for configuration becomes more popular it makes sense to delegate these kind of configurations and restrictions to terraform-docs itself. But on the other hand installing the required version as part of the hook is gonna be very useful I think.

khos2ow avatar Jun 09 '21 20:06 khos2ow

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Oct 10 '21 00:10 github-actions[bot]