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.12k stars 86 forks source link

[FEATURE] Automatically generate files if `auto_gen_code` is set to `true` #1716

Open g13013 opened 1 month ago

g13013 commented 1 month ago

Is your feature request related to a problem? Please describe. Right now, many commands complain about obsolete code which breaks the flow of dev, I want to propose introducing a new config attribute auto_gen_code inside the terramate block that tells Terramate to automatically generate code if obsolete.

Describe alternatives you've considered A wrapper script or shell alias that runs terramate generate before terramate commands

cwe1ss commented 1 month ago

Ideally there would be an environment variable and/or CLI-flag for this as well. I would prefer to set this locally only, but not in my CI/CD workflow.

The CI/CD workflow should fail if someone did not generate the code. (We also check this via pre-commit etc, but still, I think it would be good if this were environment-specific)

g13013 commented 2 weeks ago

Ideally there would be an environment variable and/or CLI-flag for this as well. I would prefer to set this locally only, but not in my CI/CD workflow.

Supporting a flag in the terramate.tm.hcl would be good as well to avoid repitition.

The CI/CD workflow should fail if someone did not generate the code. (We also check this via pre-commit etc, but still, I think it would be good if this were environment-specific)

I would argue that it should work in both environments. any terramate command, especially terramate run should auto-generate files if the config/variable/CLI-flag is set to auto as most run commands depend on the generated files. After that, it's up to the engineer to decide on whether to keep control on the files generation step or make it implicit.