Skip to content

Commit

Permalink
Extract getPullRequests()
Browse files Browse the repository at this point in the history
  • Loading branch information
chaspy committed Jan 24, 2021
1 parent ff29575 commit e3773df
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,9 @@ func run() error {
return fmt.Errorf("failed to read Datadog Config: %w", err)
}

ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: githubToken},
)
ctx := context.Background()
tc := oauth2.NewClient(ctx, ts)

client := github.NewClient(tc)

prs, _, err := client.PullRequests.List(ctx, "quipper", "kubernetes-clusters", nil)
prs, err := getPullRequests(githubToken)
if err != nil {
return fmt.Errorf("failed to get GitHub Pull Requests: %w", err)
return fmt.Errorf("failed to get PullRequests: %w", err)
}

prInfos := []PR{}
Expand Down Expand Up @@ -142,3 +134,20 @@ func readGithubConfig() (string, error) {

return githubToken, nil
}

func getPullRequests(githubToken string) ([]*github.PullRequest,error){
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: githubToken},
)
ctx := context.Background()
tc := oauth2.NewClient(ctx, ts)

client := github.NewClient(tc)

prs, _, err := client.PullRequests.List(ctx, "quipper", "kubernetes-clusters", nil)
if err != nil {
return nil,fmt.Errorf("failed to get GitHub Pull Requests: %w", err)
}

return prs, nil
}

0 comments on commit e3773df

Please sign in to comment.