From 3e7f2ecf3a353a09e4500164cbe237a6462f2fb2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 8 Oct 2023 07:58:59 +0900 Subject: [PATCH] fix(deps): update module github.com/google/go-github/v53 to v55 (#890) * fix(deps): update module github.com/google/go-github/v53 to v55 * fix: address API breaking changes - https://github.com/google/go-github/pull/2822 * fix: stop using deprecated API github.NewEnterpriseClient --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Shunsuke Suzuki --- go.mod | 2 +- go.sum | 4 ++-- pkg/notifier/github/client.go | 4 ++-- pkg/notifier/github/comment.go | 2 +- pkg/notifier/github/commits.go | 7 ++----- pkg/notifier/github/github.go | 6 +++--- pkg/notifier/github/github_test.go | 8 ++++---- pkg/notifier/github/label.go | 2 +- 8 files changed, 16 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index e36252ff..3c1ab9a5 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/Masterminds/sprig/v3 v3.2.3 github.com/google/go-cmp v0.5.9 - github.com/google/go-github/v53 v53.2.0 + github.com/google/go-github/v55 v55.0.0 github.com/mattn/go-colorable v0.1.13 github.com/shurcooL/githubv4 v0.0.0-20201206200315-234843c633fa github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 44833659..c19ee939 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,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.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v53 v53.2.0 h1:wvz3FyF53v4BK+AsnvCmeNhf8AkTaeh2SoYu/XUvTtI= -github.com/google/go-github/v53 v53.2.0/go.mod h1:XhFRObz+m/l+UCm9b7KSIC3lT3NWSXGt7mOsAWEloao= +github.com/google/go-github/v55 v55.0.0 h1:4pp/1tNMB9X/LuAhs5i0KQAE40NmiR/y6prLNb9x9cg= +github.com/google/go-github/v55 v55.0.0/go.mod h1:JLahOTA1DnXzhxEymmFF5PP2tSS9JVNj68mSZNDwskA= 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/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/pkg/notifier/github/client.go b/pkg/notifier/github/client.go index 0eaae969..0f89c06c 100644 --- a/pkg/notifier/github/client.go +++ b/pkg/notifier/github/client.go @@ -6,7 +6,7 @@ import ( "os" "strings" - "github.com/google/go-github/v53/github" + "github.com/google/go-github/v55/github" "github.com/shurcooL/githubv4" "github.com/suzuki-shunsuke/tfcmt/v4/pkg/terraform" "golang.org/x/oauth2" @@ -95,7 +95,7 @@ func NewClient(ctx context.Context, cfg *Config) (*Client, error) { } if baseURL != "" { var err error - client, err = github.NewEnterpriseClient(baseURL, baseURL, tc) + client, err = github.NewClient(tc).WithEnterpriseURLs(baseURL, baseURL) if err != nil { return &Client{}, errors.New("failed to create a new github api client") } diff --git a/pkg/notifier/github/comment.go b/pkg/notifier/github/comment.go index d357d347..4d3b4c16 100644 --- a/pkg/notifier/github/comment.go +++ b/pkg/notifier/github/comment.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/google/go-github/v53/github" + "github.com/google/go-github/v55/github" "github.com/shurcooL/githubv4" ) diff --git a/pkg/notifier/github/commits.go b/pkg/notifier/github/commits.go index 2445867f..88251388 100644 --- a/pkg/notifier/github/commits.go +++ b/pkg/notifier/github/commits.go @@ -4,7 +4,7 @@ import ( "context" "errors" - "github.com/google/go-github/v53/github" + "github.com/google/go-github/v55/github" ) // CommitsService handles communication with the commits related @@ -20,10 +20,7 @@ const ( ) func (g *CommitsService) PRNumber(ctx context.Context, sha string, state PullRequestState) (int, error) { - prs, _, err := g.client.API.PullRequestsListPullRequestsWithCommit(ctx, sha, &github.PullRequestListOptions{ - State: string(state), - Sort: "updated", - }) + prs, _, err := g.client.API.PullRequestsListPullRequestsWithCommit(ctx, sha, &github.ListOptions{}) if err != nil { return 0, err } diff --git a/pkg/notifier/github/github.go b/pkg/notifier/github/github.go index d9c7be3f..b1c2c204 100644 --- a/pkg/notifier/github/github.go +++ b/pkg/notifier/github/github.go @@ -3,7 +3,7 @@ package github import ( "context" - "github.com/google/go-github/v53/github" + "github.com/google/go-github/v55/github" ) // API is GitHub API interface @@ -15,7 +15,7 @@ type API interface { IssuesRemoveLabel(ctx context.Context, number int, label string) (*github.Response, error) IssuesUpdateLabel(ctx context.Context, label, color string) (*github.Label, *github.Response, error) RepositoriesCreateComment(ctx context.Context, sha string, comment *github.RepositoryComment) (*github.RepositoryComment, *github.Response, error) - PullRequestsListPullRequestsWithCommit(ctx context.Context, sha string, opt *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) + PullRequestsListPullRequestsWithCommit(ctx context.Context, sha string, opt *github.ListOptions) ([]*github.PullRequest, *github.Response, error) } // GitHub represents the attribute information necessary for requesting GitHub API @@ -61,6 +61,6 @@ func (g *GitHub) RepositoriesCreateComment(ctx context.Context, sha string, comm return g.Client.Repositories.CreateComment(ctx, g.owner, g.repo, sha, comment) } -func (g *GitHub) PullRequestsListPullRequestsWithCommit(ctx context.Context, sha string, opt *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) { +func (g *GitHub) PullRequestsListPullRequestsWithCommit(ctx context.Context, sha string, opt *github.ListOptions) ([]*github.PullRequest, *github.Response, error) { return g.Client.PullRequests.ListPullRequestsWithCommit(ctx, g.owner, g.repo, sha, opt) } diff --git a/pkg/notifier/github/github_test.go b/pkg/notifier/github/github_test.go index 123cf4dd..8323ce52 100644 --- a/pkg/notifier/github/github_test.go +++ b/pkg/notifier/github/github_test.go @@ -3,7 +3,7 @@ package github import ( "context" - "github.com/google/go-github/v53/github" + "github.com/google/go-github/v55/github" "github.com/suzuki-shunsuke/tfcmt/v4/pkg/terraform" ) @@ -16,7 +16,7 @@ type fakeAPI struct { FakeRepositoriesCreateComment func(ctx context.Context, sha string, comment *github.RepositoryComment) (*github.RepositoryComment, *github.Response, error) FakeRepositoriesListCommits func(ctx context.Context, opt *github.CommitsListOptions) ([]*github.RepositoryCommit, *github.Response, error) FakeRepositoriesGetCommit func(ctx context.Context, sha string) (*github.RepositoryCommit, *github.Response, error) - FakePullRequestsListPullRequestsWithCommit func(ctx context.Context, sha string, opt *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) + FakePullRequestsListPullRequestsWithCommit func(ctx context.Context, sha string, opt *github.ListOptions) ([]*github.PullRequest, *github.Response, error) } func (g *fakeAPI) IssuesCreateComment(ctx context.Context, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error) { @@ -47,7 +47,7 @@ func (g *fakeAPI) RepositoriesGetCommit(ctx context.Context, sha string) (*githu return g.FakeRepositoriesGetCommit(ctx, sha) } -func (g *fakeAPI) PullRequestsListPullRequestsWithCommit(ctx context.Context, sha string, opt *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) { +func (g *fakeAPI) PullRequestsListPullRequestsWithCommit(ctx context.Context, sha string, opt *github.ListOptions) ([]*github.PullRequest, *github.Response, error) { return g.FakePullRequestsListPullRequestsWithCommit(ctx, sha, opt) } @@ -107,7 +107,7 @@ func newFakeAPI() fakeAPI { }, }, nil, nil }, - FakePullRequestsListPullRequestsWithCommit: func(ctx context.Context, sha string, opt *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) { + FakePullRequestsListPullRequestsWithCommit: func(ctx context.Context, sha string, opt *github.ListOptions) ([]*github.PullRequest, *github.Response, error) { return []*github.PullRequest{ { State: github.String("open"), diff --git a/pkg/notifier/github/label.go b/pkg/notifier/github/label.go index d6bd513f..ad5680c5 100644 --- a/pkg/notifier/github/label.go +++ b/pkg/notifier/github/label.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/google/go-github/v53/github" + "github.com/google/go-github/v55/github" "github.com/sirupsen/logrus" "github.com/suzuki-shunsuke/tfcmt/v4/pkg/terraform" )