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

When using the config-file option, defaults cause unwanted overrides #84

Open
luigidifraia opened this issue May 21, 2022 · 0 comments
Open
Labels
bug Something isn't working

Comments

@luigidifraia
Copy link

Describe the bug

GitHub workflow file for reference available here.

Despite using the config-file option, action defaults appear to cause unwanted overrides. From an action log from the repo I am testing with, you can clearly see the unwanted behaviour:

::debug working_dir=.
::debug config_file=.terraform-docs.yml
::debug output_mode=inject
::debug output_file=README.md
::debug terraform-docs markdown table --config .terraform-docs.yml --output-mode inject --output-file README.md --output-template <!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS --> .
README.md updated successfully
modules/dns/README.md updated successfully
modules/ipam/README.md updated successfully
modules/network_firewall_vpc/README.md updated successfully
modules/tgw/README.md updated successfully
modules/vpc_endpoints/README.md updated successfully

As .terraform-docs.yml already contains all the desired settings, none of the following defaults is desirable:

markdown table
--output-mode inject
--output-file README.md
--output-template <!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->

None of the modules/**/README.md files should have been created.

This is what should have happened, i.e. only the README.md file in the root folder should have been updated, according to the contents of the .terraform-docs.yml file in the root folder and those in the module/*/ subfolders:

::debug working_dir=.
::debug config_file=.terraform-docs.yml
::debug terraform-docs --config .terraform-docs.yml .
README.md updated successfully
README.md updated successfully
README.md updated successfully
README.md updated successfully
README.md updated successfully
README.md updated successfully

That produces the correct results and is consistent with running terraform-docs v0.16.0 manually in the repo root:

C:\github-repos\aws-network-hub-for-terraform> terraform-docs --config .terraform-docs.yml .
README.md updated successfully
README.md updated successfully
README.md updated successfully
README.md updated successfully
README.md updated successfully
README.md updated successfully

Long story short: when using the config-file option, no defaults should be passed down to terraform-docs. For backward compatibility, one could perhaps add an ignore-defaults option.

How can we reproduce it?

You can:

  1. fork the repo I am testing with
  2. create a branch in which you update any of the outputs.tf files
  3. start a pull request

Environment information

This is running a GitHub action directly. See GitHub workflow file.

@luigidifraia luigidifraia added the bug Something isn't working label May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant