Skip to content

Commit

Permalink
upstreams/github: Add note about using GitHub client from k/release
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Augustus <saugustus@vmware.com>
  • Loading branch information
justaugustus committed Sep 6, 2020
1 parent e413356 commit 77b54f3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions upstreams/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,19 @@ type Github struct {
Constraints string
}

// TODO: Consider reusing the kubernetes/release GitHub client here instead
func getClient() *github.Client {
var client *github.Client

accessToken := os.Getenv("GITHUB_ACCESS_TOKEN")
if accessToken != "" {
log.Debugf("GitHub Access Token provided")
log.Debugf("GitHub access token provided")

ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: accessToken})
tc := oauth2.NewClient(context.Background(), ts)
client = github.NewClient(tc)
} else {
log.Warnf(
`No GitHub Access Token provided, might run into API limits.
Set an access token with the GITHUB_ACCESS_TOKEN env var.`,
)
log.Warnf("Set the GITHUB_ACCESS_TOKEN env var to avoid API limits")
client = github.NewClient(nil)
}

Expand Down

0 comments on commit 77b54f3

Please sign in to comment.