Check for potentially nil response from GitHub API client.

This commit is contained in:
Kit Ewbank 2017-05-19 15:19:54 -04:00
parent 6266eef652
commit 7795904f78
4 changed files with 6 additions and 4 deletions

View File

@ -84,7 +84,9 @@ func resourceGithubIssueLabelCreateOrUpdate(d *schema.ResourceData, meta interfa
} else {
log.Printf("[DEBUG] Creating label: %s/%s (%s: %s)", o, r, n, c)
_, resp, err := client.Issues.CreateLabel(context.TODO(), o, r, label)
if resp != nil {
log.Printf("[DEBUG] Response from creating label: %s", *resp)
}
if err != nil {
return err
}

View File

@ -94,7 +94,7 @@ func resourceGithubOrganizationWebhookRead(d *schema.ResourceData, meta interfac
hook, resp, err := client.Organizations.GetHook(context.TODO(), meta.(*Organization).name, hookID)
if err != nil {
if resp.StatusCode == 404 {
if resp != nil && resp.StatusCode == 404 {
d.SetId("")
return nil
}

View File

@ -127,7 +127,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
log.Printf("[DEBUG] read github repository %s/%s", meta.(*Organization).name, repoName)
repo, resp, err := client.Repositories.Get(context.TODO(), meta.(*Organization).name, repoName)
if err != nil {
if resp.StatusCode == 404 {
if resp != nil && resp.StatusCode == 404 {
log.Printf(
"[WARN] removing %s/%s from state because it no longer exists in github",
meta.(*Organization).name,

View File

@ -89,7 +89,7 @@ func resourceGithubRepositoryWebhookRead(d *schema.ResourceData, meta interface{
hook, resp, err := client.Repositories.GetHook(context.TODO(), meta.(*Organization).name, d.Get("repository").(string), hookID)
if err != nil {
if resp.StatusCode == 404 {
if resp != nil && resp.StatusCode == 404 {
d.SetId("")
return nil
}