Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions github/resource_github_actions_runner_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ func resourceGithubActionsRunnerGroup() *schema.Resource {
},
"etag": {
Type: schema.TypeString,
Optional: true,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: setting Optional makes them user editable, we don't want that. Please remove from all resources

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — removed Optional: true from all 29 etag fields (including the 7 from #2840 that also had it) and updated the unit test accordingly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though, this is covered in original PR:

Lastly these fields have to be marked as optional=true - [SDK ref](https://github.com/integrations/terraform-provider-github/blob/16872b724254fdddc3441c713b087cb4d7005f83/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/schema.go#L841)

Computed-only fields: Computed: true, Optional: false → Can't have DiffSuppressFunc
Optional computed fields: Computed: true, Optional: true → Can have DiffSuppressFunc

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added tests that confirm this SDK constraint. TestEtagComputedOnlyRejectsSuppress shows InternalValidate rejects DiffSuppressFunc on Computed-only fields with "There is no config for computed-only field, nothing to compare." TestEtagSchemaConsistency now also runs InternalValidate on all 29 resources to ensure they pass.

Restored Optional: true on all etag fields (including the ones from #2840 that I removed in the previous push).

Copy link
Copy Markdown
Author

@ei-grad ei-grad Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the standalone SDK validation tests — TestEtagSchemaConsistency now runs InternalValidate on its resources, which covers the same check.

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,
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_branch_protection_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_emu_group_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_enterprise_actions_runner_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 24 additions & 2 deletions github/resource_github_etag_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_organization_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_organization_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_organization_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_project_card.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_project_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_repository_autolink_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_repository_deploy_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_repository_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_team_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_team_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_team_sync_group_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_user_gpg_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_user_ssh_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions github/resource_organization_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down