terramate-io / terramate

Terramate CLI is an open-source Infrastructure as Code (IaC) Orchestration and Code Generation tool for Terraform, OpenTofu and Terragrunt.
https://terramate.io
Mozilla Public License 2.0
3.24k stars 91 forks source link

[FEATURE] add source generator meta to generated comment #1661

Closed delconis closed 4 months ago

delconis commented 5 months ago

Is your feature request related to a problem? Please describe. When reviewing generated code, it's hard to determine which parent stack generated the item

Describe the solution you'd like I would like to see the current generated message // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT

To include the invoking generator that created it. // TERRAMATE: "dev/app/stack.tm.hcl" GENERATED AUTOMATICALLY DO NOT EDIT

Describe alternatives you've considered Some alternatives would be a way to list all the generated files in a given stack via cli terramate generate --list --chdir dev/app where the output might look like, and list would force and output for each generated item in the stack regardless if there is a modification.

Code generation report

Successes:

[ ] /dev/app
  [ ] provider.tf - Generated from (dev/stack.tm.hcl)
  [ ] backend.tf - Generated from (dev/app/stack.tm.hcl)
i4ki commented 5 months ago

Hi @delconis

Have you tried the terramate debug show generate-origins? For each generated file, it shows the file and line/column where it comes from.

Let me know if it helps you.

Fun fact: Terramate used to include the file name in the header but it caused too many stacks being triggered for changes (when using tm run --changed ...) whenever someone refactored the generated file names. See here the PR that removed it: https://github.com/terramate-io/terramate/pull/710

mariux commented 4 months ago

closing as we have a command to get the information, please reopen when needed.