Check for potentially nil response from GitHub API client.
This commit is contained in:
parent
6266eef652
commit
7795904f78
|
@ -84,7 +84,9 @@ func resourceGithubIssueLabelCreateOrUpdate(d *schema.ResourceData, meta interfa
|
||||||
} else {
|
} else {
|
||||||
log.Printf("[DEBUG] Creating label: %s/%s (%s: %s)", o, r, n, c)
|
log.Printf("[DEBUG] Creating label: %s/%s (%s: %s)", o, r, n, c)
|
||||||
_, resp, err := client.Issues.CreateLabel(context.TODO(), o, r, label)
|
_, resp, err := client.Issues.CreateLabel(context.TODO(), o, r, label)
|
||||||
log.Printf("[DEBUG] Response from creating label: %s", *resp)
|
if resp != nil {
|
||||||
|
log.Printf("[DEBUG] Response from creating label: %s", *resp)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ func resourceGithubOrganizationWebhookRead(d *schema.ResourceData, meta interfac
|
||||||
|
|
||||||
hook, resp, err := client.Organizations.GetHook(context.TODO(), meta.(*Organization).name, hookID)
|
hook, resp, err := client.Organizations.GetHook(context.TODO(), meta.(*Organization).name, hookID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp.StatusCode == 404 {
|
if resp != nil && resp.StatusCode == 404 {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
log.Printf("[DEBUG] read github repository %s/%s", meta.(*Organization).name, repoName)
|
log.Printf("[DEBUG] read github repository %s/%s", meta.(*Organization).name, repoName)
|
||||||
repo, resp, err := client.Repositories.Get(context.TODO(), meta.(*Organization).name, repoName)
|
repo, resp, err := client.Repositories.Get(context.TODO(), meta.(*Organization).name, repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp.StatusCode == 404 {
|
if resp != nil && resp.StatusCode == 404 {
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"[WARN] removing %s/%s from state because it no longer exists in github",
|
"[WARN] removing %s/%s from state because it no longer exists in github",
|
||||||
meta.(*Organization).name,
|
meta.(*Organization).name,
|
||||||
|
|
|
@ -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)
|
hook, resp, err := client.Repositories.GetHook(context.TODO(), meta.(*Organization).name, d.Get("repository").(string), hookID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp.StatusCode == 404 {
|
if resp != nil && resp.StatusCode == 404 {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue