Skip to content

Commit 1395206

Browse files
authored
Merge pull request #32 from flant/add-github-primary-limits
add github primary limits
2 parents 99c5a47 + 2d69fc4 commit 1395206

File tree

10 files changed

+84
-88
lines changed

10 files changed

+84
-88
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@v5
1818
with:
19-
go-version: 1.21
19+
go-version: 1.23
2020

2121
- name: Build
2222
run: |

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21-bullseye as builder
1+
FROM golang:1.23-bullseye as builder
22

33
ARG versionflags
44

cmd/projects/branches.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/flant/glaball/pkg/limiter"
1212
"github.com/flant/glaball/pkg/sort/v2"
1313
"github.com/flant/glaball/pkg/util"
14-
"github.com/google/go-github/v56/github"
14+
"github.com/google/go-github/v66/github"
1515
"github.com/hashicorp/go-hclog"
1616
"github.com/spf13/cobra"
1717
"github.com/xanzy/go-gitlab"

cmd/projects/files.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/flant/glaball/pkg/client"
1414
"github.com/flant/glaball/pkg/limiter"
1515
"github.com/flant/glaball/pkg/sort/v2"
16-
"github.com/google/go-github/v58/github"
16+
"github.com/google/go-github/v66/github"
1717
"gopkg.in/yaml.v3"
1818

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

240240
ctx := context.TODO()
241241
wg.Lock()
242-
list, resp, err := h.GithubClient.Repositories.ListByOrg(ctx, h.Org, &opt)
242+
list, resp, err := h.GithubClient.Repositories.ListByOrg(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org, &opt)
243243
if err != nil {
244244
if err != nil {
245245
wg.Error(h, err)
@@ -304,7 +304,7 @@ func getRawFileFromGithub(h *client.Host, repository *github.Repository, filepat
304304
// TODO:
305305
ctx := context.TODO()
306306
wg.Lock()
307-
fileContent, _, resp, err := h.GithubClient.Repositories.GetContents(ctx,
307+
fileContent, _, resp, err := h.GithubClient.Repositories.GetContents(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true),
308308
repository.Owner.GetLogin(),
309309
repository.GetName(),
310310
filepath,

cmd/projects/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/flant/glaball/pkg/limiter"
1414
"github.com/flant/glaball/pkg/sort/v2"
1515
"github.com/flant/glaball/pkg/util"
16-
"github.com/google/go-github/v58/github"
16+
"github.com/google/go-github/v66/github"
1717

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

@@ -350,7 +350,7 @@ func listProjects(h *client.Host, opt gitlab.ListProjectsOptions, wg *limiter.Li
350350
// TODO:
351351
if h.GithubClient != nil {
352352
ctx := context.TODO()
353-
list, resp, err := h.GithubClient.Repositories.ListByOrg(ctx, h.Org,
353+
list, resp, err := h.GithubClient.Repositories.ListByOrg(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org,
354354
&github.RepositoryListByOrgOptions{ListOptions: github.ListOptions{PerPage: 100}},
355355
)
356356
if err != nil {

cmd/projects/mr.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/flant/glaball/pkg/limiter"
1212
"github.com/flant/glaball/pkg/sort/v2"
1313
"github.com/flant/glaball/pkg/util"
14-
"github.com/google/go-github/v58/github"
14+
"github.com/google/go-github/v66/github"
1515

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

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

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

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

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

492492
ctx := context.TODO()
493493
wg.Lock()
494-
list, resp, err := h.GithubClient.PullRequests.List(ctx, h.Org, repository.GetName(), &opt)
494+
list, resp, err := h.GithubClient.PullRequests.List(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org, repository.GetName(), &opt)
495495
if err != nil {
496496
wg.Error(h, err)
497497
wg.Unlock()

cmd/projects/schedules.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/flant/glaball/pkg/limiter"
1616
"github.com/flant/glaball/pkg/sort/v2"
1717
"github.com/flant/glaball/pkg/util"
18-
"github.com/google/go-github/v58/github"
18+
"github.com/google/go-github/v66/github"
1919

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

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

694694
ctx := context.TODO()
695695
wg.Lock()
696-
list, resp, err := h.GithubClient.Actions.ListWorkflows(ctx, h.Org, repository.GetName(), &opt)
696+
list, resp, err := h.GithubClient.Actions.ListWorkflows(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), h.Org, repository.GetName(), &opt)
697697
if err != nil {
698698
wg.Error(h, err)
699699
wg.Unlock()
@@ -727,7 +727,7 @@ filter:
727727
if withLastWorkflowRuns > 0 {
728728
// get last workflow runs
729729
wg.Lock()
730-
runs, _, err = h.GithubClient.Actions.ListWorkflowRunsByID(ctx,
730+
runs, _, err = h.GithubClient.Actions.ListWorkflowRunsByID(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true),
731731
h.Org,
732732
repository.GetName(),
733733
v.GetID(),
@@ -764,7 +764,7 @@ filter:
764764
var fileContent *github.RepositoryContent
765765
if withFileContent {
766766
wg.Lock()
767-
fileContent, _, _, err = h.GithubClient.Repositories.GetContents(ctx,
767+
fileContent, _, _, err = h.GithubClient.Repositories.GetContents(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true),
768768
repository.Owner.GetLogin(),
769769
repository.GetName(),
770770
v.GetPath(),

go.mod

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
module github.com/flant/glaball
22

3-
go 1.21
3+
go 1.23.3
44

55
require (
6-
dario.cat/mergo v1.0.0
6+
dario.cat/mergo v1.0.1
77
github.com/ahmetb/go-linq v3.0.0+incompatible
8-
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9
8+
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b
9+
github.com/armon/go-radix v1.0.0
910
github.com/gofri/go-github-ratelimit v1.1.0
10-
github.com/google/go-github/v58 v58.0.0
11+
github.com/google/go-github/v66 v66.0.0
1112
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
1213
github.com/hashicorp/go-cleanhttp v0.5.2
13-
github.com/hashicorp/go-hclog v1.6.2
14-
github.com/hashicorp/go-retryablehttp v0.7.5
15-
github.com/jmoiron/sqlx v1.3.5
14+
github.com/hashicorp/go-hclog v1.6.3
15+
github.com/hashicorp/go-retryablehttp v0.7.7
16+
github.com/jmoiron/sqlx v1.4.0
1617
github.com/peterbourgon/diskv v2.0.1+incompatible
17-
github.com/spf13/cobra v1.8.0
18-
github.com/spf13/viper v1.18.2
19-
github.com/xanzy/go-gitlab v0.96.0
18+
github.com/spf13/cobra v1.8.1
19+
github.com/spf13/viper v1.19.0
20+
github.com/stretchr/testify v1.9.0
21+
github.com/xanzy/go-gitlab v0.114.0
2022
gopkg.in/yaml.v3 v3.0.1
2123
)
2224

@@ -25,14 +27,15 @@ require (
2527
github.com/fatih/color v1.16.0 // indirect
2628
github.com/fsnotify/fsnotify v1.7.0 // indirect
2729
github.com/golang/protobuf v1.5.3 // indirect
30+
github.com/google/btree v1.1.3 // indirect
2831
github.com/google/go-querystring v1.1.0 // indirect
2932
github.com/hashicorp/hcl v1.0.0 // indirect
3033
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3134
github.com/magiconair/properties v1.8.7 // indirect
3235
github.com/mattn/go-colorable v0.1.13 // indirect
3336
github.com/mattn/go-isatty v0.0.20 // indirect
3437
github.com/mitchellh/mapstructure v1.5.0 // indirect
35-
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
38+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
3639
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
3740
github.com/sagikazarmark/locafero v0.4.0 // indirect
3841
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
@@ -41,20 +44,14 @@ require (
4144
github.com/spf13/cast v1.6.0 // indirect
4245
github.com/spf13/pflag v1.0.5 // indirect
4346
github.com/subosito/gotenv v1.6.0 // indirect
44-
go.uber.org/multierr v1.11.0 // indirect
45-
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
46-
golang.org/x/oauth2 v0.16.0 // indirect
47-
golang.org/x/sys v0.16.0 // indirect
47+
go.uber.org/atomic v1.9.0 // indirect
48+
go.uber.org/multierr v1.9.0 // indirect
49+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
50+
golang.org/x/oauth2 v0.18.0 // indirect
51+
golang.org/x/sys v0.20.0 // indirect
4852
golang.org/x/text v0.14.0 // indirect
53+
golang.org/x/time v0.5.0 // indirect
4954
google.golang.org/appengine v1.6.8 // indirect
50-
google.golang.org/protobuf v1.32.0 // indirect
51-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
55+
google.golang.org/protobuf v1.33.0 // indirect
5256
gopkg.in/ini.v1 v1.67.0 // indirect
5357
)
54-
55-
require (
56-
github.com/armon/go-radix v1.0.0
57-
github.com/google/btree v1.1.2 // indirect
58-
github.com/stretchr/testify v1.8.4
59-
golang.org/x/time v0.5.0 // indirect
60-
)

0 commit comments

Comments
 (0)