Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Terraform module (modules/gh-files-set) intended to manage a set of files in GitHub repositories (issue #969), and wires it into the repo’s release automation configuration.
Changes:
- Added new
gh-files-setTerraform module usinggithub_repository_fileto manage multiple files via a singleconfigobject. - Added module docs scaffolding (
terraform-docsconfig + header/footer content) and a basic example YAML input. - Registered the new module package in
release-please-config.json.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| release-please-config.json | Registers modules/gh-files-set as a release-please package. |
| modules/gh-files-set/main.tf | Implements managed vs “user-managed” GitHub repository files. |
| modules/gh-files-set/variables.tf | Defines the config input schema + validations. |
| modules/gh-files-set/outputs.tf | Exposes a list of user-managed file paths. |
| modules/gh-files-set/versions.tf | Declares GitHub provider requirement (missing required Terraform version constraint). |
| modules/gh-files-set/docs/header.md | Module overview and usage snippet for terraform-docs injection. |
| modules/gh-files-set/docs/footer.md | Footer content for terraform-docs injection (currently includes scaffolding/code fences). |
| modules/gh-files-set/README.md | Generated/injected docs (currently out of sync with module interface/resources/outputs). |
| modules/gh-files-set/.terraform-docs.yml | terraform-docs configuration for README generation. |
| modules/gh-files-set/_examples/basic/files.yaml | Example input YAML (currently does not match the module input schema). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
modules/gh-files-set/README.md
Outdated
| | [github_repository_file.files](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_file) | resource | | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Name | Description | Type | Default | Required | | ||
| |------|-------------|------|---------|:--------:| | ||
| | <a name="input_config"></a> [config](#input\_config) | Configuration for multiple GitHub repository files to be created/updated | <pre>object({<br/> files = list(object({<br/> branch = string<br/> commitMessage = string<br/> content = string<br/> file = string<br/> repository = string<br/> overwriteOnCreate = optional(bool, true)<br/> lifecycle = optional(any, {}) # placeholder for future extensions<br/> }))<br/> })</pre> | n/a | yes | | ||
|
|
||
| ## Outputs | ||
|
|
||
| | Name | Description | | ||
| |------|-------------| | ||
| | <a name="output_commit_messages"></a> [commit\_messages](#output\_commit\_messages) | Commit messages that were used | | ||
| | <a name="output_committed_files"></a> [committed\_files](#output\_committed\_files) | List of files that were successfully managed | | ||
| | <a name="output_file_paths"></a> [file\_paths](#output\_file\_paths) | Flat list of managed file paths (repo/path) | | ||
|
|
||
| ### 5. `docs/footer.md` | ||
|
|
||
| ```markdown | ||
| ## Examples | ||
|
|
||
| See [_examples/basic](https://github.com/prefapp/tfm/tree/main/modules/gh-files-set/_examples/basic) | ||
|
|
||
| ## Resources | ||
|
|
||
| - **github_repository_file** | ||
| https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_file | ||
|
|
||
| ## Support | ||
|
|
||
| Open issues in https://github.com/prefapp/tfm/issues | ||
| ``` |
There was a problem hiding this comment.
Pull request overview
Adds a new Terraform module (modules/gh-files-set) intended to manage a set of files in a GitHub repository (issue #969), and wires it into the repo’s release-please module list.
Changes:
- Added
gh-files-setTerraform module (GitHub provider, variables/outputs, example, terraform-docs config, generated README). - Added module docs scaffolding (
docs/header.md,docs/footer.md) and a basic YAML example. - Registered the module in
release-please-config.json.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| release-please-config.json | Registers modules/gh-files-set as a release-please package. |
| modules/gh-files-set/versions.tf | Declares the GitHub provider requirement for the new module. |
| modules/gh-files-set/variables.tf | Defines the module’s config schema and validations. |
| modules/gh-files-set/main.tf | Implements managed vs “userManaged” GitHub repository file resources. |
| modules/gh-files-set/outputs.tf | Exposes a list of “userManaged” file identifiers. |
| modules/gh-files-set/docs/header.md | Module documentation header content for terraform-docs. |
| modules/gh-files-set/docs/footer.md | Module documentation footer content for terraform-docs. |
| modules/gh-files-set/_examples/basic/files.yaml | Provides a YAML example intended for yamldecode(...) input. |
| modules/gh-files-set/README.md | Generated terraform-docs README for the module. |
| modules/gh-files-set/.terraform-docs.yml | terraform-docs configuration for generating the module README. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for_each = { | ||
| for f in var.config.files : "${f.file}/${f.branch}" => f | ||
| if f.userManaged | ||
| } |
There was a problem hiding this comment.
Same ambiguous for_each key issue here ("${f.file}/${f.branch}"): branch names may contain '/', and file paths almost certainly do. This can cause key collisions and unexpected resource addressing. Prefer an unambiguous composite key (e.g., jsonencode([f.file, f.branch])).
| data "github_repository" "this" { | ||
| full_name = var.config.repository | ||
| } | ||
|
|
||
| # Normal files — Terraform fully enforces content | ||
| resource "github_repository_file" "managed" { | ||
| for_each = { | ||
| for f in var.config.files : "${f.file}/${f.branch}" => f | ||
| if !f.userManaged | ||
| } | ||
|
|
||
| repository = data.github_repository.this.name | ||
| branch = each.value.branch |
There was a problem hiding this comment.
config.repository is validated as owner/repo, but the module ultimately passes only data.github_repository.this.name (repo name) to github_repository_file. This drops the owner portion and means the actual target owner will be whatever the GitHub provider is configured for. Either (a) change the input/validation/docs to accept a repo name only, or (b) adjust the implementation so the repository identifier used by github_repository_file matches what callers provide.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
solves #969