Skip to content

Commit

Permalink
Merge pull request #32 from flant/add-github-primary-limits
Browse files Browse the repository at this point in the history
add github primary limits
  • Loading branch information
perhamm authored Nov 19, 2024
2 parents 99c5a47 + 2d69fc4 commit 1395206
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.23

- name: Build
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-bullseye as builder
FROM golang:1.23-bullseye as builder

ARG versionflags

Expand Down
2 changes: 1 addition & 1 deletion cmd/projects/branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/flant/glaball/pkg/limiter"
"github.com/flant/glaball/pkg/sort/v2"
"github.com/flant/glaball/pkg/util"
"github.com/google/go-github/v56/github"
"github.com/google/go-github/v66/github"
"github.com/hashicorp/go-hclog"
"github.com/spf13/cobra"
"github.com/xanzy/go-gitlab"
Expand Down
6 changes: 3 additions & 3 deletions cmd/projects/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/flant/glaball/pkg/client"
"github.com/flant/glaball/pkg/limiter"
"github.com/flant/glaball/pkg/sort/v2"
"github.com/google/go-github/v58/github"
"github.com/google/go-github/v66/github"
"gopkg.in/yaml.v3"

"github.com/flant/glaball/cmd/common"
Expand Down Expand Up @@ -239,7 +239,7 @@ func listProjectsFilesFromGithub(h *client.Host, filepath, ref string, re []*reg

ctx := context.TODO()
wg.Lock()
list, resp, err := h.GithubClient.Repositories.ListByOrg(ctx, h.Org, &opt)
list, resp, err := h.GithubClient.Repositories.ListByOrg(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org, &opt)
if err != nil {
if err != nil {
wg.Error(h, err)
Expand Down Expand Up @@ -304,7 +304,7 @@ func getRawFileFromGithub(h *client.Host, repository *github.Repository, filepat
// TODO:
ctx := context.TODO()
wg.Lock()
fileContent, _, resp, err := h.GithubClient.Repositories.GetContents(ctx,
fileContent, _, resp, err := h.GithubClient.Repositories.GetContents(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true),
repository.Owner.GetLogin(),
repository.GetName(),
filepath,
Expand Down
4 changes: 2 additions & 2 deletions cmd/projects/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/flant/glaball/pkg/limiter"
"github.com/flant/glaball/pkg/sort/v2"
"github.com/flant/glaball/pkg/util"
"github.com/google/go-github/v58/github"
"github.com/google/go-github/v66/github"

"github.com/flant/glaball/cmd/common"

Expand Down Expand Up @@ -350,7 +350,7 @@ func listProjects(h *client.Host, opt gitlab.ListProjectsOptions, wg *limiter.Li
// TODO:
if h.GithubClient != nil {
ctx := context.TODO()
list, resp, err := h.GithubClient.Repositories.ListByOrg(ctx, h.Org,
list, resp, err := h.GithubClient.Repositories.ListByOrg(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org,
&github.RepositoryListByOrgOptions{ListOptions: github.ListOptions{PerPage: 100}},
)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions cmd/projects/mr.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/flant/glaball/pkg/limiter"
"github.com/flant/glaball/pkg/sort/v2"
"github.com/flant/glaball/pkg/util"
"github.com/google/go-github/v58/github"
"github.com/google/go-github/v66/github"

"github.com/flant/glaball/cmd/common"

Expand Down Expand Up @@ -227,7 +227,7 @@ func listRepositories(h *client.Host, archived bool, opt github.RepositoryListBy

ctx := context.TODO()
wg.Lock()
list, resp, err := h.GithubClient.Repositories.ListByOrg(ctx, h.Org, &opt)
list, resp, err := h.GithubClient.Repositories.ListByOrg(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org, &opt)
if err != nil {
wg.Error(h, err)
wg.Unlock()
Expand Down Expand Up @@ -261,7 +261,7 @@ func listRepositoriesByNamespace(h *client.Host, namespaces []string, archived b

ctx := context.TODO()
wg.Lock()
list, resp, err := h.GithubClient.Repositories.ListByOrg(ctx, h.Org, &opt)
list, resp, err := h.GithubClient.Repositories.ListByOrg(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org, &opt)
if err != nil {
wg.Error(h, err)
wg.Unlock()
Expand Down Expand Up @@ -436,7 +436,7 @@ func listPullRequestsByAssigneeOrAuthorID(h *client.Host, repository *github.Rep

ctx := context.TODO()
wg.Lock()
list, resp, err := h.GithubClient.PullRequests.List(ctx, h.Org, repository.GetName(), &opt)
list, resp, err := h.GithubClient.PullRequests.List(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org, repository.GetName(), &opt)
if err != nil {
wg.Error(h, err)
wg.Unlock()
Expand Down Expand Up @@ -491,7 +491,7 @@ func listPullRequests(h *client.Host, repository *github.Repository, opt github.

ctx := context.TODO()
wg.Lock()
list, resp, err := h.GithubClient.PullRequests.List(ctx, h.Org, repository.GetName(), &opt)
list, resp, err := h.GithubClient.PullRequests.List(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org, repository.GetName(), &opt)
if err != nil {
wg.Error(h, err)
wg.Unlock()
Expand Down
8 changes: 4 additions & 4 deletions cmd/projects/schedules.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/flant/glaball/pkg/limiter"
"github.com/flant/glaball/pkg/sort/v2"
"github.com/flant/glaball/pkg/util"
"github.com/google/go-github/v58/github"
"github.com/google/go-github/v66/github"

"github.com/flant/glaball/cmd/common"

Expand Down Expand Up @@ -693,7 +693,7 @@ func listWorkflowRuns(h *client.Host, repository *github.Repository, opt github.

ctx := context.TODO()
wg.Lock()
list, resp, err := h.GithubClient.Actions.ListWorkflows(ctx, h.Org, repository.GetName(), &opt)
list, resp, err := h.GithubClient.Actions.ListWorkflows(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org, repository.GetName(), &opt)
if err != nil {
wg.Error(h, err)
wg.Unlock()
Expand Down Expand Up @@ -727,7 +727,7 @@ filter:
if withLastWorkflowRuns > 0 {
// get last workflow runs
wg.Lock()
runs, _, err = h.GithubClient.Actions.ListWorkflowRunsByID(ctx,
runs, _, err = h.GithubClient.Actions.ListWorkflowRunsByID(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true),
h.Org,
repository.GetName(),
v.GetID(),
Expand Down Expand Up @@ -764,7 +764,7 @@ filter:
var fileContent *github.RepositoryContent
if withFileContent {
wg.Lock()
fileContent, _, _, err = h.GithubClient.Repositories.GetContents(ctx,
fileContent, _, _, err = h.GithubClient.Repositories.GetContents(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true),
repository.Owner.GetLogin(),
repository.GetName(),
v.GetPath(),
Expand Down
45 changes: 21 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
module github.com/flant/glaball

go 1.21
go 1.23.3

require (
dario.cat/mergo v1.0.0
dario.cat/mergo v1.0.1
github.com/ahmetb/go-linq v3.0.0+incompatible
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b
github.com/armon/go-radix v1.0.0
github.com/gofri/go-github-ratelimit v1.1.0
github.com/google/go-github/v58 v58.0.0
github.com/google/go-github/v66 v66.0.0
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-hclog v1.6.2
github.com/hashicorp/go-retryablehttp v0.7.5
github.com/jmoiron/sqlx v1.3.5
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/jmoiron/sqlx v1.4.0
github.com/peterbourgon/diskv v2.0.1+incompatible
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
github.com/xanzy/go-gitlab v0.96.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/xanzy/go-gitlab v0.114.0
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -25,14 +27,15 @@ require (
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand All @@ -41,20 +44,14 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.16.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)

require (
github.com/armon/go-radix v1.0.0
github.com/google/btree v1.1.2 // indirect
github.com/stretchr/testify v1.8.4
golang.org/x/time v0.5.0 // indirect
)
Loading

0 comments on commit 1395206

Please sign in to comment.