Skip to content

feat: add github_enterprise_private_repository_forking_setting resource - #3361

Closed
andrewesweet wants to merge 4 commits into
integrations:mainfrom
andrewesweet:feat/enterprise-private-repo-forking
Closed

andrewesweet wants to merge 4 commits into
integrations:mainfrom
andrewesweet:feat/enterprise-private-repo-forking

Conversation

@andrewesweet

@andrewesweet andrewesweet commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #3363
Relates to #2851, #1844


Before the change?

  • No way to manage the enterprise-level private repository forking policy via Terraform.
  • The forking destination policy (where members can fork to) is only configurable through the GitHub UI or raw GraphQL mutations.

After the change?

  • New resource github_enterprise_private_repository_forking_setting that manages the enterprise-wide fork policy via the updateEnterpriseAllowPrivateRepositoryForkingSetting GraphQL mutation.
  • Supports setting (ENABLED, DISABLED, NO_POLICY) and policy (6 destination options including ENTERPRISE_ORGANIZATIONS_USER_ACCOUNTS for EMU environments).
  • Includes CustomizeDiff validation, import support, and full acceptance test suite (8 tests all passing).
  • Destroying the resource resets to NO_POLICY, returning control to individual organizations.

Example usage

resource "github_enterprise_private_repository_forking_setting" "example" {
  enterprise_slug = "my-enterprise"
  setting         = "ENABLED"
  policy          = "ENTERPRISE_ORGANIZATIONS_USER_ACCOUNTS"
}

Pull request checklist

  • Schema migrations have been created if needed
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

  • Yes
  • No

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@github-actions github-actions Bot added the Type: Feature New feature or request label Apr 22, 2026
@andrewesweet

andrewesweet commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Design note: schema shape

I considered collapsing setting and policy into a single attribute (with values DISABLED, NO_POLICY, SAME_ORGANIZATION, ENTERPRISE_ORGANIZATIONS_USER_ACCOUNTS, etc.) for a simpler user experience. However, the existing enterprise resources in this provider consistently map to the underlying API shape rather than presenting a facade over it — see github_enterprise_actions_permissions (enabled_organizations + allowed_actions) and github_enterprise_actions_workflow_permissions (default_workflow_permissions + can_approve_pull_request_reviews) for examples. I followed that convention here, keeping setting and policy as separate attributes to match the GraphQL mutation's settingValue and policyValue input fields.

I dropped the _value suffix from both attribute names — the API field names are settingValue/policyValue but the suffix is redundant in the Terraform schema context, and existing resources already rename API fields freely (e.g. MembersCanForkPrivateRepos → members_can_fork_private_repositories).

andrewesweet and others added 4 commits May 1, 2026 12:25
Add a new resource to manage the enterprise-level policy that controls
whether and where members can fork private and internal repositories.

This uses the GraphQL mutation
updateEnterpriseAllowPrivateRepositoryForkingSetting to set:
- setting_value: ENABLED, DISABLED, or NO_POLICY
- policy_value: controls fork destinations (e.g. SAME_ORGANIZATION,
  ENTERPRISE_ORGANIZATIONS_USER_ACCOUNTS, EVERYWHERE, etc.)

The resource includes CustomizeDiff validation ensuring policy_value
is required when enabled and forbidden otherwise. Delete resets to
NO_POLICY, returning control to individual organizations.

Relates to integrations#2851, integrations#1844

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ng tests

Add testAccEnterpriseForkingSettingConfig() and
testAccEnterpriseForkingSettingCheck() helpers plus a const for the
resource address. Reduces test file by ~40% while preserving all 8
test cases and their readability.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Use "This resource allows you to..." voice (matches all enterprise resources)
- Use "Creates and manages" in frontmatter description
- Move admin access note to inline text (matches enterprise_actions_permissions)
- Add empty "Attributes Reference" section (matches enterprise_security_analysis_settings)
- Remove ~> callout for destroy note (no precedent in enterprise resource docs)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The _value suffix is redundant — every attribute is a value. Shorter
names improve readability without losing clarity.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@robert-crandall

Copy link
Copy Markdown
Contributor

Thanks for putting this PR together and taking the time to contribute!

We're temporarily moving to an issue-first model (see CONTRIBUTING.md) where only collaborators can open PRs while we work through the backlog. Because of that, I'm going to close this PR for now.

I've linked it on #3363 so we don't lose your work or context when we pick that issue up. Feel free to add a 👍 or any extra notes there to help us prioritize it.

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

Labels

Type: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: Add resource for enterprise private repository forking policy

2 participants