func handleIssue(w http.ResponseWriter, r *http.Request) { log.Debugf("Got an issue hook") // parse the issue body, err := ioutil.ReadAll(r.Body) if err != nil { log.Errorf("Error reading github issue handler body: %v", err) w.WriteHeader(500) return } issueHook, err := octokat.ParseIssueHook(body) if err != nil { log.Errorf("Error parsing issue hook: %v", err) w.WriteHeader(500) return } // get the build baseRepo := fmt.Sprintf("%s/%s", issueHook.Repo.Owner.Login, issueHook.Repo.Name) log.Debugf("Issue is for repo: %s", baseRepo) build, err := config.getBuildByContextAndRepo("janky", baseRepo) if err != nil { log.Warnf("could not find build for repo %s for issue handler, skipping: %v", baseRepo, err) return } // if we do not handle issues for this build just return if !build.HandleIssues { log.Warnf("Not configured to handle issues for %s", baseRepo) return } g := github.GitHub{ AuthToken: config.GHToken, User: config.GHUser, } log.Infof("Received GitHub issue notification for %s %d (%s): %s", baseRepo, issueHook.Issue.Number, issueHook.Issue.URL, issueHook.Action) // if it is not a comment or an opened issue // return becuase we dont care if !issueHook.IsComment() && !issueHook.IsOpened() { log.Debugf("Ignoring issue hook action %q", issueHook.Action) return } // if the issue has just been opened // parse if ENEEDMOREINFO if issueHook.IsOpened() { log.Debug("Issue is opened, checking if we have correct info") if err := g.IssueInfoCheck(issueHook); err != nil { log.Errorf("Error checking if issue opened needs more info: %v", err) w.WriteHeader(500) return } w.WriteHeader(200) return } // handle if it is an issue comment // apply approproate labels if err := g.LabelIssueComment(issueHook); err != nil { log.Errorf("Error applying labels to issue comment: %v", err) w.WriteHeader(500) return } return }