Skip to content

feat: add forgejo_team_repository resource - #155

Open
ap-1 wants to merge 1 commit into
svalabs:mainfrom
ap-1:feat/team-repository
Open

feat: add forgejo_team_repository resource#155
ap-1 wants to merge 1 commit into
svalabs:mainfrom
ap-1:feat/team-repository

Conversation

@ap-1

@ap-1 ap-1 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Adds a forgejo_team_repository resource for managing team-to-repository assignments.

The resource uses existing Forgejo SDK methods (AddTeamRepository, RemoveTeamRepository, ListTeamRepositories). All attributes require replacement. Import is supported using org_name/team_name/repo_name, consistent with forgejo_team.

Re #114: that issue requested a repos selector on forgejo_team at 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

@ap-1
ap-1 requested a review from acch as a code owner June 16, 2026 02:55
@ap-1
ap-1 force-pushed the feat/team-repository branch from b432f61 to 596abad Compare June 16, 2026 03:01
@acch acch added enhancement New feature or request go Pull requests that update Go code labels Jun 21, 2026

@acch acch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@acch

acch commented Aug 5, 2026

Copy link
Copy Markdown
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature-Request: team to repository assignment Allow repos select for team resource

2 participants