Summary
This issue tracks the migration of all resources and data sources from legacy CRUD functions (Create, Read, Update, Delete) to Context-aware CRUD functions (CreateContext, ReadContext, UpdateContext, DeleteContext).
Why This Migration Is Needed
Per the Terraform Plugin SDK v2 Upgrade Guide :
Deprecation : The legacy CRUD function types (CreateFunc, ReadFunc, UpdateFunc, DeleteFunc) are deprecated in favor of their context-aware counterparts
Reliable Timeouts & Cancellation : Context-aware functions plumb context.Context throughout the SDK, enabling better request lifecycle management
Improved Error Handling : Migration to diag.Diagnostics allows returning multiple errors and warnings while associating them with specific fields
Related Issues
Migration Pattern
Before (Legacy)
func resourceGithubExample () * schema.Resource {
return & schema.Resource {
Create : resourceGithubExampleCreate ,
Read : resourceGithubExampleRead ,
Update : resourceGithubExampleUpdate ,
Delete : resourceGithubExampleDelete ,
// ...
}
}
func resourceGithubExampleCreate (d * schema.ResourceData , meta interface {}) error {
// ...
return nil
}
After (Context-Aware)
func resourceGithubExample () * schema.Resource {
return & schema.Resource {
CreateContext : resourceGithubExampleCreate ,
ReadContext : resourceGithubExampleRead ,
UpdateContext : resourceGithubExampleUpdate ,
DeleteContext : resourceGithubExampleDelete ,
// ...
}
}
func resourceGithubExampleCreate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
// Use ctx in API calls for proper cancellation support
// ...
return nil
}
Current Status
Total files : 153
Already migrated : 20
Remaining : 133
Migration Checklist
Resources (85 files)
Actions
App Installation
Branch
Codespaces
Dependabot
Enterprise
EMU
Issues
Membership
Organization
Projects
Release
Repository
Team
User
Workflow
Data Sources (72 files)
Actions
App
Branch
Codespaces
Collaborators
Dependabot
Enterprise
External Groups
IP Ranges
Issues
Membership
Organization
Ref
Release
Repository
REST API
SSH Keys
Team
Tree
User
Suggested Approach
Pair with tflog migration : When migrating a file, also convert logging to tflog ([MAINT] Tracking issue for refactoring logging to use tflog instead of log #3070 )
Batch by domain : Group related resources/data sources and migrate them together
Reference existing migrations : Use already-migrated files as reference implementations
Update function signatures : Change CRUD function signatures to include ctx context.Context and return diag.Diagnostics
Pass context to API calls : Update go-github client calls to use the context parameter
Test thoroughly : Ensure acceptance tests pass after each batch migration
References
Summary
This issue tracks the migration of all resources and data sources from legacy CRUD functions (
Create,Read,Update,Delete) to Context-aware CRUD functions (CreateContext,ReadContext,UpdateContext,DeleteContext).Why This Migration Is Needed
Per the Terraform Plugin SDK v2 Upgrade Guide:
CreateFunc,ReadFunc,UpdateFunc,DeleteFunc) are deprecated in favor of their context-aware counterpartscontext.Contextthroughout the SDK, enabling better request lifecycle managementdiag.Diagnosticsallows returning multiple errors and warnings while associating them with specific fieldsRelated Issues
tfloginstead oflog#3070 - [MAINT] Tracking issue for refactoring logging to usetflog- Should be paired with this work sincetflogrequirescontext.ContextMigration Pattern
Before (Legacy)
After (Context-Aware)
Current Status
Migration Checklist
Resources (85 files)
Actions
resource_github_actions_environment_secret.goresource_github_actions_environment_variable.goresource_github_actions_hosted_runner.goresource_github_actions_organization_oidc_subject_claim_customization_template.goresource_github_actions_organization_permissions.goresource_github_actions_organization_secret.goresource_github_actions_organization_secret_repositories.goresource_github_actions_organization_secret_repository.goresource_github_actions_organization_variable.goresource_github_actions_repository_access_level.goresource_github_actions_repository_oidc_subject_claim_customization_template.goresource_github_actions_repository_permissions.goresource_github_actions_runner_group.goresource_github_actions_secret.goresource_github_actions_variable.goApp Installation
resource_github_app_installation_repositories.goresource_github_app_installation_repository.goBranch
resource_github_branch.goresource_github_branch_default.goresource_github_branch_protection.goresource_github_branch_protection_v3.goCodespaces
resource_github_codespaces_organization_secret.goresource_github_codespaces_organization_secret_repositories.goresource_github_codespaces_secret.goresource_github_codespaces_user_secret.goDependabot
resource_github_dependabot_organization_secret.goresource_github_dependabot_organization_secret_repositories.goresource_github_dependabot_secret.goEnterprise
resource_github_enterprise_actions_permissions.goresource_github_enterprise_actions_runner_group.goresource_github_enterprise_actions_workflow_permissions.goresource_github_enterprise_organization.goresource_github_enterprise_security_analysis_settings.goEMU
resource_github_emu_group_mapping.goIssues
resource_github_issue.goresource_github_issue_label.goresource_github_issue_labels.goMembership
resource_github_membership.go✅Organization
resource_github_organization_custom_properties.goresource_github_organization_custom_role.goresource_github_organization_project.goresource_github_organization_repository_role.go✅resource_github_organization_role.go✅resource_github_organization_role_team.go✅resource_github_organization_role_team_assignment.goresource_github_organization_role_user.go✅resource_github_organization_ruleset.go✅resource_github_organization_security_manager.goresource_github_organization_settings.goresource_github_organization_webhook.goresource_organization_block.goProjects
resource_github_project_card.goresource_github_project_column.goRelease
resource_github_release.goRepository
resource_github_repository.go✅resource_github_repository_autolink_reference.goresource_github_repository_collaborator.goresource_github_repository_collaborators.goresource_github_repository_custom_property.goresource_github_repository_dependabot_security_updates.goresource_github_repository_deploy_key.goresource_github_repository_deployment_branch_policy.goresource_github_repository_environment.goresource_github_repository_environment_deployment_policy.go✅resource_github_repository_file.goresource_github_repository_milestone.goresource_github_repository_project.goresource_github_repository_pull_request.goresource_github_repository_ruleset.go✅resource_github_repository_topics.goresource_github_repository_webhook.goTeam
resource_github_team.go✅resource_github_team_members.goresource_github_team_membership.goresource_github_team_repository.goresource_github_team_settings.goresource_github_team_sync_group_mapping.goUser
resource_github_user_gpg_key.goresource_github_user_invitation_accepter.goresource_github_user_ssh_key.goWorkflow
resource_github_workflow_repository_permissions.goData Sources (72 files)
Actions
data_source_github_actions_environment_public_key.godata_source_github_actions_environment_secrets.godata_source_github_actions_environment_variables.godata_source_github_actions_organization_oidc_subject_claim_customization_template.godata_source_github_actions_organization_public_key.godata_source_github_actions_organization_registration_token.godata_source_github_actions_organization_secrets.godata_source_github_actions_organization_variables.godata_source_github_actions_public_key.godata_source_github_actions_registration_token.godata_source_github_actions_repository_oidc_subject_claim_customization_template.godata_source_github_actions_secrets.godata_source_github_actions_variables.goApp
data_source_github_app.godata_source_github_app_token.goBranch
data_source_github_branch.godata_source_github_branch_protection_rules.goCodespaces
data_source_github_codespaces_organization_public_key.godata_source_github_codespaces_organization_secrets.godata_source_github_codespaces_public_key.godata_source_github_codespaces_secrets.godata_source_github_codespaces_user_public_key.godata_source_github_codespaces_user_secrets.goCollaborators
data_source_github_collaborators.goDependabot
data_source_github_dependabot_organization_public_key.godata_source_github_dependabot_organization_secrets.godata_source_github_dependabot_public_key.godata_source_github_dependabot_secrets.goEnterprise
data_source_github_enterprise.goExternal Groups
data_source_github_external_groups.goIP Ranges
data_source_github_ip_ranges.goIssues
data_source_github_issue_labels.goMembership
data_source_github_membership.goOrganization
data_source_github_organization.godata_source_github_organization_custom_properties.godata_source_github_organization_custom_role.godata_source_github_organization_external_identities.godata_source_github_organization_ip_allow_list.godata_source_github_organization_repository_role.go✅data_source_github_organization_repository_roles.go✅data_source_github_organization_role.go✅data_source_github_organization_role_teams.go✅data_source_github_organization_role_users.go✅data_source_github_organization_roles.go✅data_source_github_organization_security_managers.godata_source_github_organization_team_sync_groups.godata_source_github_organization_teams.godata_source_github_organization_webhooks.goRef
data_source_github_ref.goRelease
data_source_github_release.goRepository
data_source_github_repositories.godata_source_github_repository.go✅data_source_github_repository_autolink_references.godata_source_github_repository_branches.godata_source_github_repository_custom_properties.godata_source_github_repository_deploy_keys.godata_source_github_repository_deployment_branch_policies.godata_source_github_repository_environment_deployment_policies.go✅data_source_github_repository_environments.godata_source_github_repository_file.go✅data_source_github_repository_milestone.godata_source_github_repository_pull_request.godata_source_github_repository_pull_requests.godata_source_github_repository_teams.godata_source_github_repository_webhooks.goREST API
data_source_github_rest_api.goSSH Keys
data_source_github_ssh_keys.goTeam
data_source_github_team.go✅Tree
data_source_github_tree.goUser
data_source_github_user.godata_source_github_user_external_identity.godata_source_github_users.goSuggested Approach
tflog([MAINT] Tracking issue for refactoring logging to usetfloginstead oflog#3070)ctx context.Contextand returndiag.DiagnosticsReferences
resource_github_membership.go,resource_github_team.go,data_source_github_repository_file.go