Repository navigation
feat: add fork PR contributor approval resources and data sources - #3726
Draft
benlangfeld wants to merge 2 commits into
Draft
benlangfeld wants to merge 2 commits into
benlangfeld wants to merge 2 commits into
Conversation
Wrap the GitHub REST `actions/permissions/fork-pr-contributor-approval` endpoints (repo + org) in four new Terraform building blocks: - resource `github_actions_repository_fork_pr_contributor_approval` - resource `github_actions_organization_fork_pr_contributor_approval` - data source `github_actions_repository_fork_pr_contributor_approval` - data source `github_actions_organization_fork_pr_contributor_approval` Each accepts `approval_policy` in the three GitHub-documented enum values (`first_time_contributors_new_to_github`, `first_time_contributors`, `all_external_contributors`). The API has no "off" state for this policy. On Delete, the resource resets the policy to GitHub's documented default (`first_time_contributors`) to avoid leaving non-default residual state, matching the precedent set by `github_actions_organization_permissions` Delete (which resets to `all`). go-github already exposes the matching service methods on `*ActionsService` (GetForkPRContributorApprovalPermissions / Update... and the Organization* variants), so this is purely a provider-side wrapper. New resources are implemented with context-aware CRUD functions (`CreateContext` / `ReadContext` / `UpdateContext` / `DeleteContext` returning `diag.Diagnostics`) per the migration tracked in integrations#2996, rather than copying the legacy pattern from the nearby `access_level` and `organization_permissions` resources that are themselves on that migration's to-do list. Acceptance test notes: - Repo-level tests use `visibility = "public"` because configuring `fork-pr-contributor-approval` on private repos returns 422 when the org's `fork-pr-workflows-private-repos` setting has fork-PR workflows disabled. Public repos exercise the endpoint without that prerequisite. - The repo-level test allows both `individual` and `organization` auth modes so it can be exercised against an org-scoped test token. Doc generation was authored against `make generatedocs` templates and the rendered output is included; `make validatedocs` was not run locally because the dev environment lacks a `terraform` binary. CI will validate.
Follow the pattern newer repository-scoped resources use: store the repository ID and diff on it, so renaming the repository updates the resource in place while pointing it at another repository replaces it. A deleted repository now drops the resource from state instead of failing the refresh. Also check type assertions, which the strict lint config requires of new code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 5 tasks
|
👋 Hi, and thank you for this contribution! This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can. You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions. 🤖 This is an automated message. |
Author
|
Hey @acouvreur would you mind taking a look at this one? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #3445
Supersedes #3446, which has been waiting since September on @donicrosby to confirm they're still working on it. Their commit is kept as-is, with Doni as author.
Before the change?
After the change?
main. Doni's commit only moves its imports from go-github v86 to v92.github_actions_repository_fork_pr_contributor_approvalup to the pattern newer repository-scoped resources follow:diffRepository. Renaming the repository updates the resource in place; pointing it at another repository replaces it. Before, changingrepositoryleft the old repository's policy behind.Testing
make lintcheck, the strict lint for new code (.golangci.new.yml,--new-from-merge-base main) andmake testpass.Acceptance tests have not been run on this version yet. The repository resource's tests cover the new rename and replace behaviour, and I'll run them against a personal account before marking this ready. The organization resource is unchanged apart from the lint fix; #3446's description records its acceptance test passing.
I edited
docs/resources/actions_repository_fork_pr_contributor_approval.mdby hand to match its template, becausemake generatedocsfails locally on a cleanmainwith Terraform 1.17.Pull request checklist
Does this introduce a breaking change?
AI use
Written with Claude Code, which also helped draft this description. I've reviewed the change against the provider's existing patterns and stand behind it. It stays a draft until the acceptance tests have run.
🤖 Generated with Claude Code