Skip to content

Commit

Permalink
fix(deps): update module github.com/google/go-github/v53 to v55 (#890)
Browse files Browse the repository at this point in the history
* fix(deps): update module github.com/google/go-github/v53 to v55

* fix: address API breaking changes

- google/go-github#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 <suzuki.shunsuke.1989@gmail.com>
  • Loading branch information
renovate[bot] and suzuki-shunsuke committed Oct 7, 2023
1 parent 6a4db81 commit 3e7f2ec
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions pkg/notifier/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/notifier/github/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
7 changes: 2 additions & 5 deletions pkg/notifier/github/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/notifier/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
8 changes: 4 additions & 4 deletions pkg/notifier/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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) {
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion pkg/notifier/github/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down

0 comments on commit 3e7f2ec

Please sign in to comment.