diff --git a/github/resource_github_actions_runner_group.go b/github/resource_github_actions_runner_group.go index 394ff56a1c..c89f2c5b53 100644 --- a/github/resource_github_actions_runner_group.go +++ b/github/resource_github_actions_runner_group.go @@ -42,8 +42,13 @@ func resourceGithubActionsRunnerGroup() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, Description: "An etag representing the runner group object", + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, "inherited": { Type: schema.TypeBool, diff --git a/github/resource_github_branch_protection_v3.go b/github/resource_github_branch_protection_v3.go index e238def1fd..1076aedd2e 100644 --- a/github/resource_github_branch_protection_v3.go +++ b/github/resource_github_branch_protection_v3.go @@ -213,7 +213,12 @@ func resourceGithubBranchProtectionV3() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_emu_group_mapping.go b/github/resource_github_emu_group_mapping.go index 244ea3348a..7fc5f03a4f 100644 --- a/github/resource_github_emu_group_mapping.go +++ b/github/resource_github_emu_group_mapping.go @@ -46,7 +46,12 @@ func resourceGithubEMUGroupMapping() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, SchemaVersion: 1, diff --git a/github/resource_github_enterprise_actions_runner_group.go b/github/resource_github_enterprise_actions_runner_group.go index c37ebd8bef..e23b0ca011 100644 --- a/github/resource_github_enterprise_actions_runner_group.go +++ b/github/resource_github_enterprise_actions_runner_group.go @@ -43,8 +43,13 @@ func resourceGithubActionsEnterpriseRunnerGroup() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, Description: "An etag representing the runner group object", + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, "name": { Type: schema.TypeString, diff --git a/github/resource_github_etag_unit_test.go b/github/resource_github_etag_unit_test.go index 267f40f485..ba3c50e162 100644 --- a/github/resource_github_etag_unit_test.go +++ b/github/resource_github_etag_unit_test.go @@ -74,13 +74,35 @@ func TestEtagDiffSuppressFunction(t *testing.T) { // TestEtagSchemaConsistency ensure DiffSuppressFunc and DiffSuppressOnRefresh are consistently applied. func TestEtagSchemaConsistency(t *testing.T) { resourcesWithEtag := map[string]*schema.Resource{ - "github_repository": resourceGithubRepository(), + "github_actions_runner_group": resourceGithubActionsRunnerGroup(), "github_branch": resourceGithubBranch(), "github_branch_default": resourceGithubBranchDefault(), + "github_branch_protection_v3": resourceGithubBranchProtectionV3(), + "github_emu_group_mapping": resourceGithubEMUGroupMapping(), + "github_enterprise_actions_runner_group": resourceGithubActionsEnterpriseRunnerGroup(), + "github_issue": resourceGithubIssue(), "github_issue_label": resourceGithubIssueLabel(), - "github_repository_webhook": resourceGithubRepositoryWebhook(), + "github_membership": resourceGithubMembership(), + "github_organization_project": resourceGithubOrganizationProject(), + "github_organization_ruleset": resourceGithubOrganizationRuleset(), + "github_organization_webhook": resourceGithubOrganizationWebhook(), + "github_project_card": resourceGithubProjectCard(), + "github_project_column": resourceGithubProjectColumn(), + "github_release": resourceGithubRelease(), + "github_repository": resourceGithubRepository(), + "github_repository_autolink_reference": resourceGithubRepositoryAutolinkReference(), + "github_repository_deploy_key": resourceGithubRepositoryDeployKey(), "github_repository_deployment_branch_policy": resourceGithubRepositoryDeploymentBranchPolicy(), "github_repository_project": resourceGithubRepositoryProject(), + "github_repository_ruleset": resourceGithubRepositoryRuleset(), + "github_repository_webhook": resourceGithubRepositoryWebhook(), + "github_team": resourceGithubTeam(), + "github_team_membership": resourceGithubTeamMembership(), + "github_team_repository": resourceGithubTeamRepository(), + "github_team_sync_group_mapping": resourceGithubTeamSyncGroupMapping(), + "github_user_gpg_key": resourceGithubUserGpgKey(), + "github_user_ssh_key": resourceGithubUserSshKey(), + "organization_block": resourceOrganizationBlock(), } for resourceName, resource := range resourcesWithEtag { @@ -91,7 +113,8 @@ func TestEtagSchemaConsistency(t *testing.T) { return } - // Verify etag is optional and computed + // Verify etag is optional+computed (Optional is required by the SDK + // for DiffSuppressFunc, see TestEtagComputedOnlyRejectsSuppress) if !etagField.Optional { t.Errorf("etag should be optional in %s", resourceName) } @@ -117,6 +140,16 @@ func TestEtagSchemaConsistency(t *testing.T) { t.Errorf("DiffSuppressFunc should return true in %s", resourceName) } } + + // Verify the schema passes SDK internal validation + p := &schema.Provider{ + ResourcesMap: map[string]*schema.Resource{ + resourceName: resource, + }, + } + if err := p.InternalValidate(); err != nil { + t.Errorf("SDK validation failed for %s: %s", resourceName, err) + } }) } } diff --git a/github/resource_github_issue.go b/github/resource_github_issue.go index 3588c81c6d..c09c436555 100644 --- a/github/resource_github_issue.go +++ b/github/resource_github_issue.go @@ -69,7 +69,12 @@ func resourceGithubIssue() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_membership.go b/github/resource_github_membership.go index d1ddfacab2..72dc400ebd 100644 --- a/github/resource_github_membership.go +++ b/github/resource_github_membership.go @@ -39,7 +39,12 @@ func resourceGithubMembership() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, "downgrade_on_destroy": { Type: schema.TypeBool, diff --git a/github/resource_github_organization_project.go b/github/resource_github_organization_project.go index 005bc0a181..3edf01df06 100644 --- a/github/resource_github_organization_project.go +++ b/github/resource_github_organization_project.go @@ -36,7 +36,12 @@ func resourceGithubOrganizationProject() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_organization_ruleset.go b/github/resource_github_organization_ruleset.go index 8624250883..b7c06d3d49 100644 --- a/github/resource_github_organization_ruleset.go +++ b/github/resource_github_organization_ruleset.go @@ -675,8 +675,13 @@ func resourceGithubOrganizationRuleset() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, Description: "An etag representing the ruleset for caching purposes.", + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_organization_webhook.go b/github/resource_github_organization_webhook.go index 62c9a8926f..8ef38a929e 100644 --- a/github/resource_github_organization_webhook.go +++ b/github/resource_github_organization_webhook.go @@ -53,7 +53,12 @@ func resourceGithubOrganizationWebhook() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_project_card.go b/github/resource_github_project_card.go index 5e746dbe50..22445433b7 100644 --- a/github/resource_github_project_card.go +++ b/github/resource_github_project_card.go @@ -41,7 +41,12 @@ func resourceGithubProjectCard() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, "card_id": { Type: schema.TypeInt, diff --git a/github/resource_github_project_column.go b/github/resource_github_project_column.go index 830a6bb349..981a4e019e 100644 --- a/github/resource_github_project_column.go +++ b/github/resource_github_project_column.go @@ -37,7 +37,12 @@ func resourceGithubProjectColumn() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_release.go b/github/resource_github_release.go index 98949c9cd0..bf43ae7c3a 100644 --- a/github/resource_github_release.go +++ b/github/resource_github_release.go @@ -82,7 +82,12 @@ func resourceGithubRelease() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, "release_id": { Type: schema.TypeInt, diff --git a/github/resource_github_repository_autolink_reference.go b/github/resource_github_repository_autolink_reference.go index 9ee8c90eee..4e0329189a 100644 --- a/github/resource_github_repository_autolink_reference.go +++ b/github/resource_github_repository_autolink_reference.go @@ -86,7 +86,12 @@ func resourceGithubRepositoryAutolinkReference() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_repository_deploy_key.go b/github/resource_github_repository_deploy_key.go index 9cd12c2836..4067fdc95c 100644 --- a/github/resource_github_repository_deploy_key.go +++ b/github/resource_github_repository_deploy_key.go @@ -52,7 +52,12 @@ func resourceGithubRepositoryDeployKey() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_repository_ruleset.go b/github/resource_github_repository_ruleset.go index 460473e857..3a2c9b05d7 100644 --- a/github/resource_github_repository_ruleset.go +++ b/github/resource_github_repository_ruleset.go @@ -678,7 +678,12 @@ func resourceGithubRepositoryRuleset() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_team.go b/github/resource_github_team.go index 6f823e730d..be234f9211 100644 --- a/github/resource_github_team.go +++ b/github/resource_github_team.go @@ -106,7 +106,12 @@ func resourceGithubTeam() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_team_membership.go b/github/resource_github_team_membership.go index e0a296e657..2b5c4296c9 100644 --- a/github/resource_github_team_membership.go +++ b/github/resource_github_team_membership.go @@ -57,7 +57,12 @@ func resourceGithubTeamMembership() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_team_repository.go b/github/resource_github_team_repository.go index fa912b7de4..e2bc7bc71f 100644 --- a/github/resource_github_team_repository.go +++ b/github/resource_github_team_repository.go @@ -56,7 +56,12 @@ func resourceGithubTeamRepository() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_team_sync_group_mapping.go b/github/resource_github_team_sync_group_mapping.go index 53d7363bf3..fda9e23a20 100644 --- a/github/resource_github_team_sync_group_mapping.go +++ b/github/resource_github_team_sync_group_mapping.go @@ -60,7 +60,12 @@ func resourceGithubTeamSyncGroupMapping() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_user_gpg_key.go b/github/resource_github_user_gpg_key.go index cc6c2d21b8..9e255d0f24 100644 --- a/github/resource_github_user_gpg_key.go +++ b/github/resource_github_user_gpg_key.go @@ -31,7 +31,12 @@ func resourceGithubUserGpgKey() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_github_user_ssh_key.go b/github/resource_github_user_ssh_key.go index 681a68220f..ec727b7551 100644 --- a/github/resource_github_user_ssh_key.go +++ b/github/resource_github_user_ssh_key.go @@ -45,7 +45,12 @@ func resourceGithubUserSshKey() *schema.Resource { }, "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, } diff --git a/github/resource_organization_block.go b/github/resource_organization_block.go index 013e49d1dc..137296aa7d 100644 --- a/github/resource_organization_block.go +++ b/github/resource_organization_block.go @@ -29,7 +29,12 @@ func resourceOrganizationBlock() *schema.Resource { "etag": { Type: schema.TypeString, + Optional: true, Computed: true, + DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { + return true + }, + DiffSuppressOnRefresh: true, }, }, }