Skip to content

feat: simplify args inputs for terraform_docs#155

Closed
1oglop1 wants to merge 1 commit intoantonbabenko:masterfrom
jans-forks:master
Closed

feat: simplify args inputs for terraform_docs#155
1oglop1 wants to merge 1 commit intoantonbabenko:masterfrom
jans-forks:master

Conversation

@1oglop1
Copy link

@1oglop1 1oglop1 commented Oct 21, 2020

This should fix #154.
I removed getopt and instead simply passed args array in the same order as specified via .pre-commit-config.yaml file.

example usage:

  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: <version>
    hooks:
      - id: terraform_docs
        verbose: true
        name: Terraform docs
        description: Inserts input and output documentation into README.md (using terraform-docs).
        require_serial: true
        entry: _ignore/pre-commit-terraform/terraform_docs.sh
        language: script
        files: (\.tf)$
        exclude: \.terraform\/.*$
        args:
          - --header-from=doc.tf
          - --hide-all
          - md

@1oglop1
Copy link
Author

1oglop1 commented Oct 21, 2020

@antonbabenko Take this as an initial proposal, there is some additional cleanup required but I'll put more effort after discussion.

But I think that ideal solution which could resolve more issues regarding the version would be to discard bash and write some Go code with the same functionality and PR it to the original repository, however, that might be more work.

@1oglop1
Copy link
Author

1oglop1 commented Dec 3, 2020

nudge @antonbabenko could you please provide your opinion on this? PR received a few reactions from which I assume it's a wanted feature by more people.

Thank you.

@antonbabenko
Copy link
Owner

Hi @1oglop1 ! There is simply not enough time for me to review all the projects I am involved in. I assigned @robinbowes to take a look if he has some time.

@GenPage
Copy link

GenPage commented Jan 11, 2021

@robinbowes Any update on your review?

@1oglop1
Copy link
Author

1oglop1 commented Feb 11, 2021

@Vlaaaaaaad I noticed you liked my PR, and since @antonbabenko takes preference on issues/PRs from sponsors it may help if you participate in the discussion to give @antonbabenko incentive to look and comment on this change

@maulik-vimond
Copy link

maulik-vimond commented Mar 11, 2021

Can this be merged? Out of the box terraform-docs does not work right now unless we downgrade terraform-docs.

And to make it worse homebrew does not have older versions available.

@robinbowes
Copy link
Contributor

does not work right now

What doesn't work? It's working for me.

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v3.4.0
  hooks:
    - id: check-yaml
    - id: trailing-whitespace
    - id: end-of-file-fixer
- repo: https://github.com/antonbabenko/pre-commit-terraform
  rev: v1.47.0
  hooks:
    - id: terraform_validate
      args:
        - '--envs=AWS_DEFAULT_REGION=us-east-1'
    - id: terraform_fmt
    - id: terraform_docs
 $ terraform-docs --version
terraform-docs version v0.11.2 darwin/amd64 BuildDate: 2021-02-23T00:25:32+0000

@maulik-vimond
Copy link

maulik-vimond commented Mar 11, 2021

What doesn't work? It's working for me.

How is your terraform code structured? Mine is in a sub-folder. Please see the issue #181.

Actually this PR will not help with my issue since the path is hardcoded in terraform_docs.sh. I was hoping initially that by using the fix from the PR I will be able to pass in the target module directory.

if [[ "$terraform_docs_awk_file" == "0" ]]; then
# shellcheck disable=SC2086
terraform-docs md $args ./ > "$tmp_file"
terraform-docs $args ./ > "$tmp_file"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To provide backward compatibility shouldn't $args have md default somewhere?

@ezio-ballarin
Copy link

I also noticed I can't pass args to the terraform-docs hook. here's my config:

repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
  rev: v1.50.0 
  hooks:
    - id: terraform_fmt
    - id: terraform_docs
      args: 
        - '--args=--sort-by=required --hide=providers'
~$ pre-commit -V
pre-commit 2.13.0
~$ terraform-docs version
terraform-docs version v0.13.0 linux/amd64 BuildDate: 2021-05-27T15:35:35-07:00

argv=($@)

for arg in ${argv[@]}; do
echo WORKING with: \"$arg\"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also hide this print or should echo when verbose is enabled.

@MaxymVlasov MaxymVlasov self-assigned this Oct 1, 2021
@MaxymVlasov MaxymVlasov added the breaking-changes The current implementation contains Breaking Changes / Can't be implemented without Breaking Changes label Oct 14, 2021
@MaxymVlasov MaxymVlasov removed their assignment Oct 14, 2021
@MaxymVlasov MaxymVlasov changed the title Accept arguments from .pre-commit-config.yaml feat: simplify args inputs for terraform_docs Oct 14, 2021
@MaxymVlasov MaxymVlasov added feature New feature or request and removed bug Something isn't working labels Oct 14, 2021
@MaxymVlasov MaxymVlasov removed this from the Bug and docs fixes milestone Oct 14, 2021
@MaxymVlasov MaxymVlasov added the on-hold Indicates that an issue or PR should not be auto-closed due to staleness. label Oct 14, 2021
@MaxymVlasov MaxymVlasov mentioned this pull request Dec 23, 2021
4 tasks
@MaxymVlasov MaxymVlasov mentioned this pull request Feb 10, 2022
4 tasks
@MaxymVlasov
Copy link
Collaborator

Too outdated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker area/local_installation breaking-changes The current implementation contains Breaking Changes / Can't be implemented without Breaking Changes estimate/2days Need 2 work days to be done feature New feature or request hook/terraform_docs Bash hook on-hold Indicates that an issue or PR should not be auto-closed due to staleness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wrong arguments passed to terraform-docs (v0.10.0 and v0.10.1

8 participants