Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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,
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
39 changes: 36 additions & 3 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 All @@ -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)
}
Expand All @@ -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 {
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.

question: this is meant for provider validation and not resource, what is the benefit of adding it?

t.Errorf("SDK validation failed for %s: %s", resourceName, err)
}
})
}
}
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