diff --git a/github/resource_github_actions_runner_group.go b/github/resource_github_actions_runner_group.go index b24066d745..131a4b435a 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 0cba828b03..8c0d679eb1 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 e9d3ebe347..6b34c39525 100644 --- a/github/resource_github_emu_group_mapping.go +++ b/github/resource_github_emu_group_mapping.go @@ -47,7 +47,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: 2, diff --git a/github/resource_github_enterprise_actions_runner_group.go b/github/resource_github_enterprise_actions_runner_group.go index fa88980d53..d5da378c73 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 b573320008..598e6d77e9 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 46aafb9780..f3588b2594 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 53dc7d24ed..22ee4ff26d 100644 --- a/github/resource_github_organization_ruleset.go +++ b/github/resource_github_organization_ruleset.go @@ -749,8 +749,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 05ed873e71..c7fc0bc4dc 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 46b71fc269..21c5f36f69 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 f939405096..28aad410eb 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 056c6a4d33..15ed8ba05b 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 72e0e9ce10..25d5c51bfb 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 9b853494b0..ee79adf8c5 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 565a8a087a..aeea1c5f1c 100644 --- a/github/resource_github_team_membership.go +++ b/github/resource_github_team_membership.go @@ -59,7 +59,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 13f8efcc1c..5172c3917c 100644 --- a/github/resource_github_team_repository.go +++ b/github/resource_github_team_repository.go @@ -58,7 +58,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 7ee6c85733..ca4b9aee3e 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 80bb0faeb0..2841b54d27 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 a5d889eea9..b14167f52d 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 ed2ee9227b..d274ce1be8 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, }, }, }