Skip to content

Commit 97001ab

Browse files
ei-gradclaude
andcommitted
fix: Restore Optional on etag fields — required by SDK for DiffSuppressFunc
The terraform-plugin-sdk v2 InternalValidate rejects DiffSuppressFunc on Computed-only fields with: "There is no config for computed-only field, nothing to compare." Optional: true is required to use DiffSuppressFunc, as demonstrated by the new tests. Co-Authored-By: Claude <[email protected]>
1 parent df1d435 commit 97001ab

30 files changed

Lines changed: 34 additions & 1 deletion

github/resource_github_actions_runner_group.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ 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",
4748
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {

github/resource_github_branch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func resourceGithubBranch() *schema.Resource {
5050
},
5151
"etag": {
5252
Type: schema.TypeString,
53+
Optional: true,
5354
Computed: true,
5455
Description: "An etag representing the Branch object.",
5556
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {

github/resource_github_branch_default.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func resourceGithubBranchDefault() *schema.Resource {
4040
},
4141
"etag": {
4242
Type: schema.TypeString,
43+
Optional: true,
4344
Computed: true,
4445
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
4546
return true

github/resource_github_branch_protection_v3.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ func resourceGithubBranchProtectionV3() *schema.Resource {
213213
},
214214
"etag": {
215215
Type: schema.TypeString,
216+
Optional: true,
216217
Computed: true,
217218
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
218219
return true

github/resource_github_emu_group_mapping.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func resourceGithubEMUGroupMapping() *schema.Resource {
4646
},
4747
"etag": {
4848
Type: schema.TypeString,
49+
Optional: true,
4950
Computed: true,
5051
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
5152
return true

github/resource_github_enterprise_actions_runner_group.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ 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",
4849
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {

github/resource_github_etag_unit_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ func TestEtagSchemaConsistency(t *testing.T) {
168168
return
169169
}
170170

171-
// Verify etag is computed
171+
// Verify etag is optional+computed (Optional is required by the SDK
172+
// for DiffSuppressFunc, see TestEtagComputedOnlyRejectsSuppress)
173+
if !etagField.Optional {
174+
t.Errorf("etag should be optional in %s", resourceName)
175+
}
172176
if !etagField.Computed {
173177
t.Errorf("etag should be computed in %s", resourceName)
174178
}

github/resource_github_issue.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func resourceGithubIssue() *schema.Resource {
6969
},
7070
"etag": {
7171
Type: schema.TypeString,
72+
Optional: true,
7273
Computed: true,
7374
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
7475
return true

github/resource_github_issue_label.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func resourceGithubIssueLabel() *schema.Resource {
4949
},
5050
"etag": {
5151
Type: schema.TypeString,
52+
Optional: true,
5253
Computed: true,
5354
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
5455
return true

github/resource_github_membership.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func resourceGithubMembership() *schema.Resource {
3939
},
4040
"etag": {
4141
Type: schema.TypeString,
42+
Optional: true,
4243
Computed: true,
4344
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
4445
return true

0 commit comments

Comments
 (0)