feat: add forgejo_team_repository resource - #155
Conversation
b432f61 to
596abad
Compare
acch
left a comment
There was a problem hiding this comment.
Hi @ap-1, thank you very much for your valuable contribution - and sorry for the delay in my response!
I like the idea of a dedicated resource to model the team <-> repo relationship. This is consistent with how we already model similar relationships, e.g. team members and repo collaborators. I like your design very much!
I do, however, have one concern: child resources (like forgejo_team_repository) referencing parent resources (forgejo_team, forgejo_repository) should generally use the numeric identifier for referencing the parent resource (with very few exceptions). Since the numeric ID is unknown at plan-time, Terraform implicitly knows that the parent resources must be created first, before the child resources can be created.
You do reference the parent team by ID (team_id) but not the parent repo (owner/repository). This means that Terraform is not aware of the dependency between the two. In fact, your example has a race condition: Terraform could attempt to create forgejo_team_repository first, before forgejo_repository is even finished...
Please reference both, team and repo by numeric ID. We already use repository_id in e.g. forgejo_repository_action_secret, forgejo_repository_webhook, and forgejo_collaborator, so I'd suggest to use the same semantics here.
For the import, however, I think that names are more appropriate than numeric identifiers. I like the current org/team/repo import identifier - no need to change that.
Do you think this makes any sense?
On a different note: I think your PR is missing acceptance tests for the new resource. Did you forget to include them?
|
Hi @ap-1 - do you agree with referencing both, teams and repos by numeric ID? Do you have questions, or is there anything I can help with? |
Adds a
forgejo_team_repositoryresource for managing team-to-repository assignments.The resource uses existing Forgejo SDK methods (
AddTeamRepository,RemoveTeamRepository,ListTeamRepositories). All attributes require replacement. Import is supported usingorg_name/team_name/repo_name, consistent withforgejo_team.Re #114: that issue requested a
reposselector onforgejo_teamat creation time, which would require SDK/API changes. This takes the dedicated join resource approach instead (cf.github_team_repository), which covers the same use case with the existing SDK.Closes #114
Closes #154