Skip to content

Commit

Permalink
Merge pull request #407 from briantkennedy/response
Browse files Browse the repository at this point in the history
Improve error message for askpass.
  • Loading branch information
k8s-ci-robot authored Jun 15, 2021
2 parents 903d86d + a87c786 commit bf2b854
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/git-sync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1365,11 +1365,17 @@ func (git *repoSync) CallAskPassURL(ctx context.Context) error {
if err != nil {
return fmt.Errorf("can't access auth URL: %w", err)
}
defer func() {
_ = resp.Body.Close()
}()
if resp.StatusCode != 200 {
return fmt.Errorf("auth URL returned status %d", resp.StatusCode)
errMessage, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("auth URL returned status %d, failed to read body: %w", resp.StatusCode, err)
}
return fmt.Errorf("auth URL returned status %d, body: %q", resp.StatusCode, string(errMessage))
}
authData, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return fmt.Errorf("can't read auth response: %w", err)
}
Expand Down

0 comments on commit bf2b854

Please sign in to comment.