Skip to content

Commit

Permalink
Handle error return from http.NewRequest()
Browse files Browse the repository at this point in the history
  • Loading branch information
tedyu authored and yutedz committed Jul 9, 2019
1 parent 33541bd commit 7a5e703
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/credentialprovider/azure/azure_acr_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func receiveChallengeFromLoginServer(serverAddress string) (*authDirective, erro
}
var err error
var r *http.Request
r, _ = http.NewRequest("GET", challengeURL.String(), nil)
r, err = http.NewRequest("GET", challengeURL.String(), nil)
if err != nil {
return nil, fmt.Errorf("failed to construct request, got %v", err)
}
r.Header.Add(userAgentHeader, userAgent)

var challenge *http.Response
Expand Down Expand Up @@ -154,7 +157,10 @@ func performTokenExchange(

datac := data.Encode()
var r *http.Request
r, _ = http.NewRequest("POST", authEndpoint, bytes.NewBufferString(datac))
r, err = http.NewRequest("POST", authEndpoint, bytes.NewBufferString(datac))
if err != nil {
return "", fmt.Errorf("failed to construct request, got %v", err)
}
r.Header.Add(userAgentHeader, userAgent)
r.Header.Add("Content-Type", "application/x-www-form-urlencoded")
r.Header.Add("Content-Length", strconv.Itoa(len(datac)))
Expand Down

0 comments on commit 7a5e703

Please sign in to comment.