This PR adds a feature to fogg.yml that allows users to add custom golang templates to components. Users will have full access to the plan's struct in the template, allowing them to write configuration files of their own without changing the fogg code base. This is handy when we have repeatable stacks for a specific application or environment, but don't necessarily need it to be hardcoded into the fogg codebase. We can think of these a mini fogg extensions.
You can provide a set of files to any component (env, account, global, default,...) and you can also specify if fogg should overwrite a file that already exists with the overwrite option (defaults to false). Setting overwrite to true would allow someone to scaffold and template an infra stack, but still be allowed to manage the component's infrastructure normally without worrying about fogg overwritting the changes.
Notice how instead of relying on env = var.tags.env, we could code-generate the local variable env with env = {{.Env | quote}}, since the template has access to the full component plan.
Summary
This PR adds a feature to fogg.yml that allows users to add custom golang templates to components. Users will have full access to the plan's struct in the template, allowing them to write configuration files of their own without changing the fogg code base. This is handy when we have repeatable stacks for a specific application or environment, but don't necessarily need it to be hardcoded into the fogg codebase. We can think of these a mini fogg extensions.
You can provide a set of files to any component (env, account, global, default,...) and you can also specify if fogg should overwrite a file that already exists with the
overwrite
option (defaults to false). Settingoverwrite
to true would allow someone to scaffold and template an infra stack, but still be allowed to manage the component's infrastructure normally without worrying about fogg overwritting the changes.Here's an example of how to call it:
In addition to the normal stuff fogg creates, it would also produce these files:
terraform/envs/dev/eks/variables.tf
terraform/envs/dev/eks/test.txt
Notice how instead of relying on
env = var.tags.env
, we could code-generate the local variableenv
withenv = {{.Env | quote}}
, since the template has access to the full component plan.