-
Notifications
You must be signed in to change notification settings - Fork 927
Open
Labels
Good first issueGood for newcomersGood for newcomersStatus: Up for grabsIssues that are ready to be worked on by anyoneIssues that are ready to be worked on by anyone
Description
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.Contextthroughout the SDK, enabling better request lifecycle management - Improved Error Handling: Migration to
diag.Diagnosticsallows returning multiple errors and warnings while associating them with specific fields
Related Issues
- [MAINT] Tracking issue for refactoring logging to use
tfloginstead oflog#3070 - [MAINT] Tracking issue for refactoring logging to usetflog- Should be paired with this work sincetflogrequirescontext.Context
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
-
resource_github_actions_environment_secret.go -
resource_github_actions_environment_variable.go -
resource_github_actions_hosted_runner.go -
resource_github_actions_organization_oidc_subject_claim_customization_template.go -
resource_github_actions_organization_permissions.go -
resource_github_actions_organization_secret.go -
resource_github_actions_organization_secret_repositories.go -
resource_github_actions_organization_secret_repository.go -
resource_github_actions_organization_variable.go -
resource_github_actions_repository_access_level.go -
resource_github_actions_repository_oidc_subject_claim_customization_template.go -
resource_github_actions_repository_permissions.go -
resource_github_actions_runner_group.go -
resource_github_actions_secret.go -
resource_github_actions_variable.go
App Installation
-
resource_github_app_installation_repositories.go -
resource_github_app_installation_repository.go
Branch
-
resource_github_branch.go -
resource_github_branch_default.go -
resource_github_branch_protection.go -
resource_github_branch_protection_v3.go
Codespaces
-
resource_github_codespaces_organization_secret.go -
resource_github_codespaces_organization_secret_repositories.go -
resource_github_codespaces_secret.go -
resource_github_codespaces_user_secret.go
Dependabot
-
resource_github_dependabot_organization_secret.go -
resource_github_dependabot_organization_secret_repositories.go -
resource_github_dependabot_secret.go
Enterprise
-
resource_github_enterprise_actions_permissions.go -
resource_github_enterprise_actions_runner_group.go -
resource_github_enterprise_actions_workflow_permissions.go -
resource_github_enterprise_organization.go -
resource_github_enterprise_security_analysis_settings.go
EMU
-
resource_github_emu_group_mapping.go
Issues
-
resource_github_issue.go -
resource_github_issue_label.go -
resource_github_issue_labels.go
Membership
-
resource_github_membership.go✅
Organization
-
resource_github_organization_custom_properties.go -
resource_github_organization_custom_role.go -
resource_github_organization_project.go -
resource_github_organization_repository_role.go✅ -
resource_github_organization_role.go✅ -
resource_github_organization_role_team.go✅ -
resource_github_organization_role_team_assignment.go -
resource_github_organization_role_user.go✅ -
resource_github_organization_ruleset.go✅ -
resource_github_organization_security_manager.go -
resource_github_organization_settings.go -
resource_github_organization_webhook.go -
resource_organization_block.go
Projects
-
resource_github_project_card.go -
resource_github_project_column.go
Release
-
resource_github_release.go
Repository
-
resource_github_repository.go✅ -
resource_github_repository_autolink_reference.go -
resource_github_repository_collaborator.go -
resource_github_repository_collaborators.go -
resource_github_repository_custom_property.go -
resource_github_repository_dependabot_security_updates.go -
resource_github_repository_deploy_key.go -
resource_github_repository_deployment_branch_policy.go -
resource_github_repository_environment.go -
resource_github_repository_environment_deployment_policy.go✅ -
resource_github_repository_file.go -
resource_github_repository_milestone.go -
resource_github_repository_project.go -
resource_github_repository_pull_request.go -
resource_github_repository_ruleset.go✅ -
resource_github_repository_topics.go -
resource_github_repository_webhook.go
Team
-
resource_github_team.go✅ -
resource_github_team_members.go -
resource_github_team_membership.go -
resource_github_team_repository.go -
resource_github_team_settings.go -
resource_github_team_sync_group_mapping.go
User
-
resource_github_user_gpg_key.go -
resource_github_user_invitation_accepter.go -
resource_github_user_ssh_key.go
Workflow
-
resource_github_workflow_repository_permissions.go
Data Sources (72 files)
Actions
-
data_source_github_actions_environment_public_key.go -
data_source_github_actions_environment_secrets.go -
data_source_github_actions_environment_variables.go -
data_source_github_actions_organization_oidc_subject_claim_customization_template.go -
data_source_github_actions_organization_public_key.go -
data_source_github_actions_organization_registration_token.go -
data_source_github_actions_organization_secrets.go -
data_source_github_actions_organization_variables.go -
data_source_github_actions_public_key.go -
data_source_github_actions_registration_token.go -
data_source_github_actions_repository_oidc_subject_claim_customization_template.go -
data_source_github_actions_secrets.go -
data_source_github_actions_variables.go
App
-
data_source_github_app.go -
data_source_github_app_token.go
Branch
-
data_source_github_branch.go -
data_source_github_branch_protection_rules.go
Codespaces
-
data_source_github_codespaces_organization_public_key.go -
data_source_github_codespaces_organization_secrets.go -
data_source_github_codespaces_public_key.go -
data_source_github_codespaces_secrets.go -
data_source_github_codespaces_user_public_key.go -
data_source_github_codespaces_user_secrets.go
Collaborators
-
data_source_github_collaborators.go
Dependabot
-
data_source_github_dependabot_organization_public_key.go -
data_source_github_dependabot_organization_secrets.go -
data_source_github_dependabot_public_key.go -
data_source_github_dependabot_secrets.go
Enterprise
-
data_source_github_enterprise.go
External Groups
-
data_source_github_external_groups.go
IP Ranges
-
data_source_github_ip_ranges.go
Issues
-
data_source_github_issue_labels.go
Membership
-
data_source_github_membership.go
Organization
-
data_source_github_organization.go -
data_source_github_organization_custom_properties.go -
data_source_github_organization_custom_role.go -
data_source_github_organization_external_identities.go -
data_source_github_organization_ip_allow_list.go -
data_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.go -
data_source_github_organization_team_sync_groups.go -
data_source_github_organization_teams.go -
data_source_github_organization_webhooks.go
Ref
-
data_source_github_ref.go
Release
-
data_source_github_release.go
Repository
-
data_source_github_repositories.go -
data_source_github_repository.go✅ -
data_source_github_repository_autolink_references.go -
data_source_github_repository_branches.go -
data_source_github_repository_custom_properties.go -
data_source_github_repository_deploy_keys.go -
data_source_github_repository_deployment_branch_policies.go -
data_source_github_repository_environment_deployment_policies.go✅ -
data_source_github_repository_environments.go -
data_source_github_repository_file.go✅ -
data_source_github_repository_milestone.go -
data_source_github_repository_pull_request.go -
data_source_github_repository_pull_requests.go -
data_source_github_repository_teams.go -
data_source_github_repository_webhooks.go
REST API
-
data_source_github_rest_api.go
SSH Keys
-
data_source_github_ssh_keys.go
Team
-
data_source_github_team.go✅
Tree
-
data_source_github_tree.go
User
-
data_source_github_user.go -
data_source_github_user_external_identity.go -
data_source_github_users.go
Suggested Approach
- Pair with tflog migration: When migrating a file, also convert logging to
tflog([MAINT] Tracking issue for refactoring logging to usetfloginstead oflog#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.Contextand returndiag.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
- Terraform Plugin SDK v2 Upgrade Guide - Context Support
- Example migrated files:
resource_github_membership.go,resource_github_team.go,data_source_github_repository_file.go
stevehipwell
Metadata
Metadata
Assignees
Labels
Good first issueGood for newcomersGood for newcomersStatus: Up for grabsIssues that are ready to be worked on by anyoneIssues that are ready to be worked on by anyone