Skip to content

Commit

Permalink
added logging
Browse files Browse the repository at this point in the history
  • Loading branch information
BardOve committed Nov 15, 2023
1 parent fbc520a commit 6d60dd8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/git/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@ func ReposFor(org, authToken string) ([]Repo, error) {
var reposPart []Repo
res, err := getRequest(urlRaw, authToken)
if res.StatusCode != 200 {
log.Info().Msgf("got a %d from GitHub", res.StatusCode)
log.Error().Msgf("got a %d from GitHub", res.StatusCode)
return nil, err
}
if err != nil {
log.Error().Msgf("Request to '%s' filed: %v", urlRaw, err)
return nil, err
}
body, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Error().Msgf("Error reading data from '%s': %v", urlRaw, err)
return nil, err
}
err = json.Unmarshal(body, &reposPart)
if err != nil {
log.Error().Msgf("Error unmarshaling data: ", err)
return nil, err
}
allRepos = append(allRepos, reposPart...)
Expand All @@ -48,6 +51,7 @@ func ReposFor(org, authToken string) ([]Repo, error) {
func getRequest(rawUrl, authToken string) (*http.Response, error) {
u, err := url.Parse(rawUrl)
if err != nil {
log.Error().Msgf("Parsing url failed: %v", rawUrl)
return nil, err
}
req, err := http.NewRequest("GET", u.String(), nil)
Expand Down

0 comments on commit 6d60dd8

Please sign in to comment.