Skip to content

feat: Support .tofu files - #246

Closed
mnorbury wants to merge 1 commit into
masterfrom
mnorbury/repository-review
Closed

mnorbury wants to merge 1 commit into
masterfrom
mnorbury/repository-review

Conversation

@mnorbury

@mnorbury mnorbury commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Terratag only discovered *.tf files, so resources in OpenTofu *.tofu files were never tagged. This PR discovers *.tofu files in terraform, terragrunt and terragrunt-run-all modes. Tagged output keeps the input file extension.

Changes

  • Discover *.tofu alongside *.tf in GetFilePaths.
  • Tagged output keeps the input extension: main.tofu becomes main.terratag.tofu. Before, a main.tf/main.tofu twin pair both wrote main.terratag.tf. OpenTofu's rule that .tofu takes precedence over a same-named .tf still holds after tagging.
  • Skip *.terratag.tofu as well as *.terratag.tf on re-runs.
  • README: document .tofu handling for -dir, -skipTerratagFiles and -rename.
  • Fixtures: tofu_file, tofu_file_with_tf_twin and tofu_already_tagged, added to terraform_latest (so they also run under TestOpenTofu). Add a .tofu file to terragrunt_unit.
  • Unit tests: TestGetFilePathsIncludesTofuFiles, TestReplaceWithTerratagFileKeepsExtension.

Testing

  • SKIP_INTEGRATION_TESTS=1 go test ./...
  • go vet ./...
  • go fmt ./...
  • TestTerraformlatest (Terraform 1.16.0)
  • TestOpenTofu (OpenTofu 1.12.6)
  • TestTerragruntWithCache and TestTerragruntRunAll (Terragrunt 1.1.6, Terraform 1.16.0)

Discover *.tofu alongside *.tf in Terraform and Terragrunt modes. Tagged
output keeps the input extension (main.tofu -> main.terratag.tofu) so a
main.tf/main.tofu twin pair no longer races to write the same
main.terratag.tf, and OpenTofu's twin precedence still holds after tagging.
Re-runs skip *.terratag.tofu as well as *.terratag.tf.

Adds tofu_file, tofu_file_with_tf_twin and tofu_already_tagged fixtures,
a .tofu file to terragrunt_unit, and unit tests for discovery and rename.
@mnorbury mnorbury closed this Oct 5, 2026
@mnorbury
mnorbury deleted the mnorbury/repository-review branch October 5, 2026 15:26
@mnorbury

mnorbury commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #247. Renaming the branch closed this PR, and GitHub cannot reopen it on the new branch.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant