-
Notifications
You must be signed in to change notification settings - Fork 911
feat: Add support for Enterprise Cost Centers #3000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
👋 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 |
|
We're trying to move towards using Context-aware provider functions, could you update all schemas to use those? So ReadContext etc |
c8cbff4 to
2f2c50c
Compare
13dcd40 to
1ab2c0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive support for GitHub Enterprise Cost Centers, enabling Terraform management of cost center resources and their assignments. The implementation addresses issue #2739 by leveraging the newly public GitHub Enterprise billing API.
Key changes:
- Introduces
github_enterprise_cost_centerresource for creating, updating, and archiving cost centers with authoritative management of user, organization, and repository assignments - Adds
github_enterprise_cost_centerandgithub_enterprise_cost_centersdata sources for querying cost center information - Implements robust resource assignment synchronization with batching (50 resources per request) and retry logic for transient failures
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| website/github.erb | Adds navigation links for the new data sources and resource |
| website/docs/r/enterprise_cost_center.html.markdown | Documents the cost center resource with examples, arguments, attributes, and import instructions |
| website/docs/d/enterprise_cost_center.html.markdown | Documents the single cost center data source for retrieving by ID |
| website/docs/d/enterprise_cost_centers.html.markdown | Documents the data source for listing cost centers with optional state filtering |
| github/util_cost_centers.go | Provides utility functions for API interactions including CRUD operations and resource assignment management |
| github/resource_github_enterprise_cost_center.go | Implements the cost center resource with full lifecycle management and authoritative assignment synchronization |
| github/provider.go | Registers the new resource and data sources with the provider |
| github/resource_github_enterprise_cost_center_test.go | Provides acceptance tests covering create, update, assignment changes, and import scenarios |
| github/data_source_github_enterprise_cost_centers_test.go | Tests the list data source with state filtering |
| github/data_source_github_enterprise_cost_centers.go | Implements the data source for listing cost centers |
| github/data_source_github_enterprise_cost_center_test.go | Tests the single cost center data source retrieval |
| github/data_source_github_enterprise_cost_center.go | Implements the data source for retrieving a specific cost center by ID |
| examples/cost_centers/main.tf | Provides a comprehensive example demonstrating resource and data source usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,57 @@ | |||
| --- | |||
| layout: "github" | |||
| page_title: "Github: github_enterprise_cost_center" | |||
Copilot
AI
Dec 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The page_title should be "GitHub" (with capital "H") to match the standard capitalization used throughout the codebase.
| page_title: "Github: github_enterprise_cost_center" | |
| page_title: "GitHub: github_enterprise_cost_center" |
| @@ -0,0 +1,36 @@ | |||
| --- | |||
| layout: "github" | |||
| page_title: "Github: github_enterprise_cost_centers" | |||
Copilot
AI
Dec 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The page_title should be "GitHub" (with capital "H") to match the standard capitalization used throughout the codebase.
| page_title: "Github: github_enterprise_cost_centers" | |
| page_title: "GitHub: github_enterprise_cost_centers" |
| @@ -0,0 +1,37 @@ | |||
| --- | |||
| layout: "github" | |||
| page_title: "Github: github_enterprise_cost_center" | |||
Copilot
AI
Dec 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The page_title should be "GitHub" (with capital "H") to match the standard capitalization used throughout the codebase.
| page_title: "Github: github_enterprise_cost_center" | |
| page_title: "GitHub: github_enterprise_cost_center" |
| if v, ok := d.GetOkExists(key); ok { | ||
| if set, ok := v.(*schema.Set); ok && set != nil && set.Len() > 0 { | ||
| return true | ||
| } | ||
| if !ok { | ||
| // Non-set values still indicate explicit configuration. | ||
| return true | ||
| } | ||
| } |
Copilot
AI
Dec 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deprecated GetOkExists method is used here. This method has been deprecated in favor of checking the schema's default value or using GetOk with additional logic. Consider refactoring to avoid using the deprecated method.
| if v, ok := d.GetOkExists(key); ok { | |
| if set, ok := v.(*schema.Set); ok && set != nil && set.Len() > 0 { | |
| return true | |
| } | |
| if !ok { | |
| // Non-set values still indicate explicit configuration. | |
| return true | |
| } | |
| } | |
| v := d.Get(key) | |
| if v == nil { | |
| continue | |
| } | |
| if set, ok := v.(*schema.Set); ok { | |
| if set != nil && set.Len() > 0 { | |
| return true | |
| } | |
| // Empty sets are treated as not configured. | |
| continue | |
| } | |
| // Non-set, non-nil values indicate explicit configuration. | |
| return true |
It is done, @deiga |
Resolves #2739
Before the change?
After the change?
NOTE: This API (billing) has no support for APP or fine-grained tokens.
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!