Skip to content

Commit 23a52ec

Browse files
ei-gradclaude
andcommitted
fix: Add DiffSuppressFunc and DiffSuppressOnRefresh to remaining etag fields
PR #2840 added etag diff suppression to 7 resources but missed the remaining 22. This causes spurious diffs on every plan/apply for resources like github_team, github_membership, github_team_repository, github_repository_deploy_key, and others. Apply the same pattern (Optional + DiffSuppressFunc returning true + DiffSuppressOnRefresh) to all remaining resource etag schema fields and extend the unit test to cover all 29 resources. Fixes #3103 Fixes #3291 Co-Authored-By: Claude <[email protected]>
1 parent 256cdd8 commit 23a52ec

23 files changed

Lines changed: 134 additions & 2 deletions

github/resource_github_actions_runner_group.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@ func resourceGithubActionsRunnerGroup() *schema.Resource {
4242
},
4343
"etag": {
4444
Type: schema.TypeString,
45+
Optional: true,
4546
Computed: true,
4647
Description: "An etag representing the runner group object",
48+
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
49+
return true
50+
},
51+
DiffSuppressOnRefresh: true,
4752
},
4853
"inherited": {
4954
Type: schema.TypeBool,

github/resource_github_branch_protection_v3.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ func resourceGithubBranchProtectionV3() *schema.Resource {
213213
},
214214
"etag": {
215215
Type: schema.TypeString,
216+
Optional: true,
216217
Computed: true,
218+
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
219+
return true
220+
},
221+
DiffSuppressOnRefresh: true,
217222
},
218223
},
219224
}

github/resource_github_emu_group_mapping.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ func resourceGithubEMUGroupMapping() *schema.Resource {
4646
},
4747
"etag": {
4848
Type: schema.TypeString,
49+
Optional: true,
4950
Computed: true,
51+
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
52+
return true
53+
},
54+
DiffSuppressOnRefresh: true,
5055
},
5156
},
5257
SchemaVersion: 1,

github/resource_github_enterprise_actions_runner_group.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ func resourceGithubActionsEnterpriseRunnerGroup() *schema.Resource {
4343
},
4444
"etag": {
4545
Type: schema.TypeString,
46+
Optional: true,
4647
Computed: true,
4748
Description: "An etag representing the runner group object",
49+
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
50+
return true
51+
},
52+
DiffSuppressOnRefresh: true,
4853
},
4954
"name": {
5055
Type: schema.TypeString,

github/resource_github_etag_unit_test.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,35 @@ func TestEtagDiffSuppressFunction(t *testing.T) {
7474
// TestEtagSchemaConsistency ensure DiffSuppressFunc and DiffSuppressOnRefresh are consistently applied.
7575
func TestEtagSchemaConsistency(t *testing.T) {
7676
resourcesWithEtag := map[string]*schema.Resource{
77-
"github_repository": resourceGithubRepository(),
77+
"github_actions_runner_group": resourceGithubActionsRunnerGroup(),
7878
"github_branch": resourceGithubBranch(),
7979
"github_branch_default": resourceGithubBranchDefault(),
80+
"github_branch_protection_v3": resourceGithubBranchProtectionV3(),
81+
"github_emu_group_mapping": resourceGithubEMUGroupMapping(),
82+
"github_enterprise_actions_runner_group": resourceGithubActionsEnterpriseRunnerGroup(),
83+
"github_issue": resourceGithubIssue(),
8084
"github_issue_label": resourceGithubIssueLabel(),
81-
"github_repository_webhook": resourceGithubRepositoryWebhook(),
85+
"github_membership": resourceGithubMembership(),
86+
"github_organization_project": resourceGithubOrganizationProject(),
87+
"github_organization_ruleset": resourceGithubOrganizationRuleset(),
88+
"github_organization_webhook": resourceGithubOrganizationWebhook(),
89+
"github_project_card": resourceGithubProjectCard(),
90+
"github_project_column": resourceGithubProjectColumn(),
91+
"github_release": resourceGithubRelease(),
92+
"github_repository": resourceGithubRepository(),
93+
"github_repository_autolink_reference": resourceGithubRepositoryAutolinkReference(),
94+
"github_repository_deploy_key": resourceGithubRepositoryDeployKey(),
8295
"github_repository_deployment_branch_policy": resourceGithubRepositoryDeploymentBranchPolicy(),
8396
"github_repository_project": resourceGithubRepositoryProject(),
97+
"github_repository_ruleset": resourceGithubRepositoryRuleset(),
98+
"github_repository_webhook": resourceGithubRepositoryWebhook(),
99+
"github_team": resourceGithubTeam(),
100+
"github_team_membership": resourceGithubTeamMembership(),
101+
"github_team_repository": resourceGithubTeamRepository(),
102+
"github_team_sync_group_mapping": resourceGithubTeamSyncGroupMapping(),
103+
"github_user_gpg_key": resourceGithubUserGpgKey(),
104+
"github_user_ssh_key": resourceGithubUserSshKey(),
105+
"organization_block": resourceOrganizationBlock(),
84106
}
85107

86108
for resourceName, resource := range resourcesWithEtag {

github/resource_github_issue.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ func resourceGithubIssue() *schema.Resource {
6969
},
7070
"etag": {
7171
Type: schema.TypeString,
72+
Optional: true,
7273
Computed: true,
74+
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
75+
return true
76+
},
77+
DiffSuppressOnRefresh: true,
7378
},
7479
},
7580
}

github/resource_github_membership.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ func resourceGithubMembership() *schema.Resource {
3939
},
4040
"etag": {
4141
Type: schema.TypeString,
42+
Optional: true,
4243
Computed: true,
44+
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
45+
return true
46+
},
47+
DiffSuppressOnRefresh: true,
4348
},
4449
"downgrade_on_destroy": {
4550
Type: schema.TypeBool,

github/resource_github_organization_project.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ func resourceGithubOrganizationProject() *schema.Resource {
3636
},
3737
"etag": {
3838
Type: schema.TypeString,
39+
Optional: true,
3940
Computed: true,
41+
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
42+
return true
43+
},
44+
DiffSuppressOnRefresh: true,
4045
},
4146
},
4247
}

github/resource_github_organization_ruleset.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,13 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
675675
},
676676
"etag": {
677677
Type: schema.TypeString,
678+
Optional: true,
678679
Computed: true,
679680
Description: "An etag representing the ruleset for caching purposes.",
681+
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
682+
return true
683+
},
684+
DiffSuppressOnRefresh: true,
680685
},
681686
},
682687
}

github/resource_github_organization_webhook.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ func resourceGithubOrganizationWebhook() *schema.Resource {
5353
},
5454
"etag": {
5555
Type: schema.TypeString,
56+
Optional: true,
5657
Computed: true,
58+
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
59+
return true
60+
},
61+
DiffSuppressOnRefresh: true,
5762
},
5863
},
5964
}

0 commit comments

Comments
 (0)