Skip to content

Conversation

@vmvarela
Copy link
Owner

Apply code review feedback from @deiga on enterprise teams resources:

Changes

  • Remove Read-after-Create/Update pattern in all enterprise team resources, setting computed fields directly from API response instead
  • Remove unnecessary re-discovery of team slug in Update (always available from Read)
  • Remove meaningless _ = resp assignment in Delete
  • Eliminate redundant testCase wrapper pattern in acceptance tests
  • Separate enterprise_team field into team_slug and team_id with ExactlyOneOf validation for membership and organizations resources
  • Move shared helper functions to util_enterprise_teams.go:
    • findEnterpriseTeamBySlugOrID
    • listAllEnterpriseTeamOrganizations
  • Use "/" as ID separator instead of ":" because enterprise team slugs contain ":" (e.g., ent:team-name)
  • Use state data in Delete instead of API call for organizations resource
  • Update documentation with new schema

Testing

All 7 acceptance tests pass:

  • TestAccGithubEnterpriseTeam
  • TestAccGithubEnterpriseTeamOrganizations
  • TestAccGithubEnterpriseTeamMembership
  • TestAccGithubEnterpriseTeamDataSource
  • TestAccGithubEnterpriseTeamsDataSource
  • TestAccGithubEnterpriseTeamOrganizationsDataSource
  • TestAccGithubEnterpriseTeamMembershipDataSource

Apply code review feedback from @deiga on enterprise teams resources:

- Remove Read-after-Create/Update pattern in all enterprise team resources,
  setting computed fields directly from API response instead
- Remove unnecessary re-discovery of team slug in Update (always available from Read)
- Remove meaningless `_ = resp` assignment in Delete
- Eliminate redundant `testCase` wrapper pattern in acceptance tests
- Separate `enterprise_team` field into `team_slug` and `team_id` with
  ExactlyOneOf validation for membership and organizations resources
- Move shared helper functions to util_enterprise_teams.go:
  - findEnterpriseTeamBySlugOrID
  - listAllEnterpriseTeamOrganizations
- Use "/" as ID separator instead of ":" because enterprise team slugs
  contain ":" (e.g., "ent:team-name")
- Use state data in Delete instead of API call for organizations resource
- Update documentation with new schema
Copilot AI review requested due to automatic review settings January 10, 2026 09:18
Copy link

Copilot AI left a 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 refactoring PR addresses code review feedback for enterprise team resources by removing the Read-after-Create/Update pattern, eliminating redundant code, improving schema validation with separate team_slug and team_id fields, and consolidating shared utilities.

Changes:

  • Removed Read-after-Create/Update calls across all enterprise team resources, setting computed fields directly from API responses instead
  • Split the enterprise_team field into separate team_slug and team_id fields with ExactlyOneOf validation for membership and organizations resources
  • Moved shared helper functions to util_enterprise_teams.go and changed ID separator from ":" to "/" to avoid conflicts with team slug format
  • Simplified test structure by removing redundant wrapper patterns and updated documentation to reflect new schema

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
github/util_enterprise_teams.go Added ID building/parsing functions and moved shared helper functions (findEnterpriseTeamBySlugOrID, listAllEnterpriseTeamOrganizations)
github/resource_github_enterprise_team.go Removed Read-after-Create/Update, removed re-discovery logic in Update, removed meaningless assignment in Delete
github/resource_github_enterprise_team_organizations.go Split enterprise_team into team_slug/team_id, removed Read-after-Create/Update, used state data in Delete
github/resource_github_enterprise_team_membership.go Split enterprise_team into team_slug/team_id, removed Read-after-Create, set computed fields from API response
github/resource_github_enterprise_team_test.go Removed redundant testCase wrapper pattern, updated field references from enterprise_team to team_slug
github/data_source_github_enterprise_team_test.go Updated field references from enterprise_team to team_slug, fixed formatting
github/data_source_github_enterprise_teams_test.go Fixed PreCheck formatting for consistency
github/data_source_github_enterprise_team.go Removed findEnterpriseTeamBySlugOrID (moved to util file), removed unused import
github/data_source_github_enterprise_team_organizations.go Removed listAllEnterpriseTeamOrganizations (moved to util file), removed unused import
website/docs/r/enterprise_team_organizations.html.markdown Updated documentation to reflect new team_slug/team_id schema
website/docs/r/enterprise_team_membership.html.markdown Updated documentation to reflect new team_slug/team_id schema

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Fix team_slug drift: only set team_slug in Create when user originally
  provided it, not when using team_id
- Remove dead code: delete unused findEnterpriseTeamBySlugOrID function
- Document separator safety: add note that GitHub slugs cannot contain '/'
- Add MinItems validation test for organization_slugs
@github-actions github-actions bot added the Type: Documentation Improvements or additions to documentation label Jan 10, 2026
@vmvarela vmvarela requested a review from Copilot January 10, 2026 09:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- In Create: set team_id in state when user provides it (not just team_slug)
- In Read: only set team_slug if it was configured or during import
- This prevents drift when users configure team_id instead of team_slug
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Use team.ID from API response instead of user input value when setting
team_id in state. This ensures consistency with how team_slug is handled.
- Fix ExactlyOneOf in data_source_github_enterprise_team: must include
  the field itself (slug) in the list, add validation for slug field
- Add 404 handling in Delete for membership and organizations resources
  to gracefully handle already-deleted resources
- Handle error in Import function instead of discarding with _ =
- Fix group_id: now always sent in Create/Update requests, allowing
  empty string to clear the IdP group association
- Align data source naming with resources: enterprise_team -> team_slug
  in data_source_github_enterprise_team_membership and
  data_source_github_enterprise_team_organizations
- Update documentation for renamed fields
- Use consistent ID functions across data sources
@vmvarela vmvarela added Type: Feature New feature or request and removed Type: Bug labels Jan 10, 2026
@vmvarela vmvarela merged commit e4ba19e into develop Jan 10, 2026
1 check passed
@vmvarela vmvarela deleted the fix/pr-enterprise-teams branch January 10, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Documentation Improvements or additions to documentation Type: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants