Skip to content

Commit

Permalink
fail if the request could not be created
Browse files Browse the repository at this point in the history
  • Loading branch information
azr committed Oct 25, 2018
1 parent aa2ebec commit 7b10079
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions post-processor/vagrant-cloud/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ func (v *VagrantCloudClient) Get(path string) (*http.Response, error) {

log.Printf("Post-Processor Vagrant Cloud API GET: %s", reqUrl)

req, _ := v.newRequest("GET", reqUrl, nil)
req, err := v.newRequest("GET", reqUrl, nil)
if err != nil {
return nil, err
}
resp, err := v.client.Do(req)

log.Printf("Post-Processor Vagrant Cloud API Response: \n\n%+v", resp)
Expand All @@ -97,7 +100,10 @@ func (v *VagrantCloudClient) Delete(path string) (*http.Response, error) {
scrubbedUrl := strings.Replace(reqUrl, v.AccessToken, "ACCESS_TOKEN", -1)
log.Printf("Post-Processor Vagrant Cloud API DELETE: %s", scrubbedUrl)

req, _ := http.NewRequest("DELETE", reqUrl, nil)
req, err := http.NewRequest("DELETE", reqUrl, nil)
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", v.AccessToken))
resp, err := v.client.Do(req)
Expand Down Expand Up @@ -149,7 +155,10 @@ func (v *VagrantCloudClient) Post(path string, body interface{}) (*http.Response

log.Printf("Post-Processor Vagrant Cloud API POST: %s. \n\n Body: %s", reqUrl, encBody)

req, _ := v.newRequest("POST", reqUrl, encBody)
req, err := v.newRequest("POST", reqUrl, encBody)
if err != nil {
return nil, err
}

resp, err := v.client.Do(req)

Expand All @@ -163,7 +172,10 @@ func (v *VagrantCloudClient) Put(path string) (*http.Response, error) {

log.Printf("Post-Processor Vagrant Cloud API PUT: %s", reqUrl)

req, _ := v.newRequest("PUT", reqUrl, nil)
req, err := v.newRequest("PUT", reqUrl, nil)
if err != nil {
return nil, err
}

resp, err := v.client.Do(req)

Expand Down

0 comments on commit 7b10079

Please sign in to comment.