Skip to content

Commit

Permalink
feat(vcs): display gh response (#5561)
Browse files Browse the repository at this point in the history
* feat: display gh response

Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault authored Nov 20, 2020
1 parent 9de27a5 commit 5b2fe68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions engine/vcs/github/client_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func (g *githubClient) SetStatus(ctx context.Context, event sdk.Event) error {
}
buf := bytes.NewBuffer(b)

log.Debug("SetStatus> github post on %v body:%v", path, string(b))

res, err := g.post(path, "application/json", buf, nil)
if err != nil {
return sdk.WrapError(err, "Unable to post status")
Expand All @@ -77,6 +79,8 @@ func (g *githubClient) SetStatus(ctx context.Context, event sdk.Event) error {
return sdk.WrapError(err, "Unable to read body")
}

log.Debug("SetStatus> github response for %v body:%v", path, string(body))

if res.StatusCode != 201 {
return sdk.WrapError(err, "Unable to create status on github. Status code : %d - Body: %s - target:%s", res.StatusCode, body, data.urlPipeline)
}
Expand Down
4 changes: 2 additions & 2 deletions engine/vcs/github/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ func (c *githubClient) post(path string, bodyType string, body io.Reader, opts *
req.Header.Add("Accept", "application/json")
if opts.asUser && c.token != "" {
req.SetBasicAuth(c.username, c.token)
log.Debug("Github API>> Request URL %s with basicAuth username:%v len:%d", req.URL.String(), c.username, len(c.token))
} else {
req.Header.Add("Authorization", fmt.Sprintf("token %s", c.OAuthToken))
log.Debug("Github API>> Request URL %s with Authorization", req.URL.String())
}

log.Debug("Github API>> Request URL %s", req.URL.String())

return httpClient.Do(req)
}

Expand Down

0 comments on commit 5b2fe68

Please sign in to comment.