diff --git a/e2e/github.go b/e2e/github.go index 5037b52e87..b86145d846 100644 --- a/e2e/github.go +++ b/e2e/github.go @@ -21,7 +21,7 @@ import ( "os/exec" "strings" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" ) type GithubClient struct { @@ -90,7 +90,7 @@ func (g GithubClient) CreateAtlantisWebhook(ctx context.Context, hookURL string) atlantisHook := &github.Hook{ Events: []string{"issue_comment", "pull_request", "push"}, Config: hookConfig, - Active: github.Bool(true), + Active: github.Ptr(true), } hook, _, err := g.client.Repositories.CreateHook(ctx, g.ownerName, g.repoName, atlantisHook) @@ -146,7 +146,7 @@ func (g GithubClient) GetAtlantisStatus(ctx context.Context, branchName string) func (g GithubClient) ClosePullRequest(ctx context.Context, pullRequestNumber int) error { // clean up - _, _, err := g.client.PullRequests.Edit(ctx, g.ownerName, g.repoName, pullRequestNumber, &github.PullRequest{State: github.String("closed")}) + _, _, err := g.client.PullRequests.Edit(ctx, g.ownerName, g.repoName, pullRequestNumber, &github.PullRequest{State: github.Ptr("closed")}) if err != nil { return fmt.Errorf("error while closing new pull request: %v", err) } diff --git a/e2e/go.mod b/e2e/go.mod index f3cdcc40c4..f600c3f52d 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -3,7 +3,7 @@ module github.com/runatlantis/atlantis/e2e go 1.23.4 require ( - github.com/google/go-github/v66 v66.0.0 + github.com/google/go-github/v68 v68.0.0 github.com/hashicorp/go-multierror v1.1.1 gitlab.com/gitlab-org/api/client-go v0.118.0 ) diff --git a/e2e/go.sum b/e2e/go.sum index 9b950972d6..825bce8d88 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -10,8 +10,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v66 v66.0.0 h1:ADJsaXj9UotwdgK8/iFZtv7MLc8E8WBl62WLd/D/9+M= -github.com/google/go-github/v66 v66.0.0/go.mod h1:+4SO9Zkuyf8ytMj0csN1NR/5OTR+MfqPp8P8dVlcvY4= +github.com/google/go-github/v68 v68.0.0 h1:ZW57zeNZiXTdQ16qrDiZ0k6XucrxZ2CGmoTvcCyQG6s= +github.com/google/go-github/v68 v68.0.0/go.mod h1:K9HAUBovM2sLwM408A18h+wd9vqdLOEqTUCbnRIcx68= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= diff --git a/go.mod b/go.mod index a3d9fd5609..458983b9a1 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/go-playground/validator/v10 v10.23.0 github.com/go-test/deep v1.1.1 github.com/golang-jwt/jwt/v5 v5.2.1 - github.com/google/go-github/v66 v66.0.0 + github.com/google/go-github/v68 v68.0.0 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.1 @@ -144,3 +144,6 @@ require ( google.golang.org/protobuf v1.36.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) + +// upstream pr to patch go-github to use v68, https://github.com/bradleyfalzon/ghinstallation/pull/137 +replace github.com/bradleyfalzon/ghinstallation/v2 => github.com/chenrui333/ghinstallation/v2 v2.12.1-0.20241231170237-36dcfb064b2f diff --git a/go.sum b/go.sum index 6b6ce265b0..65b17647c4 100644 --- a/go.sum +++ b/go.sum @@ -75,8 +75,6 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= -github.com/bradleyfalzon/ghinstallation/v2 v2.12.0 h1:k8oVjGhZel2qmCUsYwSE34jPNT9DL2wCBOtugsHv26g= -github.com/bradleyfalzon/ghinstallation/v2 v2.12.0/go.mod h1:V4gJcNyAftH0rXpRp1SUVUuh+ACxOH1xOk/ZzkRHltg= github.com/briandowns/spinner v1.23.1 h1:t5fDPmScwUjozhDj4FA46p5acZWIPXYE30qW2Ptu650= github.com/briandowns/spinner v1.23.1/go.mod h1:LaZeM4wm2Ywy6vO571mvhQNRcWfRUnXOs0RcKV0wYKM= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= @@ -92,6 +90,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chenrui333/ghinstallation/v2 v2.12.1-0.20241231170237-36dcfb064b2f h1:TN3fEfE18MJ+o3Y4PMUWu1S9IVYL7a82G3LVa8zJ7/c= +github.com/chenrui333/ghinstallation/v2 v2.12.1-0.20241231170237-36dcfb064b2f/go.mod h1:EJ6fgedVEHa2kUyBTTvslJCXJafS/mhJNNKEOCspZXQ= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -216,8 +216,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v66 v66.0.0 h1:ADJsaXj9UotwdgK8/iFZtv7MLc8E8WBl62WLd/D/9+M= -github.com/google/go-github/v66 v66.0.0/go.mod h1:+4SO9Zkuyf8ytMj0csN1NR/5OTR+MfqPp8P8dVlcvY4= +github.com/google/go-github/v68 v68.0.0 h1:ZW57zeNZiXTdQ16qrDiZ0k6XucrxZ2CGmoTvcCyQG6s= +github.com/google/go-github/v68 v68.0.0/go.mod h1:K9HAUBovM2sLwM408A18h+wd9vqdLOEqTUCbnRIcx68= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= diff --git a/server/controllers/events/events_controller.go b/server/controllers/events/events_controller.go index 57d5a8bb57..ba9dd1d5c0 100644 --- a/server/controllers/events/events_controller.go +++ b/server/controllers/events/events_controller.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/mcdafydd/go-azuredevops/azuredevops" "github.com/microcosm-cc/bluemonday" "github.com/pkg/errors" diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index a9d4fe70a1..2727dd2bac 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -13,7 +13,7 @@ import ( "strings" "testing" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock/v4" @@ -1695,26 +1695,26 @@ func GitHubPullRequestParsed(headSHA string) *github.PullRequest { headSHA = "13940d121be73f656e2132c6d7b4c8e87878ac8d" } return &github.PullRequest{ - Number: github.Int(2), - State: github.String("open"), - HTMLURL: github.String("htmlurl"), + Number: github.Ptr(2), + State: github.Ptr("open"), + HTMLURL: github.Ptr("htmlurl"), Head: &github.PullRequestBranch{ Repo: &github.Repository{ - FullName: github.String("runatlantis/atlantis-tests"), - CloneURL: github.String("https://github.com/runatlantis/atlantis-tests.git"), + FullName: github.Ptr("runatlantis/atlantis-tests"), + CloneURL: github.Ptr("https://github.com/runatlantis/atlantis-tests.git"), }, - SHA: github.String(headSHA), - Ref: github.String("branch"), + SHA: github.Ptr(headSHA), + Ref: github.Ptr("branch"), }, Base: &github.PullRequestBranch{ Repo: &github.Repository{ - FullName: github.String("runatlantis/atlantis-tests"), - CloneURL: github.String("https://github.com/runatlantis/atlantis-tests.git"), + FullName: github.Ptr("runatlantis/atlantis-tests"), + CloneURL: github.Ptr("https://github.com/runatlantis/atlantis-tests.git"), }, - Ref: github.String("main"), + Ref: github.Ptr("main"), }, User: &github.User{ - Login: github.String("atlantisbot"), + Login: github.Ptr("atlantisbot"), }, } } diff --git a/server/controllers/events/events_controller_test.go b/server/controllers/events/events_controller_test.go index ff68c1f77e..f4c563552c 100644 --- a/server/controllers/events/events_controller_test.go +++ b/server/controllers/events/events_controller_test.go @@ -25,7 +25,7 @@ import ( "strings" "testing" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/mcdafydd/go-azuredevops/azuredevops" . "github.com/petergtz/pegomock/v4" events_controllers "github.com/runatlantis/atlantis/server/controllers/events" diff --git a/server/controllers/events/github_request_validator.go b/server/controllers/events/github_request_validator.go index 89ae67e6b2..dc8b89f560 100644 --- a/server/controllers/events/github_request_validator.go +++ b/server/controllers/events/github_request_validator.go @@ -19,7 +19,7 @@ import ( "io" "net/http" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" ) //go:generate pegomock generate --package mocks -o mocks/mock_github_request_validator.go GithubRequestValidator diff --git a/server/events/apply_command_runner_test.go b/server/events/apply_command_runner_test.go index 6f713710f6..6ef5873c90 100644 --- a/server/events/apply_command_runner_test.go +++ b/server/events/apply_command_runner_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" . "github.com/petergtz/pegomock/v4" "github.com/runatlantis/atlantis/server/core/db" "github.com/runatlantis/atlantis/server/core/locking" @@ -54,7 +54,7 @@ func TestApplyCommandRunner_IsLocked(t *testing.T) { scopeNull, _, _ := metrics.NewLoggingScope(logger, "atlantis") pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(logger, testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) @@ -475,7 +475,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) { scopeNull, _, _ := metrics.NewLoggingScope(logger, "atlantis") pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} diff --git a/server/events/command_runner.go b/server/events/command_runner.go index dbc2e7e99b..fd544baabf 100644 --- a/server/events/command_runner.go +++ b/server/events/command_runner.go @@ -17,7 +17,7 @@ import ( "fmt" "strconv" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/mcdafydd/go-azuredevops/azuredevops" "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/core/config/valid" diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go index 8764c08bea..cd9cbc10e4 100644 --- a/server/events/command_runner_test.go +++ b/server/events/command_runner_test.go @@ -27,7 +27,7 @@ import ( "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/metrics" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" . "github.com/petergtz/pegomock/v4" lockingmocks "github.com/runatlantis/atlantis/server/core/locking/mocks" "github.com/runatlantis/atlantis/server/events" @@ -506,7 +506,7 @@ func TestRunCommentCommand_DisableApplyAllDisabled(t *testing.T) { vcsClient := setup(t) applyCommandRunner.DisableApplyAll = true pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil) @@ -594,7 +594,7 @@ func TestRunCommentCommand_ClosedPull(t *testing.T) { " comment saying that this is not allowed") vcsClient := setup(t) pull := &github.PullRequest{ - State: github.String("closed"), + State: github.Ptr("closed"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.ClosedPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil) @@ -647,12 +647,12 @@ func TestRunUnlockCommand_VCSComment(t *testing.T) { }{ { name: "PR open", - prState: github.String("open"), + prState: github.Ptr("open"), }, { name: "PR closed", - prState: github.String("closed"), + prState: github.Ptr("closed"), }, } @@ -689,7 +689,7 @@ func TestRunUnlockCommandFail_VCSComment(t *testing.T) { vcsClient := setup(t) pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), @@ -713,7 +713,7 @@ func TestRunUnlockCommandFail_DisableUnlockLabel(t *testing.T) { vcsClient := setup(t) pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), @@ -737,7 +737,7 @@ func TestRunUnlockCommandFail_GetLabelsFail(t *testing.T) { vcsClient := setup(t) pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), @@ -763,7 +763,7 @@ func TestRunUnlockCommandDoesntRetrieveLabelsIfDisableUnlockLabelNotSet(t *testi vcsClient := setup(t) pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), @@ -865,7 +865,7 @@ func TestRunCommentCommand_FailedPreWorkflowHook_FailOnPreWorkflowHookError_Fals When(projectCommandRunner.Plan(Any[command.ProjectContext]())).ThenReturn(command.ProjectResult{PlanSuccess: &models.PlanSuccess{}}) When(workingDir.GetPullDir(Any[models.Repo](), Any[models.PullRequest]())).ThenReturn(tmp, nil) - pull := &github.PullRequest{State: github.String("open")} + pull := &github.PullRequest{State: github.Ptr("open")} modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil) When(eventParsing.ParseGithubPull(Any[logging.SimpleLogging](), Eq(pull))).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) @@ -907,7 +907,7 @@ func TestRunGenericPlanCommand_DeletePlans(t *testing.T) { When(projectCommandRunner.Plan(Any[command.ProjectContext]())).ThenReturn(command.ProjectResult{PlanSuccess: &models.PlanSuccess{}}) When(workingDir.GetPullDir(Any[models.Repo](), Any[models.PullRequest]())).ThenReturn(tmp, nil) - pull := &github.PullRequest{State: github.String("open")} + pull := &github.PullRequest{State: github.Ptr("open")} modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil) When(eventParsing.ParseGithubPull(Any[logging.SimpleLogging](), Eq(pull))).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) @@ -1001,7 +1001,7 @@ func TestRunGenericPlanCommand_DiscardApprovals(t *testing.T) { When(projectCommandRunner.Plan(Any[command.ProjectContext]())).ThenReturn(command.ProjectResult{PlanSuccess: &models.PlanSuccess{}}) When(workingDir.GetPullDir(Any[models.Repo](), Any[models.PullRequest]())).ThenReturn(tmp, nil) - pull := &github.PullRequest{State: github.String("open")} + pull := &github.PullRequest{State: github.Ptr("open")} modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil) When(eventParsing.ParseGithubPull(Any[logging.SimpleLogging](), Eq(pull))).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) @@ -1025,7 +1025,7 @@ func TestFailedApprovalCreatesFailedStatusUpdate(t *testing.T) { defer func() { autoMerger.GlobalAutomerge = false }() pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{ @@ -1071,7 +1071,7 @@ func TestApprovedPoliciesUpdateFailedPolicyStatus(t *testing.T) { defer func() { autoMerger.GlobalAutomerge = false }() pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{ @@ -1127,7 +1127,7 @@ func TestApplyMergeablityWhenPolicyCheckFails(t *testing.T) { defer func() { autoMerger.GlobalAutomerge = false }() pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{ @@ -1174,7 +1174,7 @@ func TestApplyWithAutoMerge_VSCMerge(t *testing.T) { vcsClient := setup(t) pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState} When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(pull, nil) @@ -1217,7 +1217,7 @@ func TestRunApply_DiscardedProjects(t *testing.T) { Ok(t, err) Ok(t, boltDB.UpdateProjectStatus(pull, "default", ".", models.DiscardedPlanStatus)) ghPull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } When(githubGetter.GetPullRequest(Any[logging.SimpleLogging](), Eq(testdata.GithubRepo), Eq(testdata.Pull.Num))).ThenReturn(ghPull, nil) When(eventParsing.ParseGithubPull(Any[logging.SimpleLogging](), Eq(ghPull))).ThenReturn(pull, pull.BaseRepo, testdata.GithubRepo, nil) diff --git a/server/events/event_parser.go b/server/events/event_parser.go index e96b65ac72..c9cae1c828 100644 --- a/server/events/event_parser.go +++ b/server/events/event_parser.go @@ -24,7 +24,7 @@ import ( giteasdk "code.gitea.io/sdk/gitea" "github.com/go-playground/validator/v10" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" lru "github.com/hashicorp/golang-lru/v2" "github.com/mcdafydd/go-azuredevops/azuredevops" "github.com/pkg/errors" diff --git a/server/events/event_parser_test.go b/server/events/event_parser_test.go index 648807c742..27515be71d 100644 --- a/server/events/event_parser_test.go +++ b/server/events/event_parser_test.go @@ -21,7 +21,7 @@ import ( "strings" "testing" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/mcdafydd/go-azuredevops/azuredevops" "github.com/mohae/deepcopy" "github.com/runatlantis/atlantis/server/events" @@ -68,12 +68,12 @@ func TestParseGithubIssueCommentEvent(t *testing.T) { comment := github.IssueCommentEvent{ Repo: &Repo, Issue: &github.Issue{ - Number: github.Int(1), - User: &github.User{Login: github.String("issue_user")}, - HTMLURL: github.String("https://github.com/runatlantis/atlantis/issues/1"), + Number: github.Ptr(1), + User: &github.User{Login: github.Ptr("issue_user")}, + HTMLURL: github.Ptr("https://github.com/runatlantis/atlantis/issues/1"), }, Comment: &github.IssueComment{ - User: &github.User{Login: github.String("comment_user")}, + User: &github.User{Login: github.Ptr("comment_user")}, }, } @@ -170,8 +170,8 @@ func TestParseGithubPullEventFromDraft(t *testing.T) { logger := logging.NewNoopLogger(t) // verify that close event treated as 'close' events by default closeEvent := deepcopy.Copy(PullEvent).(github.PullRequestEvent) - closeEvent.Action = github.String("closed") - closeEvent.PullRequest.Draft = github.Bool(true) + closeEvent.Action = github.Ptr("closed") + closeEvent.PullRequest.Draft = github.Ptr(true) _, evType, _, _, _, err := parser.ParseGithubPullEvent(logger, &closeEvent) Ok(t, err) @@ -179,7 +179,7 @@ func TestParseGithubPullEventFromDraft(t *testing.T) { // verify that draft PRs are treated as 'other' events by default testEvent := deepcopy.Copy(PullEvent).(github.PullRequestEvent) - testEvent.PullRequest.Draft = github.Bool(true) + testEvent.PullRequest.Draft = github.Ptr(true) _, evType, _, _, _, err = parser.ParseGithubPullEvent(logger, &testEvent) Ok(t, err) Equals(t, models.OtherPullEvent, evType) diff --git a/server/events/mocks/mock_event_parsing.go b/server/events/mocks/mock_event_parsing.go index 8732cadc1d..e6b72acacd 100644 --- a/server/events/mocks/mock_event_parsing.go +++ b/server/events/mocks/mock_event_parsing.go @@ -5,7 +5,7 @@ package mocks import ( gitea "code.gitea.io/sdk/gitea" - github "github.com/google/go-github/v66/github" + github "github.com/google/go-github/v68/github" azuredevops "github.com/mcdafydd/go-azuredevops/azuredevops" pegomock "github.com/petergtz/pegomock/v4" models "github.com/runatlantis/atlantis/server/events/models" diff --git a/server/events/mocks/mock_github_pull_getter.go b/server/events/mocks/mock_github_pull_getter.go index c904e371e4..c2be8a5fb3 100644 --- a/server/events/mocks/mock_github_pull_getter.go +++ b/server/events/mocks/mock_github_pull_getter.go @@ -4,7 +4,7 @@ package mocks import ( - github "github.com/google/go-github/v66/github" + github "github.com/google/go-github/v68/github" pegomock "github.com/petergtz/pegomock/v4" models "github.com/runatlantis/atlantis/server/events/models" logging "github.com/runatlantis/atlantis/server/logging" diff --git a/server/events/plan_command_runner_test.go b/server/events/plan_command_runner_test.go index c0085dc963..b1da0012e1 100644 --- a/server/events/plan_command_runner_test.go +++ b/server/events/plan_command_runner_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" . "github.com/petergtz/pegomock/v4" "github.com/runatlantis/atlantis/server/core/db" "github.com/runatlantis/atlantis/server/events" @@ -472,7 +472,7 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) { scopeNull, _, _ := metrics.NewLoggingScope(logger, "atlantis") pull := &github.PullRequest{ - State: github.String("open"), + State: github.Ptr("open"), } modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} diff --git a/server/events/vcs/github_client.go b/server/events/vcs/github_client.go index 1000f73e07..9d13bb2587 100644 --- a/server/events/vcs/github_client.go +++ b/server/events/vcs/github_client.go @@ -25,7 +25,7 @@ import ( "strings" "time" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/models" @@ -268,8 +268,8 @@ func (g *GithubClient) HidePrevCommandComments(logger logging.SimpleLogging, rep nextPage := 0 for { comments, resp, err := g.client.Issues.ListComments(g.ctx, repo.Owner, repo.Name, pullNum, &github.IssueListCommentsOptions{ - Sort: github.String("created"), - Direction: github.String("asc"), + Sort: github.Ptr("created"), + Direction: github.Ptr("asc"), ListOptions: github.ListOptions{Page: nextPage}, }) if resp != nil { @@ -913,9 +913,9 @@ func (g *GithubClient) UpdateStatus(logger logging.SimpleLogging, repo models.Re logger.Info("Updating GitHub Check status for '%s' to '%s'", src, ghState) status := &github.RepoStatus{ - State: github.String(ghState), - Description: github.String(description), - Context: github.String(src), + State: github.Ptr(ghState), + Description: github.Ptr(description), + Context: github.Ptr(src), TargetURL: &url, } _, resp, err := g.client.Repositories.CreateStatus(g.ctx, repo.Owner, repo.Name, pull.HeadCommit, status) diff --git a/server/events/vcs/github_credentials.go b/server/events/vcs/github_credentials.go index e46b0e3c2c..ad6fadda61 100644 --- a/server/events/vcs/github_credentials.go +++ b/server/events/vcs/github_credentials.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/bradleyfalzon/ghinstallation/v2" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/pkg/errors" ) diff --git a/server/events/vcs/instrumented_client.go b/server/events/vcs/instrumented_client.go index adc0ca0abc..d5d5809d9c 100644 --- a/server/events/vcs/instrumented_client.go +++ b/server/events/vcs/instrumented_client.go @@ -3,7 +3,7 @@ package vcs import ( "strconv" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/metrics" diff --git a/server/events/vcs/mocks/mock_github_pull_request_getter.go b/server/events/vcs/mocks/mock_github_pull_request_getter.go index f8a809e44f..ad5670ca14 100644 --- a/server/events/vcs/mocks/mock_github_pull_request_getter.go +++ b/server/events/vcs/mocks/mock_github_pull_request_getter.go @@ -4,7 +4,7 @@ package mocks import ( - github "github.com/google/go-github/v66/github" + github "github.com/google/go-github/v68/github" pegomock "github.com/petergtz/pegomock/v4" models "github.com/runatlantis/atlantis/server/events/models" logging "github.com/runatlantis/atlantis/server/logging" diff --git a/server/events/vcs/testdata/fixtures.go b/server/events/vcs/testdata/fixtures.go index db17101876..aa18059bac 100644 --- a/server/events/vcs/testdata/fixtures.go +++ b/server/events/vcs/testdata/fixtures.go @@ -22,43 +22,43 @@ import ( "testing" "github.com/golang-jwt/jwt/v5" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/mcdafydd/go-azuredevops/azuredevops" ) var PullEvent = github.PullRequestEvent{ Sender: &github.User{ - Login: github.String("user"), + Login: github.Ptr("user"), }, Repo: &Repo, PullRequest: &Pull, - Action: github.String("opened"), + Action: github.Ptr("opened"), } var Pull = github.PullRequest{ Head: &github.PullRequestBranch{ - SHA: github.String("sha256"), - Ref: github.String("ref"), + SHA: github.Ptr("sha256"), + Ref: github.Ptr("ref"), Repo: &Repo, }, Base: &github.PullRequestBranch{ - SHA: github.String("sha256"), + SHA: github.Ptr("sha256"), Repo: &Repo, - Ref: github.String("basebranch"), + Ref: github.Ptr("basebranch"), }, - HTMLURL: github.String("html-url"), + HTMLURL: github.Ptr("html-url"), User: &github.User{ - Login: github.String("user"), + Login: github.Ptr("user"), }, - Number: github.Int(1), - State: github.String("open"), + Number: github.Ptr(1), + State: github.Ptr("open"), } var Repo = github.Repository{ - FullName: github.String("owner/repo"), - Owner: &github.User{Login: github.String("owner")}, - Name: github.String("repo"), - CloneURL: github.String("https://github.com/owner/repo.git"), + FullName: github.Ptr("owner/repo"), + Owner: &github.User{Login: github.Ptr("owner")}, + Name: github.Ptr("repo"), + CloneURL: github.Ptr("https://github.com/owner/repo.git"), } var ADPullEvent = azuredevops.Event{ diff --git a/testdrive/github.go b/testdrive/github.go index a56d3eee35..4fc8279678 100644 --- a/testdrive/github.go +++ b/testdrive/github.go @@ -18,7 +18,7 @@ import ( "strings" "time" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" ) var githubUsername string @@ -57,13 +57,13 @@ func (g *Client) CheckForkSuccess(ownerName string, forkRepoName string) bool { func (g *Client) CreateWebhook(ownerName string, repoName string, hookURL string) error { contentType := "json" hookConfig := &github.HookConfig{ - ContentType: &contentType, - URL: &hookURL, + ContentType: github.Ptr(contentType), + URL: github.Ptr(hookURL), } atlantisHook := &github.Hook{ Events: []string{"issue_comment", "pull_request", "pull_request_review", "push"}, Config: hookConfig, - Active: github.Bool(true), + Active: github.Ptr(true), } _, _, err := g.client.Repositories.CreateHook(g.ctx, ownerName, repoName, atlantisHook) return err @@ -87,10 +87,10 @@ func (g *Client) CreatePullRequest(ownerName string, repoName string, head strin // If not, create it. newPullRequest := &github.NewPullRequest{ - Title: github.String("Welcome to Atlantis!"), - Head: github.String(head), - Body: github.String(pullRequestBody), - Base: github.String(base), + Title: github.Ptr("Welcome to Atlantis!"), + Head: github.Ptr(head), + Body: github.Ptr(pullRequestBody), + Base: github.Ptr(base), } pull, _, err := g.client.PullRequests.Create(g.ctx, ownerName, repoName, newPullRequest) if err != nil { diff --git a/testdrive/testdrive.go b/testdrive/testdrive.go index 6847540fc0..9f2b61c6c7 100644 --- a/testdrive/testdrive.go +++ b/testdrive/testdrive.go @@ -31,7 +31,7 @@ import ( "time" "github.com/briandowns/spinner" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v68/github" "github.com/mitchellh/colorstring" "github.com/pkg/errors" )