Skip to content

Commit

Permalink
Extract getPRInfos()
Browse files Browse the repository at this point in the history
  • Loading branch information
chaspy committed Jan 24, 2021
1 parent 6b271e7 commit b97198f
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ import (
"golang.org/x/oauth2"
)

type PR struct {
Number *int
Labels []*github.Label
User *string
Assignee *string
Assignees []*string
RequestedReviewers []*github.User
}

func main() {
err := run()
if err != nil {
Expand All @@ -21,15 +30,6 @@ func main() {
}

func run() error {
type PR struct {
Number *int
Labels []*github.Label
User *string
Assignee *string
Assignees []*string
RequestedReviewers []*github.User
}

apikey, appkey, err := readDatadogConfig()
if err != nil {
return fmt.Errorf("failed to read Datadog Config: %w", err)
Expand All @@ -45,16 +45,7 @@ func run() error {
return fmt.Errorf("failed to get PullRequests: %w", err)
}

prInfos := []PR{}

for _, pr := range prs {
prInfos = append(prInfos, PR{
Number: pr.Number,
Labels: pr.Labels,
User: pr.User.Login,
RequestedReviewers: pr.RequestedReviewers,
})
}
prInfos := getPRInfos(prs)

ddClient := datadog.NewClient(apikey, appkey)

Expand Down Expand Up @@ -151,3 +142,18 @@ func getPullRequests(githubToken string) ([]*github.PullRequest, error) {

return prs, nil
}

func getPRInfos(prs []*github.PullRequest) []PR {
prInfos := []PR{}

for _, pr := range prs {
prInfos = append(prInfos, PR{
Number: pr.Number,
Labels: pr.Labels,
User: pr.User.Login,
RequestedReviewers: pr.RequestedReviewers,
})
}

return prInfos
}

0 comments on commit b97198f

Please sign in to comment.