diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 926202b13a..0bdd194767 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,5 @@ jobs: go-version-file: go.mod cache: true - run: make tools - - run: make lintcheck - - run: make website-lint - run: make build - run: make test diff --git a/.golangci.yml b/.golangci.yml index 10890c6c1a..900dce093b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,8 @@ version: "2" +run: + allow-serial-runners: true + linters: default: none diff --git a/GNUmakefile b/GNUmakefile index 4d39de3b47..0409d0b9ed 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -28,8 +28,7 @@ endif default: build tools: - go install github.com/client9/misspell/cmd/misspell@v0.3.4 - go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.10.1 build: lintcheck CGO_ENABLED=0 go build -ldflags="-s -w" ./... @@ -73,10 +72,6 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) endif @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) -website-lint: - @echo "==> Checking website against linters..." - @misspell -error -source=text website/ - website-test: ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." @@ -84,4 +79,4 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) endif @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) -.PHONY: build test testacc fmt lint lintcheck tools website website-lint website-test sweep +.PHONY: build test testacc fmt lint lintcheck tools website website-test sweep diff --git a/README.md b/README.md index 197c6a6bf0..89edaa3fd5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Terraform Provider GitHub +# Terraform Provider GitHub ========================= @@ -9,8 +9,8 @@ This project is used to manipulate GitHub resources (repositories, teams, files, ## Requirements -- [Terraform](https://www.terraform.io/downloads.html) 0.10.x -- [Go](https://golang.org/doc/install) 1.24.x (to build the provider plugin) +- [Terraform](https://www.terraform.io/downloads.html) 1.14.x +- [Go](https://golang.org/doc/install) 1.26.x (to build the provider plugin) ## Usage diff --git a/github/data_source_github_branch_protection_rules.go b/github/data_source_github_branch_protection_rules.go index 1ffcfa8588..c7e3aff22d 100644 --- a/github/data_source_github_branch_protection_rules.go +++ b/github/data_source_github_branch_protection_rules.go @@ -74,7 +74,7 @@ func dataSourceGithubBranchProtectionRulesRead(ctx context.Context, d *schema.Re if !query.Repository.BranchProtectionRules.PageInfo.HasNextPage { break } - variables["cursor"] = githubv4.NewString(query.Repository.BranchProtectionRules.PageInfo.EndCursor) + variables["cursor"] = new(query.Repository.BranchProtectionRules.PageInfo.EndCursor) } d.SetId(string(query.Repository.ID)) diff --git a/github/data_source_github_organization.go b/github/data_source_github_organization.go index fd705e786b..ede1ac9e6b 100644 --- a/github/data_source_github_organization.go +++ b/github/data_source_github_organization.go @@ -241,7 +241,7 @@ func dataSourceGithubOrganizationRead(ctx context.Context, d *schema.ResourceDat if !query.Organization.MembersWithRole.PageInfo.HasNextPage { break } - variables["after"] = githubv4.NewString(query.Organization.MembersWithRole.PageInfo.EndCursor) + variables["after"] = new(query.Organization.MembersWithRole.PageInfo.EndCursor) } _ = d.Set("repositories", repoList) diff --git a/github/data_source_github_organization_external_identities.go b/github/data_source_github_organization_external_identities.go index 1eff583cd6..cd284b0bf9 100644 --- a/github/data_source_github_organization_external_identities.go +++ b/github/data_source_github_organization_external_identities.go @@ -121,7 +121,7 @@ func dataSourceGithubOrganizationExternalIdentitiesRead(ctx context.Context, d * if !query.Organization.SamlIdentityProvider.PageInfo.HasNextPage { break } - variables["after"] = githubv4.NewString(query.Organization.SamlIdentityProvider.PageInfo.EndCursor) + variables["after"] = new(query.Organization.SamlIdentityProvider.PageInfo.EndCursor) } d.SetId(name) diff --git a/github/data_source_github_organization_ip_allow_list.go b/github/data_source_github_organization_ip_allow_list.go index fe234d5d4e..2c7e770f1d 100644 --- a/github/data_source_github_organization_ip_allow_list.go +++ b/github/data_source_github_organization_ip_allow_list.go @@ -98,7 +98,7 @@ func dataSourceGithubOrganizationIpAllowListRead(ctx context.Context, d *schema. if !query.Organization.IpAllowListEntries.PageInfo.HasNextPage { break } - variables["entriesCursor"] = githubv4.NewString(query.Organization.IpAllowListEntries.PageInfo.EndCursor) + variables["entriesCursor"] = new(query.Organization.IpAllowListEntries.PageInfo.EndCursor) } for index := range ipAllowListEntries { ipAllowList = append(ipAllowList, map[string]any{ diff --git a/github/data_source_github_organization_teams.go b/github/data_source_github_organization_teams.go index d42b312432..e98045ea9f 100644 --- a/github/data_source_github_organization_teams.go +++ b/github/data_source_github_organization_teams.go @@ -131,7 +131,7 @@ func dataSourceGithubOrganizationTeamsRead(ctx context.Context, d *schema.Resour if !query.Organization.Teams.PageInfo.HasNextPage { break } - variables["cursor"] = githubv4.NewString(query.Organization.Teams.PageInfo.EndCursor) + variables["cursor"] = new(query.Organization.Teams.PageInfo.EndCursor) } d.SetId(string(query.Organization.ID)) diff --git a/github/resource_github_actions_organization_permissions.go b/github/resource_github_actions_organization_permissions.go index e17d9c6a8e..ec76372aa0 100644 --- a/github/resource_github_actions_organization_permissions.go +++ b/github/resource_github_actions_organization_permissions.go @@ -159,7 +159,7 @@ func resourceGithubActionsOrganizationPermissionsCreateOrUpdate(d *schema.Resour } if v, ok := d.GetOk("sha_pinning_required"); ok { - actionsPermissions.SHAPinningRequired = github.Ptr(v.(bool)) + actionsPermissions.SHAPinningRequired = new(v.(bool)) } _, _, err = client.Actions.UpdateActionsPermissions(ctx, @@ -313,8 +313,8 @@ func resourceGithubActionsOrganizationPermissionsDelete(d *schema.ResourceData, _, _, err = client.Actions.UpdateActionsPermissions(ctx, orgName, github.ActionsPermissions{ - AllowedActions: github.Ptr("all"), - EnabledRepositories: github.Ptr("all"), + AllowedActions: new("all"), + EnabledRepositories: new("all"), }) if err != nil { return err diff --git a/github/resource_github_actions_organization_secret_repository.go b/github/resource_github_actions_organization_secret_repository.go index 0d6acb32f0..cf0d98db07 100644 --- a/github/resource_github_actions_organization_secret_repository.go +++ b/github/resource_github_actions_organization_secret_repository.go @@ -50,7 +50,7 @@ func resourceGithubActionsOrganizationSecretRepositoryCreate(ctx context.Context repoID := d.Get("repository_id").(int) repository := &github.Repository{ - ID: github.Ptr(int64(repoID)), + ID: new(int64(repoID)), } _, err := client.Actions.AddSelectedRepoToOrgSecret(ctx, owner, secretName, repository) @@ -120,7 +120,7 @@ func resourceGithubActionsOrganizationSecretRepositoryDelete(ctx context.Context repoID := d.Get("repository_id").(int) repository := &github.Repository{ - ID: github.Ptr(int64(repoID)), + ID: new(int64(repoID)), } _, err := client.Actions.RemoveSelectedRepoFromOrgSecret(ctx, owner, secretName, repository) if err != nil { diff --git a/github/resource_github_actions_organization_variable.go b/github/resource_github_actions_organization_variable.go index 9b9af649d6..bc9ad8caf5 100644 --- a/github/resource_github_actions_organization_variable.go +++ b/github/resource_github_actions_organization_variable.go @@ -86,8 +86,8 @@ func resourceGithubActionsOrganizationVariableCreate(ctx context.Context, d *sch variable := &github.ActionsVariable{ Name: varName, Value: d.Get("value").(string), - Visibility: github.Ptr(visibility), - SelectedRepositoryIDs: github.Ptr(repoIDs), + Visibility: new(visibility), + SelectedRepositoryIDs: new(repoIDs), } _, err := client.Actions.CreateOrgVariable(ctx, owner, variable) if err != nil { @@ -193,8 +193,8 @@ func resourceGithubActionsOrganizationVariableUpdate(ctx context.Context, d *sch variable := &github.ActionsVariable{ Name: varName, Value: d.Get("value").(string), - Visibility: github.Ptr(visibility), - SelectedRepositoryIDs: github.Ptr(repoIDs), + Visibility: new(visibility), + SelectedRepositoryIDs: new(repoIDs), } _, err := client.Actions.UpdateOrgVariable(ctx, owner, variable) diff --git a/github/resource_github_actions_organization_variable_repository.go b/github/resource_github_actions_organization_variable_repository.go index 544454b005..948f8155ff 100644 --- a/github/resource_github_actions_organization_variable_repository.go +++ b/github/resource_github_actions_organization_variable_repository.go @@ -50,7 +50,7 @@ func resourceGithubActionsOrganizationVariableRepositoryCreate(ctx context.Conte repoID := d.Get("repository_id").(int) repository := &github.Repository{ - ID: github.Ptr(int64(repoID)), + ID: new(int64(repoID)), } _, err := client.Actions.AddSelectedRepoToOrgVariable(ctx, owner, variableName, repository) @@ -120,7 +120,7 @@ func resourceGithubActionsOrganizationVariableRepositoryDelete(ctx context.Conte repoID := d.Get("repository_id").(int) repository := &github.Repository{ - ID: github.Ptr(int64(repoID)), + ID: new(int64(repoID)), } _, err := client.Actions.RemoveSelectedRepoFromOrgVariable(ctx, owner, variableName, repository) if err != nil { diff --git a/github/resource_github_actions_organization_variable_test.go b/github/resource_github_actions_organization_variable_test.go index e5633bf614..3f536aa386 100644 --- a/github/resource_github_actions_organization_variable_test.go +++ b/github/resource_github_actions_organization_variable_test.go @@ -361,7 +361,7 @@ resource "github_actions_organization_variable" "test" { _, err = client.Actions.CreateOrgVariable(ctx, owner, &github.ActionsVariable{ Name: varName, Value: "test", - Visibility: github.Ptr("all"), + Visibility: new("all"), }) return err }, diff --git a/github/resource_github_actions_organization_workflow_permissions.go b/github/resource_github_actions_organization_workflow_permissions.go index 174590e116..83f3f9b944 100644 --- a/github/resource_github_actions_organization_workflow_permissions.go +++ b/github/resource_github_actions_organization_workflow_permissions.go @@ -117,11 +117,11 @@ func resourceGithubActionsOrganizationWorkflowPermissionsCreateOrUpdate(ctx cont workflowPerms := github.DefaultWorkflowPermissionOrganization{} if v, ok := d.GetOk("default_workflow_permissions"); ok { - workflowPerms.DefaultWorkflowPermissions = github.Ptr(v.(string)) + workflowPerms.DefaultWorkflowPermissions = new(v.(string)) } if v, ok := d.GetOk("can_approve_pull_request_reviews"); ok { - workflowPerms.CanApprovePullRequestReviews = github.Ptr(v.(bool)) + workflowPerms.CanApprovePullRequestReviews = new(v.(bool)) } tflog.Debug(ctx, "Calling GitHub API to update workflow permissions", map[string]any{ @@ -194,8 +194,8 @@ func resourceGithubActionsOrganizationWorkflowPermissionsDelete(ctx context.Cont // Reset to safe defaults workflowPerms := github.DefaultWorkflowPermissionOrganization{ - DefaultWorkflowPermissions: github.Ptr("read"), - CanApprovePullRequestReviews: github.Ptr(false), + DefaultWorkflowPermissions: new("read"), + CanApprovePullRequestReviews: new(false), } tflog.Debug(ctx, "Using safe default values", map[string]any{ diff --git a/github/resource_github_actions_repository_access_level.go b/github/resource_github_actions_repository_access_level.go index 4c1fc96a71..eced33e0dd 100644 --- a/github/resource_github_actions_repository_access_level.go +++ b/github/resource_github_actions_repository_access_level.go @@ -46,7 +46,7 @@ func resourceGithubActionsRepositoryAccessLevelCreateOrUpdate(d *schema.Resource accessLevel := d.Get("access_level").(string) actionAccessLevel := github.RepositoryActionsAccessLevel{ - AccessLevel: github.Ptr(accessLevel), + AccessLevel: new(accessLevel), } _, err := client.Repositories.EditActionsAccessLevel(ctx, owner, repoName, actionAccessLevel) @@ -81,7 +81,7 @@ func resourceGithubActionsRepositoryAccessLevelDelete(d *schema.ResourceData, me ctx := context.WithValue(context.Background(), ctxId, repoName) actionAccessLevel := github.RepositoryActionsAccessLevel{ - AccessLevel: github.Ptr("none"), + AccessLevel: new("none"), } _, err := client.Repositories.EditActionsAccessLevel(ctx, owner, repoName, actionAccessLevel) diff --git a/github/resource_github_actions_repository_oidc_subject_claim_customization_template.go b/github/resource_github_actions_repository_oidc_subject_claim_customization_template.go index 29335df96a..6185e6ecb8 100644 --- a/github/resource_github_actions_repository_oidc_subject_claim_customization_template.go +++ b/github/resource_github_actions_repository_oidc_subject_claim_customization_template.go @@ -117,7 +117,7 @@ func resourceGithubActionsRepositoryOIDCSubjectClaimCustomizationTemplateDelete( owner := meta.(*Owner).name customOIDCSubjectClaimTemplate := &github.OIDCSubjectClaimCustomTemplate{ - UseDefault: github.Ptr(true), + UseDefault: new(true), } ctx := context.Background() diff --git a/github/resource_github_actions_repository_permissions.go b/github/resource_github_actions_repository_permissions.go index d5f4ef9868..d5394c438a 100644 --- a/github/resource_github_actions_repository_permissions.go +++ b/github/resource_github_actions_repository_permissions.go @@ -132,7 +132,7 @@ func resourceGithubActionsRepositoryPermissionsCreateOrUpdate(d *schema.Resource } if v, ok := d.GetOk("sha_pinning_required"); ok { - repoActionPermissions.SHAPinningRequired = github.Ptr(v.(bool)) + repoActionPermissions.SHAPinningRequired = new(v.(bool)) } _, _, err := client.Repositories.UpdateActionsPermissions(ctx, @@ -236,8 +236,8 @@ func resourceGithubActionsRepositoryPermissionsDelete(d *schema.ResourceData, me // Reset the repo to "default" settings repoActionPermissions := github.ActionsPermissionsRepository{ - AllowedActions: github.Ptr("all"), - Enabled: github.Ptr(true), + AllowedActions: new("all"), + Enabled: new(true), } _, _, err := client.Repositories.UpdateActionsPermissions(ctx, diff --git a/github/resource_github_branch_protection.go b/github/resource_github_branch_protection.go index 8dc5bbcbcc..7faa34320f 100644 --- a/github/resource_github_branch_protection.go +++ b/github/resource_github_branch_protection.go @@ -232,30 +232,30 @@ func resourceGithubBranchProtectionCreate(d *schema.ResourceData, meta any) erro data.BypassPullRequestActorIDs = bypassPullRequestIds input := githubv4.CreateBranchProtectionRuleInput{ - AllowsDeletions: githubv4.NewBoolean(githubv4.Boolean(data.AllowsDeletions)), - AllowsForcePushes: githubv4.NewBoolean(githubv4.Boolean(data.AllowsForcePushes)), - BlocksCreations: githubv4.NewBoolean(githubv4.Boolean(data.BlocksCreations)), - BypassForcePushActorIDs: githubv4NewIDSlice(githubv4IDSliceEmpty(data.BypassForcePushActorIDs)), - BypassPullRequestActorIDs: githubv4NewIDSlice(githubv4IDSliceEmpty(data.BypassPullRequestActorIDs)), - DismissesStaleReviews: githubv4.NewBoolean(githubv4.Boolean(data.DismissesStaleReviews)), - IsAdminEnforced: githubv4.NewBoolean(githubv4.Boolean(data.IsAdminEnforced)), + AllowsDeletions: new(githubv4.Boolean(data.AllowsDeletions)), + AllowsForcePushes: new(githubv4.Boolean(data.AllowsForcePushes)), + BlocksCreations: new(githubv4.Boolean(data.BlocksCreations)), + BypassForcePushActorIDs: new(githubv4IDSliceEmpty(data.BypassForcePushActorIDs)), + BypassPullRequestActorIDs: new(githubv4IDSliceEmpty(data.BypassPullRequestActorIDs)), + DismissesStaleReviews: new(githubv4.Boolean(data.DismissesStaleReviews)), + IsAdminEnforced: new(githubv4.Boolean(data.IsAdminEnforced)), Pattern: githubv4.String(data.Pattern), - PushActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.PushActorIDs)), - RepositoryID: githubv4.NewID(githubv4.ID(data.RepositoryID)), - RequiredApprovingReviewCount: githubv4.NewInt(githubv4.Int(data.RequiredApprovingReviewCount)), - RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSliceEmpty(data.RequiredStatusCheckContexts)), - RequiresApprovingReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresApprovingReviews)), - RequiresCodeOwnerReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCodeOwnerReviews)), - RequiresCommitSignatures: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCommitSignatures)), - RequiresConversationResolution: githubv4.NewBoolean(githubv4.Boolean(data.RequiresConversationResolution)), - RequiresLinearHistory: githubv4.NewBoolean(githubv4.Boolean(data.RequiresLinearHistory)), - RequiresStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStatusChecks)), - RequiresStrictStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStrictStatusChecks)), - RestrictsPushes: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsPushes)), - RestrictsReviewDismissals: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsReviewDismissals)), - ReviewDismissalActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.ReviewDismissalActorIDs)), - LockBranch: githubv4.NewBoolean(githubv4.Boolean(data.LockBranch)), - RequireLastPushApproval: githubv4.NewBoolean(githubv4.Boolean(data.RequireLastPushApproval)), + PushActorIDs: new(githubv4IDSlice(data.PushActorIDs)), + RepositoryID: new(githubv4.ID(data.RepositoryID)), + RequiredApprovingReviewCount: new(githubv4.Int(data.RequiredApprovingReviewCount)), + RequiredStatusCheckContexts: new(githubv4StringSliceEmpty(data.RequiredStatusCheckContexts)), + RequiresApprovingReviews: new(githubv4.Boolean(data.RequiresApprovingReviews)), + RequiresCodeOwnerReviews: new(githubv4.Boolean(data.RequiresCodeOwnerReviews)), + RequiresCommitSignatures: new(githubv4.Boolean(data.RequiresCommitSignatures)), + RequiresConversationResolution: new(githubv4.Boolean(data.RequiresConversationResolution)), + RequiresLinearHistory: new(githubv4.Boolean(data.RequiresLinearHistory)), + RequiresStatusChecks: new(githubv4.Boolean(data.RequiresStatusChecks)), + RequiresStrictStatusChecks: new(githubv4.Boolean(data.RequiresStrictStatusChecks)), + RestrictsPushes: new(githubv4.Boolean(data.RestrictsPushes)), + RestrictsReviewDismissals: new(githubv4.Boolean(data.RestrictsReviewDismissals)), + ReviewDismissalActorIDs: new(githubv4IDSlice(data.ReviewDismissalActorIDs)), + LockBranch: new(githubv4.Boolean(data.LockBranch)), + RequireLastPushApproval: new(githubv4.Boolean(data.RequireLastPushApproval)), } ctx := context.Background() @@ -406,29 +406,29 @@ func resourceGithubBranchProtectionUpdate(d *schema.ResourceData, meta any) erro input := githubv4.UpdateBranchProtectionRuleInput{ BranchProtectionRuleID: d.Id(), - AllowsDeletions: githubv4.NewBoolean(githubv4.Boolean(data.AllowsDeletions)), - AllowsForcePushes: githubv4.NewBoolean(githubv4.Boolean(data.AllowsForcePushes)), - BlocksCreations: githubv4.NewBoolean(githubv4.Boolean(data.BlocksCreations)), - BypassForcePushActorIDs: githubv4NewIDSlice(githubv4IDSliceEmpty(data.BypassForcePushActorIDs)), - BypassPullRequestActorIDs: githubv4NewIDSlice(githubv4IDSliceEmpty(data.BypassPullRequestActorIDs)), - DismissesStaleReviews: githubv4.NewBoolean(githubv4.Boolean(data.DismissesStaleReviews)), - IsAdminEnforced: githubv4.NewBoolean(githubv4.Boolean(data.IsAdminEnforced)), - Pattern: githubv4.NewString(githubv4.String(data.Pattern)), - PushActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.PushActorIDs)), - RequiredApprovingReviewCount: githubv4.NewInt(githubv4.Int(data.RequiredApprovingReviewCount)), - RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSliceEmpty(data.RequiredStatusCheckContexts)), - RequiresApprovingReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresApprovingReviews)), - RequiresCodeOwnerReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCodeOwnerReviews)), - RequiresCommitSignatures: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCommitSignatures)), - RequiresConversationResolution: githubv4.NewBoolean(githubv4.Boolean(data.RequiresConversationResolution)), - RequiresLinearHistory: githubv4.NewBoolean(githubv4.Boolean(data.RequiresLinearHistory)), - RequiresStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStatusChecks)), - RequiresStrictStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStrictStatusChecks)), - RestrictsPushes: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsPushes)), - RestrictsReviewDismissals: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsReviewDismissals)), - ReviewDismissalActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.ReviewDismissalActorIDs)), - LockBranch: githubv4.NewBoolean(githubv4.Boolean(data.LockBranch)), - RequireLastPushApproval: githubv4.NewBoolean(githubv4.Boolean(data.RequireLastPushApproval)), + AllowsDeletions: new(githubv4.Boolean(data.AllowsDeletions)), + AllowsForcePushes: new(githubv4.Boolean(data.AllowsForcePushes)), + BlocksCreations: new(githubv4.Boolean(data.BlocksCreations)), + BypassForcePushActorIDs: new(githubv4IDSliceEmpty(data.BypassForcePushActorIDs)), + BypassPullRequestActorIDs: new(githubv4IDSliceEmpty(data.BypassPullRequestActorIDs)), + DismissesStaleReviews: new(githubv4.Boolean(data.DismissesStaleReviews)), + IsAdminEnforced: new(githubv4.Boolean(data.IsAdminEnforced)), + Pattern: new(githubv4.String(data.Pattern)), + PushActorIDs: new(githubv4IDSlice(data.PushActorIDs)), + RequiredApprovingReviewCount: new(githubv4.Int(data.RequiredApprovingReviewCount)), + RequiredStatusCheckContexts: new(githubv4StringSliceEmpty(data.RequiredStatusCheckContexts)), + RequiresApprovingReviews: new(githubv4.Boolean(data.RequiresApprovingReviews)), + RequiresCodeOwnerReviews: new(githubv4.Boolean(data.RequiresCodeOwnerReviews)), + RequiresCommitSignatures: new(githubv4.Boolean(data.RequiresCommitSignatures)), + RequiresConversationResolution: new(githubv4.Boolean(data.RequiresConversationResolution)), + RequiresLinearHistory: new(githubv4.Boolean(data.RequiresLinearHistory)), + RequiresStatusChecks: new(githubv4.Boolean(data.RequiresStatusChecks)), + RequiresStrictStatusChecks: new(githubv4.Boolean(data.RequiresStrictStatusChecks)), + RestrictsPushes: new(githubv4.Boolean(data.RestrictsPushes)), + RestrictsReviewDismissals: new(githubv4.Boolean(data.RestrictsReviewDismissals)), + ReviewDismissalActorIDs: new(githubv4IDSlice(data.ReviewDismissalActorIDs)), + LockBranch: new(githubv4.Boolean(data.LockBranch)), + RequireLastPushApproval: new(githubv4.Boolean(data.RequireLastPushApproval)), } ctx := context.WithValue(context.Background(), ctxId, d.Id()) diff --git a/github/resource_github_branch_protection_v3_utils.go b/github/resource_github_branch_protection_v3_utils.go index fccab2a54c..5f1b06a2fe 100644 --- a/github/resource_github_branch_protection_v3_utils.go +++ b/github/resource_github_branch_protection_v3_utils.go @@ -15,7 +15,7 @@ import ( func buildProtectionRequest(d *schema.ResourceData) (*github.ProtectionRequest, error) { req := &github.ProtectionRequest{ EnforceAdmins: d.Get("enforce_admins").(bool), - RequiredConversationResolution: github.Ptr(d.Get("require_conversation_resolution").(bool)), + RequiredConversationResolution: new(d.Get("require_conversation_resolution").(bool)), } rsc, err := expandRequiredStatusChecks(d) diff --git a/github/resource_github_dependabot_organization_secret_repository.go b/github/resource_github_dependabot_organization_secret_repository.go index 2857730709..23104ee2f4 100644 --- a/github/resource_github_dependabot_organization_secret_repository.go +++ b/github/resource_github_dependabot_organization_secret_repository.go @@ -50,7 +50,7 @@ func resourceGithubDependabotOrganizationSecretRepositoryCreate(ctx context.Cont repoID := d.Get("repository_id").(int) repository := &github.Repository{ - ID: github.Ptr(int64(repoID)), + ID: new(int64(repoID)), } _, err := client.Dependabot.AddSelectedRepoToOrgSecret(ctx, owner, secretName, repository) @@ -120,7 +120,7 @@ func resourceGithubDependabotOrganizationSecretRepositoryDelete(ctx context.Cont repoID := d.Get("repository_id").(int) repository := &github.Repository{ - ID: github.Ptr(int64(repoID)), + ID: new(int64(repoID)), } _, err := client.Dependabot.RemoveSelectedRepoFromOrgSecret(ctx, owner, secretName, repository) if err != nil { diff --git a/github/resource_github_emu_group_mapping.go b/github/resource_github_emu_group_mapping.go index 6a9d6ad238..8811867fdb 100644 --- a/github/resource_github_emu_group_mapping.go +++ b/github/resource_github_emu_group_mapping.go @@ -77,7 +77,7 @@ func resourceGithubEMUGroupMappingCreate(ctx context.Context, d *schema.Resource groupID := toInt64(d.Get("group_id")) tflog.SetField(ctx, "group_id", groupID) eg := &github.ExternalGroup{ - GroupID: github.Ptr(groupID), + GroupID: new(groupID), } tflog.Debug(ctx, "Connecting external group to team via GitHub API") @@ -223,7 +223,7 @@ func resourceGithubEMUGroupMappingUpdate(ctx context.Context, d *schema.Resource groupID := toInt64(d.Get("group_id")) tflog.SetField(ctx, "group_id", groupID) eg := &github.ExternalGroup{ - GroupID: github.Ptr(groupID), + GroupID: new(groupID), } if d.HasChanges("group_id", "team_slug") { diff --git a/github/resource_github_enterprise_actions_permissions.go b/github/resource_github_enterprise_actions_permissions.go index 77050404cf..b9be1b5dc5 100644 --- a/github/resource_github_enterprise_actions_permissions.go +++ b/github/resource_github_enterprise_actions_permissions.go @@ -280,8 +280,8 @@ func resourceGithubActionsEnterprisePermissionsDelete(d *schema.ResourceData, me _, _, err := client.Actions.UpdateActionsPermissionsInEnterprise(ctx, d.Get("enterprise_slug").(string), github.ActionsPermissionsEnterprise{ - AllowedActions: github.Ptr("all"), - EnabledOrganizations: github.Ptr("all"), + AllowedActions: new("all"), + EnabledOrganizations: new("all"), }) if err != nil { return err diff --git a/github/resource_github_enterprise_actions_workflow_permissions.go b/github/resource_github_enterprise_actions_workflow_permissions.go index fd0e5d30b7..9e2cd98f53 100644 --- a/github/resource_github_enterprise_actions_workflow_permissions.go +++ b/github/resource_github_enterprise_actions_workflow_permissions.go @@ -54,11 +54,11 @@ func resourceGithubEnterpriseActionsWorkflowPermissionsCreateOrUpdate(d *schema. workflowPerms := github.DefaultWorkflowPermissionEnterprise{} if v, ok := d.GetOk("default_workflow_permissions"); ok { - workflowPerms.DefaultWorkflowPermissions = github.Ptr(v.(string)) + workflowPerms.DefaultWorkflowPermissions = new(v.(string)) } if v, ok := d.GetOk("can_approve_pull_request_reviews"); ok { - workflowPerms.CanApprovePullRequestReviews = github.Ptr(v.(bool)) + workflowPerms.CanApprovePullRequestReviews = new(v.(bool)) } log.Printf("[DEBUG] Updating workflow permissions for enterprise: %s", enterpriseSlug) @@ -104,8 +104,8 @@ func resourceGithubEnterpriseActionsWorkflowPermissionsDelete(d *schema.Resource // Reset to safe defaults workflowPerms := github.DefaultWorkflowPermissionEnterprise{ - DefaultWorkflowPermissions: github.Ptr("read"), - CanApprovePullRequestReviews: github.Ptr(false), + DefaultWorkflowPermissions: new("read"), + CanApprovePullRequestReviews: new(false), } _, _, err := client.Actions.UpdateDefaultWorkflowPermissionsInEnterprise(ctx, enterpriseSlug, workflowPerms) diff --git a/github/resource_github_enterprise_organization.go b/github/resource_github_enterprise_organization.go index acc706a53a..9f7fb5bb32 100644 --- a/github/resource_github_enterprise_organization.go +++ b/github/resource_github_enterprise_organization.go @@ -137,8 +137,8 @@ func resourceGithubEnterpriseOrganizationCreate(data *schema.ResourceData, meta context.Background(), data.Get("name").(string), &github.Organization{ - Description: github.Ptr(description), - Name: github.Ptr(displayName), + Description: new(description), + Name: new(displayName), }, ) if err != nil { @@ -208,7 +208,7 @@ func resourceGithubEnterpriseOrganizationRead(data *schema.ResourceData, meta an break } - variables["cursor"] = githubv4.NewString(query.Node.Organization.MembersWithRole.PageInfo.EndCursor) + variables["cursor"] = new(query.Node.Organization.MembersWithRole.PageInfo.EndCursor) } err := data.Set("admin_logins", schema.NewSet(schema.HashString, adminLogins)) @@ -324,7 +324,7 @@ func updateDescription(ctx context.Context, data *schema.ResourceData, v3 *githu ctx, orgName, &github.Organization{ - Description: github.Ptr(newDesc), + Description: new(newDesc), }, ) if err != nil { @@ -349,7 +349,7 @@ func updateDisplayName(ctx context.Context, data *schema.ResourceData, v4 *githu ctx, orgName, &github.Organization{ - Name: github.Ptr(newDisplayName), + Name: new(newDisplayName), }, ) if err != nil { @@ -411,7 +411,7 @@ func removeUser(ctx context.Context, v3 *github.Client, v4 *githubv4.Client, use return err } - membership.Role = github.Ptr("member") + membership.Role = new("member") _, _, err = v3.Organizations.EditOrgMembership(ctx, user, orgName, membership) return err } diff --git a/github/resource_github_enterprise_security_analysis_settings.go b/github/resource_github_enterprise_security_analysis_settings.go index 304da609d0..f0f7aa9dbb 100644 --- a/github/resource_github_enterprise_security_analysis_settings.go +++ b/github/resource_github_enterprise_security_analysis_settings.go @@ -69,23 +69,23 @@ func resourceGithubEnterpriseSecurityAnalysisSettingsCreateOrUpdate(d *schema.Re settings := &github.EnterpriseSecurityAnalysisSettings{} if v, ok := d.GetOk("advanced_security_enabled_for_new_repositories"); ok { - settings.AdvancedSecurityEnabledForNewRepositories = github.Ptr(v.(bool)) + settings.AdvancedSecurityEnabledForNewRepositories = new(v.(bool)) } if v, ok := d.GetOk("secret_scanning_enabled_for_new_repositories"); ok { - settings.SecretScanningEnabledForNewRepositories = github.Ptr(v.(bool)) + settings.SecretScanningEnabledForNewRepositories = new(v.(bool)) } if v, ok := d.GetOk("secret_scanning_push_protection_enabled_for_new_repositories"); ok { - settings.SecretScanningPushProtectionEnabledForNewRepositories = github.Ptr(v.(bool)) + settings.SecretScanningPushProtectionEnabledForNewRepositories = new(v.(bool)) } if v, ok := d.GetOk("secret_scanning_push_protection_custom_link"); ok { - settings.SecretScanningPushProtectionCustomLink = github.Ptr(v.(string)) + settings.SecretScanningPushProtectionCustomLink = new(v.(string)) } if v, ok := d.GetOk("secret_scanning_validity_checks_enabled"); ok { - settings.SecretScanningValidityChecksEnabled = github.Ptr(v.(bool)) + settings.SecretScanningValidityChecksEnabled = new(v.(bool)) } log.Printf("[DEBUG] Updating security analysis settings for enterprise: %s", enterpriseSlug) @@ -140,11 +140,11 @@ func resourceGithubEnterpriseSecurityAnalysisSettingsDelete(d *schema.ResourceDa // Reset to safe defaults (all disabled) settings := &github.EnterpriseSecurityAnalysisSettings{ - AdvancedSecurityEnabledForNewRepositories: github.Ptr(false), - SecretScanningEnabledForNewRepositories: github.Ptr(false), - SecretScanningPushProtectionEnabledForNewRepositories: github.Ptr(false), - SecretScanningPushProtectionCustomLink: github.Ptr(""), - SecretScanningValidityChecksEnabled: github.Ptr(false), + AdvancedSecurityEnabledForNewRepositories: new(false), + SecretScanningEnabledForNewRepositories: new(false), + SecretScanningPushProtectionEnabledForNewRepositories: new(false), + SecretScanningPushProtectionCustomLink: new(""), + SecretScanningValidityChecksEnabled: new(false), } _, err := client.Enterprise.UpdateCodeSecurityAndAnalysis(ctx, enterpriseSlug, settings) diff --git a/github/resource_github_issue.go b/github/resource_github_issue.go index 99a926045e..8aaa8317ae 100644 --- a/github/resource_github_issue.go +++ b/github/resource_github_issue.go @@ -84,11 +84,11 @@ func resourceGithubIssueCreateOrUpdate(d *schema.ResourceData, meta any) error { milestone := d.Get("milestone_number").(int) req := &github.IssueRequest{ - Title: github.Ptr(title), + Title: new(title), } if v, ok := d.GetOk("body"); ok { - req.Body = github.Ptr(v.(string)) + req.Body = new(v.(string)) } labels := expandStringList(d.Get("labels").(*schema.Set).List()) @@ -98,7 +98,7 @@ func resourceGithubIssueCreateOrUpdate(d *schema.ResourceData, meta any) error { req.Assignees = &assignees if milestone > 0 { - req.Milestone = intPtr(milestone) + req.Milestone = new(milestone) } var issue *github.Issue @@ -219,13 +219,9 @@ func resourceGithubIssueDelete(d *schema.ResourceData, meta any) error { log.Printf("[DEBUG] Deleting issue by closing: %d (%s/%s)", number, orgName, repoName) - request := &github.IssueRequest{State: github.Ptr("closed")} + request := &github.IssueRequest{State: new("closed")} _, _, err := client.Issues.Edit(ctx, orgName, repoName, number, request) return err } - -func intPtr(i int) *int { - return &i -} diff --git a/github/resource_github_issue_label.go b/github/resource_github_issue_label.go index fecbe93c90..d158fed8d8 100644 --- a/github/resource_github_issue_label.go +++ b/github/resource_github_issue_label.go @@ -78,8 +78,8 @@ func resourceGithubIssueLabelCreateOrUpdate(d *schema.ResourceData, meta any) er color := d.Get("color").(string) label := &github.Label{ - Name: github.Ptr(name), - Color: github.Ptr(color), + Name: new(name), + Color: new(color), } ctx := context.Background() if !d.IsNewResource() { @@ -106,7 +106,7 @@ func resourceGithubIssueLabelCreateOrUpdate(d *schema.ResourceData, meta any) er } if existing != nil { - label.Description = github.Ptr(d.Get("description").(string)) + label.Description = new(d.Get("description").(string)) // Pull out the original name. If we already have a resource, this is the // parsed ID. If not, it's the value given to the resource. @@ -128,7 +128,7 @@ func resourceGithubIssueLabelCreateOrUpdate(d *schema.ResourceData, meta any) er } } else { if v, ok := d.GetOk("description"); ok { - label.Description = github.Ptr(v.(string)) + label.Description = new(v.(string)) } _, _, err := client.Issues.CreateLabel(ctx, diff --git a/github/resource_github_issue_labels.go b/github/resource_github_issue_labels.go index 7b887113f0..e64533571b 100644 --- a/github/resource_github_issue_labels.go +++ b/github/resource_github_issue_labels.go @@ -121,9 +121,9 @@ func resourceGithubIssueLabelsCreateOrUpdate(d *schema.ResourceData, meta any) e log.Printf("[DEBUG] Updating GitHub issue label %s/%s/%s", owner, repository, name) _, _, err := client.Issues.EditLabel(ctx, owner, repository, name, &github.Label{ - Name: github.Ptr(name), - Description: github.Ptr(description), - Color: github.Ptr(color), + Name: new(name), + Description: new(description), + Color: new(color), }) if err != nil { return err @@ -150,9 +150,9 @@ func resourceGithubIssueLabelsCreateOrUpdate(d *schema.ResourceData, meta any) e log.Printf("[DEBUG] Creating GitHub issue label %s/%s/%s", owner, repository, name) _, _, err := client.Issues.CreateLabel(ctx, owner, repository, &github.Label{ - Name: github.Ptr(name), - Description: github.Ptr(labelData["description"].(string)), - Color: github.Ptr(labelData["color"].(string)), + Name: new(name), + Description: new(labelData["description"].(string)), + Color: new(labelData["color"].(string)), }) if err != nil { return err diff --git a/github/resource_github_membership.go b/github/resource_github_membership.go index f8f4083e68..f54f75a28c 100644 --- a/github/resource_github_membership.go +++ b/github/resource_github_membership.go @@ -70,7 +70,7 @@ func resourceGithubMembershipCreateOrUpdate(ctx context.Context, d *schema.Resou username, orgName, &github.Membership{ - Role: github.Ptr(roleName), + Role: new(roleName), }, ) if err != nil { @@ -186,7 +186,7 @@ func resourceGithubMembershipDelete(ctx context.Context, d *schema.ResourceData, } _, _, err = client.Organizations.EditOrgMembership(ctx, username, orgName, &github.Membership{ - Role: github.Ptr(downgradeTo), + Role: new(downgradeTo), }) } else { tflog.Info(ctx, fmt.Sprintf("Revoking '%s' membership for '%s'", orgName, username), map[string]any{ diff --git a/github/resource_github_organization_custom_role.go b/github/resource_github_organization_custom_role.go index 3afdcf1bcf..73196bf932 100644 --- a/github/resource_github_organization_custom_role.go +++ b/github/resource_github_organization_custom_role.go @@ -67,9 +67,9 @@ func resourceGithubOrganizationCustomRoleCreate(d *schema.ResourceData, meta any } role, _, err := client.Organizations.CreateCustomRepoRole(ctx, orgName, &github.CreateOrUpdateCustomRepoRoleOptions{ - Name: github.Ptr(d.Get("name").(string)), - Description: github.Ptr(d.Get("description").(string)), - BaseRole: github.Ptr(d.Get("base_role").(string)), + Name: new(d.Get("name").(string)), + Description: new(d.Get("description").(string)), + BaseRole: new(d.Get("base_role").(string)), Permissions: permissionsStr, }) if err != nil { @@ -153,9 +153,9 @@ func resourceGithubOrganizationCustomRoleUpdate(d *schema.ResourceData, meta any } update := &github.CreateOrUpdateCustomRepoRoleOptions{ - Name: github.Ptr(d.Get("name").(string)), - Description: github.Ptr(d.Get("description").(string)), - BaseRole: github.Ptr(d.Get("base_role").(string)), + Name: new(d.Get("name").(string)), + Description: new(d.Get("description").(string)), + BaseRole: new(d.Get("base_role").(string)), Permissions: permissionsStr, } diff --git a/github/resource_github_organization_repository_role.go b/github/resource_github_organization_repository_role.go index 78e1bbf2e7..5c2a22dd55 100644 --- a/github/resource_github_organization_repository_role.go +++ b/github/resource_github_organization_repository_role.go @@ -77,9 +77,9 @@ func resourceGithubOrganizationRepositoryRoleCreate(ctx context.Context, d *sche } role, _, err := client.Organizations.CreateCustomRepoRole(ctx, orgName, &github.CreateOrUpdateCustomRepoRoleOptions{ - Name: github.Ptr(d.Get("name").(string)), - Description: github.Ptr(d.Get("description").(string)), - BaseRole: github.Ptr(d.Get("base_role").(string)), + Name: new(d.Get("name").(string)), + Description: new(d.Get("description").(string)), + BaseRole: new(d.Get("base_role").(string)), Permissions: permissionsStr, }) if err != nil { @@ -164,9 +164,9 @@ func resourceGithubOrganizationRepositoryRoleUpdate(ctx context.Context, d *sche } update := &github.CreateOrUpdateCustomRepoRoleOptions{ - Name: github.Ptr(d.Get("name").(string)), - Description: github.Ptr(d.Get("description").(string)), - BaseRole: github.Ptr(d.Get("base_role").(string)), + Name: new(d.Get("name").(string)), + Description: new(d.Get("description").(string)), + BaseRole: new(d.Get("base_role").(string)), Permissions: permissionsStr, } diff --git a/github/resource_github_organization_role.go b/github/resource_github_organization_role.go index cd45af1994..0ea17251ec 100644 --- a/github/resource_github_organization_role.go +++ b/github/resource_github_organization_role.go @@ -74,14 +74,14 @@ func resourceGithubOrganizationRoleCreate(ctx context.Context, d *schema.Resourc } createOrUpdateOrgRoleOptions := &github.CreateOrUpdateOrgRoleOptions{ - Name: github.Ptr(d.Get("name").(string)), - Description: github.Ptr(d.Get("description").(string)), + Name: new(d.Get("name").(string)), + Description: new(d.Get("description").(string)), Permissions: permissionsStr, } baseRole := d.Get("base_role").(string) if baseRole != "none" { - createOrUpdateOrgRoleOptions.BaseRole = github.Ptr(baseRole) + createOrUpdateOrgRoleOptions.BaseRole = new(baseRole) } role, _, err := client.Organizations.CreateCustomOrgRole(ctx, orgName, createOrUpdateOrgRoleOptions) @@ -169,9 +169,9 @@ func resourceGithubOrganizationRoleUpdate(ctx context.Context, d *schema.Resourc } update := &github.CreateOrUpdateOrgRoleOptions{ - Name: github.Ptr(d.Get("name").(string)), - Description: github.Ptr(d.Get("description").(string)), - BaseRole: github.Ptr(d.Get("base_role").(string)), + Name: new(d.Get("name").(string)), + Description: new(d.Get("description").(string)), + BaseRole: new(d.Get("base_role").(string)), Permissions: permissionsStr, } diff --git a/github/resource_github_organization_settings.go b/github/resource_github_organization_settings.go index 245e76b878..f2b20072cc 100644 --- a/github/resource_github_organization_settings.go +++ b/github/resource_github_organization_settings.go @@ -194,43 +194,43 @@ func buildOrganizationSettings(d *schema.ResourceData, isEnterprise bool) *githu // Required field - always include if configured (API requires it even if unchanged) if billingEmail, ok := d.GetOk("billing_email"); ok { - settings.BillingEmail = github.Ptr(billingEmail.(string)) + settings.BillingEmail = new(billingEmail.(string)) } // Optional string fields - only set if should be included if shouldInclude("company") { if company, ok := d.GetOk("company"); ok { - settings.Company = github.Ptr(company.(string)) + settings.Company = new(company.(string)) } } if shouldInclude("email") { if email, ok := d.GetOk("email"); ok { - settings.Email = github.Ptr(email.(string)) + settings.Email = new(email.(string)) } } if shouldInclude("twitter_username") { if twitterUsername, ok := d.GetOk("twitter_username"); ok { - settings.TwitterUsername = github.Ptr(twitterUsername.(string)) + settings.TwitterUsername = new(twitterUsername.(string)) } } if shouldInclude("location") { if location, ok := d.GetOk("location"); ok { - settings.Location = github.Ptr(location.(string)) + settings.Location = new(location.(string)) } } if shouldInclude("name") { if name, ok := d.GetOk("name"); ok { - settings.Name = github.Ptr(name.(string)) + settings.Name = new(name.(string)) } } if shouldInclude("description") { if description, ok := d.GetOk("description"); ok { - settings.Description = github.Ptr(description.(string)) + settings.Description = new(description.(string)) } } if shouldInclude("blog") { if blog, ok := d.GetOk("blog"); ok { - settings.Blog = github.Ptr(blog.(string)) + settings.Blog = new(blog.(string)) } } @@ -238,63 +238,63 @@ func buildOrganizationSettings(d *schema.ResourceData, isEnterprise bool) *githu // Use d.Get() instead of d.GetOk() when shouldInclude() returns true, // because we already know the field should be included, and d.Get() correctly handles false values if shouldInclude("has_organization_projects") { - settings.HasOrganizationProjects = github.Ptr(d.Get("has_organization_projects").(bool)) + settings.HasOrganizationProjects = new(d.Get("has_organization_projects").(bool)) } if shouldInclude("has_repository_projects") { - settings.HasRepositoryProjects = github.Ptr(d.Get("has_repository_projects").(bool)) + settings.HasRepositoryProjects = new(d.Get("has_repository_projects").(bool)) } if shouldInclude("default_repository_permission") { if defaultRepoPermission, ok := d.GetOk("default_repository_permission"); ok { - settings.DefaultRepoPermission = github.Ptr(defaultRepoPermission.(string)) + settings.DefaultRepoPermission = new(defaultRepoPermission.(string)) } } if shouldInclude("members_can_create_repositories") { - settings.MembersCanCreateRepos = github.Ptr(d.Get("members_can_create_repositories").(bool)) + settings.MembersCanCreateRepos = new(d.Get("members_can_create_repositories").(bool)) } if shouldInclude("members_can_create_private_repositories") { - settings.MembersCanCreatePrivateRepos = github.Ptr(d.Get("members_can_create_private_repositories").(bool)) + settings.MembersCanCreatePrivateRepos = new(d.Get("members_can_create_private_repositories").(bool)) } if shouldInclude("members_can_create_public_repositories") { - settings.MembersCanCreatePublicRepos = github.Ptr(d.Get("members_can_create_public_repositories").(bool)) + settings.MembersCanCreatePublicRepos = new(d.Get("members_can_create_public_repositories").(bool)) } if shouldInclude("members_can_create_pages") { - settings.MembersCanCreatePages = github.Ptr(d.Get("members_can_create_pages").(bool)) + settings.MembersCanCreatePages = new(d.Get("members_can_create_pages").(bool)) } if shouldInclude("members_can_create_public_pages") { - settings.MembersCanCreatePublicPages = github.Ptr(d.Get("members_can_create_public_pages").(bool)) + settings.MembersCanCreatePublicPages = new(d.Get("members_can_create_public_pages").(bool)) } if shouldInclude("members_can_create_private_pages") { - settings.MembersCanCreatePrivatePages = github.Ptr(d.Get("members_can_create_private_pages").(bool)) + settings.MembersCanCreatePrivatePages = new(d.Get("members_can_create_private_pages").(bool)) } if shouldInclude("members_can_fork_private_repositories") { - settings.MembersCanForkPrivateRepos = github.Ptr(d.Get("members_can_fork_private_repositories").(bool)) + settings.MembersCanForkPrivateRepos = new(d.Get("members_can_fork_private_repositories").(bool)) } if shouldInclude("web_commit_signoff_required") { - settings.WebCommitSignoffRequired = github.Ptr(d.Get("web_commit_signoff_required").(bool)) + settings.WebCommitSignoffRequired = new(d.Get("web_commit_signoff_required").(bool)) } if shouldInclude("advanced_security_enabled_for_new_repositories") { - settings.AdvancedSecurityEnabledForNewRepos = github.Ptr(d.Get("advanced_security_enabled_for_new_repositories").(bool)) + settings.AdvancedSecurityEnabledForNewRepos = new(d.Get("advanced_security_enabled_for_new_repositories").(bool)) } if shouldInclude("dependabot_alerts_enabled_for_new_repositories") { - settings.DependabotAlertsEnabledForNewRepos = github.Ptr(d.Get("dependabot_alerts_enabled_for_new_repositories").(bool)) + settings.DependabotAlertsEnabledForNewRepos = new(d.Get("dependabot_alerts_enabled_for_new_repositories").(bool)) } if shouldInclude("dependabot_security_updates_enabled_for_new_repositories") { - settings.DependabotSecurityUpdatesEnabledForNewRepos = github.Ptr(d.Get("dependabot_security_updates_enabled_for_new_repositories").(bool)) + settings.DependabotSecurityUpdatesEnabledForNewRepos = new(d.Get("dependabot_security_updates_enabled_for_new_repositories").(bool)) } if shouldInclude("dependency_graph_enabled_for_new_repositories") { - settings.DependencyGraphEnabledForNewRepos = github.Ptr(d.Get("dependency_graph_enabled_for_new_repositories").(bool)) + settings.DependencyGraphEnabledForNewRepos = new(d.Get("dependency_graph_enabled_for_new_repositories").(bool)) } if shouldInclude("secret_scanning_enabled_for_new_repositories") { - settings.SecretScanningEnabledForNewRepos = github.Ptr(d.Get("secret_scanning_enabled_for_new_repositories").(bool)) + settings.SecretScanningEnabledForNewRepos = new(d.Get("secret_scanning_enabled_for_new_repositories").(bool)) } if shouldInclude("secret_scanning_push_protection_enabled_for_new_repositories") { - settings.SecretScanningPushProtectionEnabledForNewRepos = github.Ptr(d.Get("secret_scanning_push_protection_enabled_for_new_repositories").(bool)) + settings.SecretScanningPushProtectionEnabledForNewRepos = new(d.Get("secret_scanning_push_protection_enabled_for_new_repositories").(bool)) } // Enterprise-specific field if isEnterprise { if shouldInclude("members_can_create_internal_repositories") { - settings.MembersCanCreateInternalRepos = github.Ptr(d.Get("members_can_create_internal_repositories").(bool)) + settings.MembersCanCreateInternalRepos = new(d.Get("members_can_create_internal_repositories").(bool)) } } @@ -537,12 +537,12 @@ func resourceGithubOrganizationSettingsDelete(d *schema.ResourceData, meta any) // Build minimal settings with only required fields isEnterprise := orgInfo.GetPlan().GetName() == "enterprise" defaultSettings := &github.Organization{ - BillingEmail: github.Ptr("email@example.com"), + BillingEmail: new("email@example.com"), } // Only add enterprise-specific fields if it's an enterprise org if isEnterprise { - defaultSettings.MembersCanCreateInternalRepos = github.Ptr(true) + defaultSettings.MembersCanCreateInternalRepos = new(true) } _, _, err = client.Organizations.Edit(ctx, org, defaultSettings) diff --git a/github/resource_github_organization_webhook.go b/github/resource_github_organization_webhook.go index 5dc3e7ad31..7405680dfa 100644 --- a/github/resource_github_organization_webhook.go +++ b/github/resource_github_organization_webhook.go @@ -67,9 +67,9 @@ func resourceGithubOrganizationWebhookObject(d *schema.ResourceData) *github.Hoo } hook := &github.Hook{ - URL: github.Ptr(d.Get("url").(string)), + URL: new(d.Get("url").(string)), Events: events, - Active: github.Ptr(d.Get("active").(bool)), + Active: new(d.Get("active").(bool)), } config := d.Get("configuration").([]any) @@ -167,7 +167,7 @@ func resourceGithubOrganizationWebhookRead(ctx context.Context, d *schema.Resour currentSecret := d.Get("configuration").([]any)[0].(map[string]any)["secret"] if hook.Config.Secret != nil { - hook.Config.Secret = github.Ptr(currentSecret.(string)) + hook.Config.Secret = new(currentSecret.(string)) } } @@ -225,28 +225,28 @@ func resourceGithubOrganizationWebhookDelete(ctx context.Context, d *schema.Reso func webhookConfigFromInterface(config map[string]any) *github.HookConfig { hookConfig := &github.HookConfig{} if config["url"] != nil { - hookConfig.URL = github.Ptr(config["url"].(string)) + hookConfig.URL = new(config["url"].(string)) } if config["content_type"] != nil { - hookConfig.ContentType = github.Ptr(config["content_type"].(string)) + hookConfig.ContentType = new(config["content_type"].(string)) } if config["insecure_ssl"] != nil { if insecureSsl, ok := config["insecure_ssl"].(bool); ok { if insecureSsl { - hookConfig.InsecureSSL = github.Ptr("1") + hookConfig.InsecureSSL = new("1") } else { - hookConfig.InsecureSSL = github.Ptr("0") + hookConfig.InsecureSSL = new("0") } } else { if config["insecure_ssl"] == "1" || config["insecure_ssl"] == "true" { - hookConfig.InsecureSSL = github.Ptr("1") + hookConfig.InsecureSSL = new("1") } else { - hookConfig.InsecureSSL = github.Ptr("0") + hookConfig.InsecureSSL = new("0") } } } if config["secret"] != nil { - hookConfig.Secret = github.Ptr(config["secret"].(string)) + hookConfig.Secret = new(config["secret"].(string)) } return hookConfig } diff --git a/github/resource_github_release.go b/github/resource_github_release.go index 8ad37b8a67..4b600f96df 100644 --- a/github/resource_github_release.go +++ b/github/resource_github_release.go @@ -149,23 +149,23 @@ func resourceGithubReleaseCreateUpdate(ctx context.Context, d *schema.ResourceDa generateReleaseNotes := d.Get("generate_release_notes").(bool) req := &github.RepositoryRelease{ - TagName: github.Ptr(tagName), - TargetCommitish: github.Ptr(targetCommitish), - Draft: github.Ptr(draft), - Prerelease: github.Ptr(prerelease), - GenerateReleaseNotes: github.Ptr(generateReleaseNotes), + TagName: new(tagName), + TargetCommitish: new(targetCommitish), + Draft: new(draft), + Prerelease: new(prerelease), + GenerateReleaseNotes: new(generateReleaseNotes), } if v, ok := d.GetOk("body"); ok { - req.Body = github.Ptr(v.(string)) + req.Body = new(v.(string)) } if v, ok := d.GetOk("name"); ok { - req.Name = github.Ptr(v.(string)) + req.Name = new(v.(string)) } if v, ok := d.GetOk("discussion_category_name"); ok { - req.DiscussionCategoryName = github.Ptr(v.(string)) + req.DiscussionCategoryName = new(v.(string)) } var release *github.RepositoryRelease diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index 2c57b54182..79e6c5ec09 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -565,17 +565,17 @@ func calculateSecurityAndAnalysis(d *schema.ResourceData) *github.SecurityAndAna if ok, status := tryGetSecurityAndAnalysisSettingStatus(lookup, "advanced_security"); ok { securityAndAnalysis.AdvancedSecurity = &github.AdvancedSecurity{ - Status: github.Ptr(status), + Status: new(status), } } if ok, status := tryGetSecurityAndAnalysisSettingStatus(lookup, "secret_scanning"); ok { securityAndAnalysis.SecretScanning = &github.SecretScanning{ - Status: github.Ptr(status), + Status: new(status), } } if ok, status := tryGetSecurityAndAnalysisSettingStatus(lookup, "secret_scanning_push_protection"); ok { securityAndAnalysis.SecretScanningPushProtection = &github.SecretScanningPushProtection{ - Status: github.Ptr(status), + Status: new(status), } } @@ -586,27 +586,27 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository { visibility := calculateVisibility(d) repository := &github.Repository{ - Name: github.Ptr(d.Get("name").(string)), - Description: github.Ptr(d.Get("description").(string)), - Homepage: github.Ptr(d.Get("homepage_url").(string)), - Visibility: github.Ptr(visibility), - HasDownloads: github.Ptr(d.Get("has_downloads").(bool)), - HasIssues: github.Ptr(d.Get("has_issues").(bool)), - HasDiscussions: github.Ptr(d.Get("has_discussions").(bool)), - HasProjects: github.Ptr(d.Get("has_projects").(bool)), - HasWiki: github.Ptr(d.Get("has_wiki").(bool)), - IsTemplate: github.Ptr(d.Get("is_template").(bool)), - AllowMergeCommit: github.Ptr(d.Get("allow_merge_commit").(bool)), - AllowSquashMerge: github.Ptr(d.Get("allow_squash_merge").(bool)), - AllowRebaseMerge: github.Ptr(d.Get("allow_rebase_merge").(bool)), - AllowAutoMerge: github.Ptr(d.Get("allow_auto_merge").(bool)), - DeleteBranchOnMerge: github.Ptr(d.Get("delete_branch_on_merge").(bool)), - AutoInit: github.Ptr(d.Get("auto_init").(bool)), - LicenseTemplate: github.Ptr(d.Get("license_template").(string)), - GitignoreTemplate: github.Ptr(d.Get("gitignore_template").(string)), - Archived: github.Ptr(d.Get("archived").(bool)), + Name: new(d.Get("name").(string)), + Description: new(d.Get("description").(string)), + Homepage: new(d.Get("homepage_url").(string)), + Visibility: new(visibility), + HasDownloads: new(d.Get("has_downloads").(bool)), + HasIssues: new(d.Get("has_issues").(bool)), + HasDiscussions: new(d.Get("has_discussions").(bool)), + HasProjects: new(d.Get("has_projects").(bool)), + HasWiki: new(d.Get("has_wiki").(bool)), + IsTemplate: new(d.Get("is_template").(bool)), + AllowMergeCommit: new(d.Get("allow_merge_commit").(bool)), + AllowSquashMerge: new(d.Get("allow_squash_merge").(bool)), + AllowRebaseMerge: new(d.Get("allow_rebase_merge").(bool)), + AllowAutoMerge: new(d.Get("allow_auto_merge").(bool)), + DeleteBranchOnMerge: new(d.Get("delete_branch_on_merge").(bool)), + AutoInit: new(d.Get("auto_init").(bool)), + LicenseTemplate: new(d.Get("license_template").(string)), + GitignoreTemplate: new(d.Get("gitignore_template").(string)), + Archived: new(d.Get("archived").(bool)), Topics: expandStringList(d.Get("topics").(*schema.Set).List()), - AllowUpdateBranch: github.Ptr(d.Get("allow_update_branch").(bool)), + AllowUpdateBranch: new(d.Get("allow_update_branch").(bool)), SecurityAndAnalysis: calculateSecurityAndAnalysis(d), } @@ -614,8 +614,8 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository { allowMergeCommit, ok := d.Get("allow_merge_commit").(bool) if ok { if allowMergeCommit { - repository.MergeCommitTitle = github.Ptr(d.Get("merge_commit_title").(string)) - repository.MergeCommitMessage = github.Ptr(d.Get("merge_commit_message").(string)) + repository.MergeCommitTitle = new(d.Get("merge_commit_title").(string)) + repository.MergeCommitMessage = new(d.Get("merge_commit_message").(string)) } } @@ -623,25 +623,25 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository { allowSquashMerge, ok := d.Get("allow_squash_merge").(bool) if ok { if allowSquashMerge { - repository.SquashMergeCommitTitle = github.Ptr(d.Get("squash_merge_commit_title").(string)) - repository.SquashMergeCommitMessage = github.Ptr(d.Get("squash_merge_commit_message").(string)) + repository.SquashMergeCommitTitle = new(d.Get("squash_merge_commit_title").(string)) + repository.SquashMergeCommitMessage = new(d.Get("squash_merge_commit_message").(string)) } } // only configure allow forking if repository is not public if visibility != "public" && (d.IsNewResource() || d.HasChange("allow_forking")) { - if allowForking, ok := d.GetOkExists("allow_forking"); ok { //nolint:staticcheck,SA1019 // We sometimes need to use GetOkExists for booleans + if allowForking, ok := d.GetOkExists("allow_forking"); ok { //nolint:staticcheck // SA1019 // We sometimes need to use GetOkExists for booleans if val, ok := allowForking.(bool); ok { - repository.AllowForking = github.Ptr(val) + repository.AllowForking = new(val) } } } // only configure web commit signoff if explicitly set in the configuration if d.IsNewResource() || d.HasChange("web_commit_signoff_required") { - if webCommitSignoffRequired, ok := d.GetOkExists("web_commit_signoff_required"); ok { //nolint:staticcheck,SA1019 // We sometimes need to use GetOkExists for booleans + if webCommitSignoffRequired, ok := d.GetOkExists("web_commit_signoff_required"); ok { //nolint:staticcheck // SA1019 // We sometimes need to use GetOkExists for booleans if val, ok := webCommitSignoffRequired.(bool); ok { - repository.WebCommitSignoffRequired = github.Ptr(val) + repository.WebCommitSignoffRequired = new(val) } } } @@ -679,9 +679,9 @@ func resourceGithubRepositoryCreate(ctx context.Context, d *schema.ResourceData, templateRepoReq := github.TemplateRepoRequest{ Name: &repoName, Owner: &owner, - Description: github.Ptr(d.Get("description").(string)), - Private: github.Ptr(private), - IncludeAllBranches: github.Ptr(includeAllBranches), + Description: new(d.Get("description").(string)), + Private: new(private), + IncludeAllBranches: new(includeAllBranches), } repo, _, err := client.Repositories.CreateFromTemplate(ctx, @@ -948,7 +948,7 @@ func resourceGithubRepositoryUpdate(ctx context.Context, d *schema.ResourceData, // compatibility we need to allow terraform configurations that set // `default_branch` to "main" when a repository is created. if d.HasChange("default_branch") && !d.IsNewResource() { - repoReq.DefaultBranch = github.Ptr(d.Get("default_branch").(string)) + repoReq.DefaultBranch = new(d.Get("default_branch").(string)) } repoName := d.Id() @@ -995,7 +995,7 @@ func resourceGithubRepositoryUpdate(ctx context.Context, d *schema.ResourceData, } if d.IsNewResource() || d.HasChange("vulnerability_alerts") { - if v, ok := d.GetOkExists("vulnerability_alerts"); ok { //nolint:staticcheck,SA1019 // We sometimes need to use GetOkExists for booleans + if v, ok := d.GetOkExists("vulnerability_alerts"); ok { //nolint:staticcheck // SA1019 // We sometimes need to use GetOkExists for booleans if val, ok := v.(bool); ok { err := updateVulnerabilityAlerts(ctx, client, owner, repoName, val) if err != nil { @@ -1006,7 +1006,7 @@ func resourceGithubRepositoryUpdate(ctx context.Context, d *schema.ResourceData, } if d.HasChanges("visibility", "private") { - repoReq.Visibility = github.Ptr(visibility) + repoReq.Visibility = new(visibility) repoReq.AllowForking = allowForking log.Printf("[DEBUG] Updating repository visibility from %s to %s", repo.GetVisibility(), visibility) @@ -1061,17 +1061,17 @@ func expandPages(input []any) *github.Pages { } pages := input[0].(map[string]any) source := &github.PagesSource{ - Branch: github.Ptr("main"), + Branch: new("main"), } if len(pages["source"].([]any)) == 1 { if pagesSource, ok := pages["source"].([]any)[0].(map[string]any); ok { if v, ok := pagesSource["branch"].(string); ok { - source.Branch = github.Ptr(v) + source.Branch = new(v) } if v, ok := pagesSource["path"].(string); ok { // To set to the root directory "/", leave source.Path unset if v != "" && v != "/" { - source.Path = github.Ptr(v) + source.Path = new(v) } } } @@ -1079,7 +1079,7 @@ func expandPages(input []any) *github.Pages { var buildType *string if v, ok := pages["build_type"].(string); ok { - buildType = github.Ptr(v) + buildType = new(v) } return &github.Pages{Source: source, BuildType: buildType} @@ -1096,12 +1096,12 @@ func expandPagesUpdate(input []any) *github.PagesUpdate { // Only set the github.PagesUpdate CNAME field if the value is a non-empty string. // Leaving the CNAME field unset will remove the custom domain. if v, ok := pages["cname"].(string); ok && v != "" { - update.CNAME = github.Ptr(v) + update.CNAME = new(v) } // Only set the github.PagesUpdate BuildType field if the value is a non-empty string. if v, ok := pages["build_type"].(string); ok && v != "" { - update.BuildType = github.Ptr(v) + update.BuildType = new(v) } // To update the GitHub Pages source, the github.PagesUpdate Source field diff --git a/github/resource_github_repository_deploy_key.go b/github/resource_github_repository_deploy_key.go index ed31266203..f477bd3efb 100644 --- a/github/resource_github_repository_deploy_key.go +++ b/github/resource_github_repository_deploy_key.go @@ -69,9 +69,9 @@ func resourceGithubRepositoryDeployKeyCreate(d *schema.ResourceData, meta any) e ctx := context.Background() resultKey, _, err := client.Repositories.CreateKey(ctx, owner, repoName, &github.Key{ - Key: github.Ptr(key), - Title: github.Ptr(title), - ReadOnly: github.Ptr(readOnly), + Key: new(key), + Title: new(title), + ReadOnly: new(readOnly), }) if err != nil { return err diff --git a/github/resource_github_repository_deployment_branch_policy.go b/github/resource_github_repository_deployment_branch_policy.go index ce5d0c2e98..f08fd7acad 100644 --- a/github/resource_github_repository_deployment_branch_policy.go +++ b/github/resource_github_repository_deployment_branch_policy.go @@ -88,7 +88,7 @@ func resourceGithubRepositoryDeploymentBranchPolicyCreate(d *schema.ResourceData environmentName := d.Get("environment_name").(string) name := d.Get("name").(string) - policy, _, err := client.Repositories.CreateDeploymentBranchPolicy(ctx, owner, repoName, environmentName, &github.DeploymentBranchPolicyRequest{Name: &name, Type: github.Ptr("branch")}) + policy, _, err := client.Repositories.CreateDeploymentBranchPolicy(ctx, owner, repoName, environmentName, &github.DeploymentBranchPolicyRequest{Name: &name, Type: new("branch")}) if err != nil { return err } diff --git a/github/resource_github_repository_environment.go b/github/resource_github_repository_environment.go index 85f751c995..5e4383ad90 100644 --- a/github/resource_github_repository_environment.go +++ b/github/resource_github_repository_environment.go @@ -335,27 +335,27 @@ func createUpdateEnvironmentData(d *schema.ResourceData) github.CreateUpdateEnvi data := github.CreateUpdateEnvironment{} if v, ok := d.GetOk("wait_timer"); ok { - data.WaitTimer = github.Ptr(v.(int)) + data.WaitTimer = new(v.(int)) } - data.CanAdminsBypass = github.Ptr(d.Get("can_admins_bypass").(bool)) + data.CanAdminsBypass = new(d.Get("can_admins_bypass").(bool)) - data.PreventSelfReview = github.Ptr(d.Get("prevent_self_review").(bool)) + data.PreventSelfReview = new(d.Get("prevent_self_review").(bool)) if v, ok := d.GetOk("reviewers"); ok { envReviewers := make([]*github.EnvReviewers, 0) for _, team := range expandReviewers(v, "teams") { envReviewers = append(envReviewers, &github.EnvReviewers{ - Type: github.Ptr("Team"), - ID: github.Ptr(team), + Type: new("Team"), + ID: new(team), }) } for _, user := range expandReviewers(v, "users") { envReviewers = append(envReviewers, &github.EnvReviewers{ - Type: github.Ptr("User"), - ID: github.Ptr(user), + Type: new("User"), + ID: new(user), }) } @@ -365,8 +365,8 @@ func createUpdateEnvironmentData(d *schema.ResourceData) github.CreateUpdateEnvi if v, ok := d.GetOk("deployment_branch_policy"); ok { policy := v.([]any)[0].(map[string]any) data.DeploymentBranchPolicy = &github.BranchPolicy{ - ProtectedBranches: github.Ptr(policy["protected_branches"].(bool)), - CustomBranchPolicies: github.Ptr(policy["custom_branch_policies"].(bool)), + ProtectedBranches: new(policy["protected_branches"].(bool)), + CustomBranchPolicies: new(policy["custom_branch_policies"].(bool)), } } diff --git a/github/resource_github_repository_environment_deployment_policy.go b/github/resource_github_repository_environment_deployment_policy.go index 52569fe5e8..8ed9bb9568 100644 --- a/github/resource_github_repository_environment_deployment_policy.go +++ b/github/resource_github_repository_environment_deployment_policy.go @@ -117,8 +117,8 @@ func resourceGithubRepositoryEnvironmentDeploymentPolicyCreate(ctx context.Conte } createData := github.DeploymentBranchPolicyRequest{ - Name: github.Ptr(pattern), - Type: github.Ptr(policyType), + Name: new(pattern), + Type: new(policyType), } policy, _, err := client.Repositories.CreateDeploymentBranchPolicy(ctx, owner, repoName, url.PathEscape(envName), &createData) @@ -203,7 +203,7 @@ func resourceGithubRepositoryEnvironmentDeploymentPolicyUpdate(ctx context.Conte } updateData := github.DeploymentBranchPolicyRequest{ - Name: github.Ptr(pattern), + Name: new(pattern), } _, _, err := client.Repositories.UpdateDeploymentBranchPolicy(ctx, owner, repoName, url.PathEscape(envName), int64(policyID), &updateData) diff --git a/github/resource_github_repository_file.go b/github/resource_github_repository_file.go index a80d60dbd7..ef8e34242a 100644 --- a/github/resource_github_repository_file.go +++ b/github/resource_github_repository_file.go @@ -141,23 +141,23 @@ func resourceGithubRepositoryFileOptions(d *schema.ResourceData) *github.Reposit } if branch, ok := d.GetOk("branch"); ok { - opts.Branch = github.Ptr(branch.(string)) + opts.Branch = new(branch.(string)) } if commitMessage, hasCommitMessage := d.GetOk("commit_message"); hasCommitMessage { - opts.Message = github.Ptr(commitMessage.(string)) + opts.Message = new(commitMessage.(string)) } if SHA, hasSHA := d.GetOk("sha"); hasSHA { - opts.SHA = github.Ptr(SHA.(string)) + opts.SHA = new(SHA.(string)) } commitAuthor, hasCommitAuthor := d.GetOk("commit_author") commitEmail, hasCommitEmail := d.GetOk("commit_email") if hasCommitAuthor && hasCommitEmail { - name := github.Ptr(commitAuthor.(string)) - mail := github.Ptr(commitEmail.(string)) + name := new(commitAuthor.(string)) + mail := new(commitEmail.(string)) opts.Author = &github.CommitAuthor{Name: name, Email: mail} opts.Committer = &github.CommitAuthor{Name: name, Email: mail} } @@ -207,7 +207,7 @@ func resourceGithubRepositoryFileCreate(ctx context.Context, d *schema.ResourceD opts := resourceGithubRepositoryFileOptions(d) if opts.Message == nil { - opts.Message = github.Ptr(fmt.Sprintf("Add %s", file)) + opts.Message = new(fmt.Sprintf("Add %s", file)) } tflog.Debug(ctx, "Checking if overwriting a repository file") @@ -379,7 +379,7 @@ func resourceGithubRepositoryFileUpdate(ctx context.Context, d *schema.ResourceD opts := resourceGithubRepositoryFileOptions(d) if *opts.Message == fmt.Sprintf("Add %s", file) { - opts.Message = github.Ptr(fmt.Sprintf("Update %s", file)) + opts.Message = new(fmt.Sprintf("Update %s", file)) } update, _, err := client.Repositories.UpdateFile(ctx, owner, repo, file, opts) @@ -412,11 +412,11 @@ func resourceGithubRepositoryFileDelete(ctx context.Context, d *schema.ResourceD opts := resourceGithubRepositoryFileOptions(d) if *opts.Message == fmt.Sprintf("Add %s", file) { - opts.Message = github.Ptr(fmt.Sprintf("Delete %s", file)) + opts.Message = new(fmt.Sprintf("Delete %s", file)) } branch := d.Get("branch").(string) - opts.Branch = github.Ptr(branch) + opts.Branch = new(branch) _, _, err := client.Repositories.DeleteFile(ctx, owner, repo, file, opts) return diag.FromErr(handleArchivedRepoDelete(err, "repository file", file, owner, repo)) diff --git a/github/resource_github_repository_milestone.go b/github/resource_github_repository_milestone.go index 48ff59e6cb..46c4f9af10 100644 --- a/github/resource_github_repository_milestone.go +++ b/github/resource_github_repository_milestone.go @@ -101,11 +101,11 @@ func resourceGithubRepositoryMilestoneCreate(d *schema.ResourceData, meta any) e repoName := d.Get("repository").(string) milestone := &github.Milestone{ - Title: github.Ptr(d.Get("title").(string)), + Title: new(d.Get("title").(string)), } if v, ok := d.GetOk("description"); ok && len(v.(string)) > 0 { - milestone.Description = github.Ptr(v.(string)) + milestone.Description = new(v.(string)) } if v, ok := d.GetOk("due_date"); ok && len(v.(string)) > 0 { dueDate, err := time.Parse(layoutISO, v.(string)) @@ -118,7 +118,7 @@ func resourceGithubRepositoryMilestoneCreate(d *schema.ResourceData, meta any) e } } if v, ok := d.GetOk("state"); ok && len(v.(string)) > 0 { - milestone.State = github.Ptr(v.(string)) + milestone.State = new(v.(string)) } milestone, _, err := conn.Issues.CreateMilestone(ctx, owner, repoName, milestone) @@ -193,12 +193,12 @@ func resourceGithubRepositoryMilestoneUpdate(d *schema.ResourceData, meta any) e milestone := &github.Milestone{} if d.HasChanges("title") { _, n := d.GetChange("title") - milestone.Title = github.Ptr(n.(string)) + milestone.Title = new(n.(string)) } if d.HasChanges("description") { _, n := d.GetChange("description") - milestone.Description = github.Ptr(n.(string)) + milestone.Description = new(n.(string)) } if d.HasChanges("due_date") { @@ -215,7 +215,7 @@ func resourceGithubRepositoryMilestoneUpdate(d *schema.ResourceData, meta any) e if d.HasChanges("state") { _, n := d.GetChange("state") - milestone.State = github.Ptr(n.(string)) + milestone.State = new(n.(string)) } _, _, err = conn.Issues.EditMilestone(ctx, owner, repoName, number, milestone) diff --git a/github/resource_github_repository_pull_request.go b/github/resource_github_repository_pull_request.go index 9fbaad7f46..785269ada4 100644 --- a/github/resource_github_repository_pull_request.go +++ b/github/resource_github_repository_pull_request.go @@ -159,11 +159,11 @@ func resourceGithubRepositoryPullRequestCreate(d *schema.ResourceData, meta any) } pullRequest, _, err := client.PullRequests.Create(ctx, baseOwner, baseRepository, &github.NewPullRequest{ - Title: github.Ptr(d.Get("title").(string)), - Head: github.Ptr(head), - Base: github.Ptr(d.Get("base_ref").(string)), - Body: github.Ptr(d.Get("body").(string)), - MaintainerCanModify: github.Ptr(d.Get("maintainer_can_modify").(bool)), + Title: new(d.Get("title").(string)), + Head: new(head), + Base: new(d.Get("base_ref").(string)), + Body: new(d.Get("body").(string)), + MaintainerCanModify: new(d.Get("maintainer_can_modify").(bool)), }) if err != nil { return err @@ -273,14 +273,14 @@ func resourceGithubRepositoryPullRequestUpdate(d *schema.ResourceData, meta any) } update := &github.PullRequest{ - Title: github.Ptr(d.Get("title").(string)), - Body: github.Ptr(d.Get("body").(string)), - MaintainerCanModify: github.Ptr(d.Get("maintainer_can_modify").(bool)), + Title: new(d.Get("title").(string)), + Body: new(d.Get("body").(string)), + MaintainerCanModify: new(d.Get("maintainer_can_modify").(bool)), } if d.HasChange("base_ref") { update.Base = &github.PullRequestBranch{ - Ref: github.Ptr(d.Get("base_ref").(string)), + Ref: new(d.Get("base_ref").(string)), } } @@ -316,7 +316,7 @@ func resourceGithubRepositoryPullRequestDelete(d *schema.ResourceData, meta any) return err } - update := &github.PullRequest{State: github.Ptr("closed")} + update := &github.PullRequest{State: new("closed")} if _, _, err = client.PullRequests.Edit(ctx, owner, repository, number, update); err != nil { return err } diff --git a/github/resource_github_repository_webhook.go b/github/resource_github_repository_webhook.go index 62fc0b878a..3bfb6eecba 100644 --- a/github/resource_github_repository_webhook.go +++ b/github/resource_github_repository_webhook.go @@ -180,7 +180,7 @@ func resourceGithubRepositoryWebhookRead(ctx context.Context, d *schema.Resource currentSecret := d.Get("configuration").([]any)[0].(map[string]any)["secret"] if hook.Config.Secret != nil { - hook.Config.Secret = github.Ptr(currentSecret.(string)) + hook.Config.Secret = new(currentSecret.(string)) } } diff --git a/github/resource_github_team.go b/github/resource_github_team.go index 6799dfd605..ddd54a7dc5 100644 --- a/github/resource_github_team.go +++ b/github/resource_github_team.go @@ -125,9 +125,9 @@ func resourceGithubTeamCreate(ctx context.Context, d *schema.ResourceData, meta newTeam := github.NewTeam{ Name: name, - Description: github.Ptr(d.Get("description").(string)), - Privacy: github.Ptr(d.Get("privacy").(string)), - NotificationSetting: github.Ptr(d.Get("notification_setting").(string)), + Description: new(d.Get("description").(string)), + Privacy: new(d.Get("privacy").(string)), + NotificationSetting: new(d.Get("notification_setting").(string)), } if ldapDN := d.Get("ldap_dn").(string); ldapDN != "" { @@ -318,9 +318,9 @@ func resourceGithubTeamUpdate(ctx context.Context, d *schema.ResourceData, meta editedTeam := github.NewTeam{ Name: d.Get("name").(string), - Description: github.Ptr(d.Get("description").(string)), - Privacy: github.Ptr(d.Get("privacy").(string)), - NotificationSetting: github.Ptr(d.Get("notification_setting").(string)), + Description: new(d.Get("description").(string)), + Privacy: new(d.Get("privacy").(string)), + NotificationSetting: new(d.Get("notification_setting").(string)), } if parentTeamID, ok := d.GetOk("parent_team_id"); ok { teamId, err := getTeamID(parentTeamID.(string), meta) @@ -346,7 +346,7 @@ func resourceGithubTeamUpdate(ctx context.Context, d *schema.ResourceData, meta if d.HasChange("ldap_dn") { ldapDN := d.Get("ldap_dn").(string) mapping := &github.TeamLDAPMapping{ - LDAPDN: github.Ptr(ldapDN), + LDAPDN: new(ldapDN), } _, _, err = client.Admin.UpdateTeamLDAPMapping(ctx, team.GetID(), mapping) if err != nil { diff --git a/github/resource_github_team_members.go b/github/resource_github_team_members.go index 5fb9697fb4..2734f3b14b 100644 --- a/github/resource_github_team_members.go +++ b/github/resource_github_team_members.go @@ -238,7 +238,7 @@ func resourceGithubTeamMembersRead(d *schema.ResourceData, meta any) error { if !q.Organization.Team.Members.PageInfo.HasNextPage { break } - variables["after"] = githubv4.NewString(q.Organization.Team.Members.PageInfo.EndCursor) + variables["after"] = new(q.Organization.Team.Members.PageInfo.EndCursor) } if err := d.Set("members", teamMembersAndMaintainers); err != nil { diff --git a/github/resource_github_team_settings.go b/github/resource_github_team_settings.go index eae86ace2a..505b45053e 100644 --- a/github/resource_github_team_settings.go +++ b/github/resource_github_team_settings.go @@ -164,8 +164,8 @@ func resourceGithubTeamSettingsUpdate(d *schema.ResourceData, meta any) error { ID: d.Id(), Enabled: githubv4.Boolean(true), Algorithm: &teamReviewAlgorithm, - TeamMemberCount: githubv4.NewInt(githubv4.Int(settings["member_count"].(int))), - NotifyTeam: githubv4.NewBoolean(githubv4.Boolean(settings["notify"].(bool))), + TeamMemberCount: new(githubv4.Int(settings["member_count"].(int))), + NotifyTeam: new(githubv4.Boolean(settings["notify"].(bool))), }, nil) } } diff --git a/github/resource_github_team_sync_group_mapping.go b/github/resource_github_team_sync_group_mapping.go index acdb454cf0..902ce3f1d4 100644 --- a/github/resource_github_team_sync_group_mapping.go +++ b/github/resource_github_team_sync_group_mapping.go @@ -201,9 +201,9 @@ func expandTeamSyncGroups(d *schema.ResourceData) *github.IDPGroupList { groupName := m["group_name"].(string) groupDescription := m["group_description"].(string) group := &github.IDPGroup{ - GroupID: github.Ptr(groupID), - GroupName: github.Ptr(groupName), - GroupDescription: github.Ptr(groupDescription), + GroupID: new(groupID), + GroupName: new(groupName), + GroupDescription: new(groupDescription), } groups = append(groups, group) } diff --git a/github/resource_github_user_ssh_key.go b/github/resource_github_user_ssh_key.go index fc18088227..cf9657fdab 100644 --- a/github/resource_github_user_ssh_key.go +++ b/github/resource_github_user_ssh_key.go @@ -59,8 +59,8 @@ func resourceGithubUserSshKeyCreate(d *schema.ResourceData, meta any) error { ctx := context.Background() userKey, _, err := client.Users.CreateKey(ctx, &github.Key{ - Title: github.Ptr(title), - Key: github.Ptr(key), + Title: new(title), + Key: new(key), }) if err != nil { return err diff --git a/github/resource_github_workflow_repository_permissions.go b/github/resource_github_workflow_repository_permissions.go index 9c4c88a6ec..f8036bb436 100644 --- a/github/resource_github_workflow_repository_permissions.go +++ b/github/resource_github_workflow_repository_permissions.go @@ -106,8 +106,8 @@ func resourceGithubWorkflowRepositoryPermissionsDelete(d *schema.ResourceData, m // Reset the repo to "default" settings repoWorkflowPermissions := github.DefaultWorkflowPermissionRepository{ - DefaultWorkflowPermissions: github.Ptr("read"), - CanApprovePullRequestReviews: github.Ptr(false), + DefaultWorkflowPermissions: new("read"), + CanApprovePullRequestReviews: new(false), } _, _, err := client.Repositories.UpdateDefaultWorkflowPermissions(ctx, diff --git a/github/transport_test.go b/github/transport_test.go index 6ee7a13c73..5b139d0cd2 100644 --- a/github/transport_test.go +++ b/github/transport_test.go @@ -48,7 +48,7 @@ func TestEtagTransport(t *testing.T) { } func githubApiMock(responseSequence []*mockResponse) *httptest.Server { - position := github.Ptr(0) + position := new(0) return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Server", "GitHub.com") @@ -106,7 +106,7 @@ func githubApiMock(responseSequence []*mockResponse) *httptest.Server { fmt.Fprintln(w, tc.ResponseBody) // Treat response as disposable - position = github.Ptr(i + 1) + position = new(i + 1) })) } @@ -232,8 +232,8 @@ func TestRateLimitTransport_abuseLimit_post(t *testing.T) { ctx := context.WithValue(context.Background(), ctxId, t.Name()) r, _, err := client.Repositories.Create(ctx, "tada", &github.Repository{ - Name: github.Ptr("radek-example-48"), - Description: github.Ptr(""), + Name: new("radek-example-48"), + Description: new(""), }) if err != nil { t.Fatal(err) @@ -292,8 +292,8 @@ func TestRateLimitTransport_abuseLimit_post_error(t *testing.T) { ctx := context.WithValue(context.Background(), ctxId, t.Name()) _, _, err := client.Repositories.Create(ctx, "tada", &github.Repository{ - Name: github.Ptr("radek-example-48"), - Description: github.Ptr(""), + Name: new("radek-example-48"), + Description: new(""), }) if err == nil { t.Fatal("Expected 422 error, got nil") @@ -425,8 +425,8 @@ func TestRetryTransport_retry_post_error(t *testing.T) { ctx := context.WithValue(context.Background(), ctxId, t.Name()) _, _, err := client.Repositories.Create(ctx, "tada", &github.Repository{ - Name: github.Ptr("radek-example-48"), - Description: github.Ptr(""), + Name: new("radek-example-48"), + Description: new(""), }) if err == nil { t.Fatal("Expected error not to be nil") @@ -488,8 +488,8 @@ func TestRetryTransport_retry_post_success(t *testing.T) { ctx := context.WithValue(context.Background(), ctxId, t.Name()) _, _, err := client.Repositories.Create(ctx, "tada", &github.Repository{ - Name: github.Ptr("radek-example-48"), - Description: github.Ptr(""), + Name: new("radek-example-48"), + Description: new(""), }) if err != nil { t.Fatalf("Expected error to be nil, got %v", err) diff --git a/github/util_rules.go b/github/util_rules.go index 71c08b2ea1..0c0c914a77 100644 --- a/github/util_rules.go +++ b/github/util_rules.go @@ -40,7 +40,7 @@ func expandRequiredReviewers(input []any) []*github.RulesetRequiredReviewer { reviewerData := rv[0].(map[string]any) reviewerType := github.RulesetReviewerType(reviewerData["type"].(string)) reviewer = &github.RulesetReviewer{ - ID: github.Ptr(int64(reviewerData["id"].(int))), + ID: new(int64(reviewerData["id"].(int))), Type: &reviewerType, } } @@ -53,7 +53,7 @@ func expandRequiredReviewers(input []any) []*github.RulesetRequiredReviewer { } reviewers = append(reviewers, &github.RulesetRequiredReviewer{ - MinimumApprovals: github.Ptr(reviewerMap["minimum_approvals"].(int)), + MinimumApprovals: new(reviewerMap["minimum_approvals"].(int)), FilePatterns: filePatterns, Reviewer: reviewer, }) @@ -144,7 +144,7 @@ func expandBypassActors(input []any) []*github.BypassActor { if actorID == 0 { actor.ActorID = nil } else { - actor.ActorID = github.Ptr(int64(actorID)) + actor.ActorID = new(int64(actorID)) } } @@ -404,7 +404,7 @@ func expandRules(input []any, org bool) *github.RepositoryRulesetRules { } if integrationID != 0 { - params.IntegrationID = github.Ptr(integrationID) + params.IntegrationID = new(integrationID) } requiredStatusChecks = append(requiredStatusChecks, params) @@ -470,9 +470,9 @@ func expandRules(input []any, org bool) *github.RepositoryRulesetRules { workflow := workflowMap.(map[string]any) params := &github.RuleWorkflow{ - RepositoryID: github.Ptr(toInt64(workflow["repository_id"])), + RepositoryID: new(toInt64(workflow["repository_id"])), Path: workflow["path"].(string), - Ref: github.Ptr(workflow["ref"].(string)), + Ref: new(workflow["ref"].(string)), } requiredWorkflows = append(requiredWorkflows, params) diff --git a/github/util_rules_test.go b/github/util_rules_test.go index d99e6e4589..190eaa1490 100644 --- a/github/util_rules_test.go +++ b/github/util_rules_test.go @@ -704,18 +704,18 @@ func TestFlattenRequiredReviewers(t *testing.T) { reviewerType := github.RulesetReviewerTypeTeam reviewers := []*github.RulesetRequiredReviewer{ { - MinimumApprovals: github.Ptr(2), + MinimumApprovals: new(2), FilePatterns: []string{"*.go", "src/**/*.ts"}, Reviewer: &github.RulesetReviewer{ - ID: github.Ptr(int64(12345)), + ID: new(int64(12345)), Type: &reviewerType, }, }, { - MinimumApprovals: github.Ptr(1), + MinimumApprovals: new(1), FilePatterns: []string{"docs/**/*.md"}, Reviewer: &github.RulesetReviewer{ - ID: github.Ptr(int64(67890)), + ID: new(int64(67890)), Type: &reviewerType, }, }, diff --git a/github/util_v4.go b/github/util_v4.go index e0f9ac1df5..d48af82733 100644 --- a/github/util_v4.go +++ b/github/util_v4.go @@ -46,7 +46,3 @@ func githubv4IDSliceEmpty(ss []string) []githubv4.ID { } return vGh4 } - -func githubv4NewStringSlice(v []githubv4.String) *[]githubv4.String { return &v } - -func githubv4NewIDSlice(v []githubv4.ID) *[]githubv4.ID { return &v } diff --git a/github/util_v4_branch_protection.go b/github/util_v4_branch_protection.go index 1109f7cd3f..5cf91536e5 100644 --- a/github/util_v4_branch_protection.go +++ b/github/util_v4_branch_protection.go @@ -597,7 +597,7 @@ func getBranchProtectionID(repoID githubv4.ID, pattern string, meta any) (github if !query.Node.Repository.BranchProtectionRules.PageInfo.HasNextPage { break } - variables["cursor"] = githubv4.NewString(query.Node.Repository.BranchProtectionRules.PageInfo.EndCursor) + variables["cursor"] = new(query.Node.Repository.BranchProtectionRules.PageInfo.EndCursor) } for i := range allRules { diff --git a/go.mod b/go.mod index b1090713c9..db7e4d8f94 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/integrations/terraform-provider-github/v6 -go 1.24.4 +go 1.26 require ( github.com/go-jose/go-jose/v3 v3.0.4