Skip to content

Commit

Permalink
Rename receiver variable for Release type, Fix bad logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas committed Aug 2, 2022
1 parent 0bc087d commit 75f7b88
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ type Release struct {
}

// Generates a Textual summary for the release, intended to be used as the Jira issue summary
func (release Release) IssueSummary() string {
return fmt.Sprintf("Update %v to version %v", release.Project, release.Version)
func (r Release) IssueSummary() string {
return fmt.Sprintf("Update %v to version %v", r.Project, r.Version)
}

func (release Release) JiraIssue() jira.Issue {
labels := append(config.AddLabels, release.Project)
func (r Release) JiraIssue() jira.Issue {
labels := append(config.AddLabels, r.Project)
return jira.Issue{
Fields: &jira.IssueFields{
Description: "Update issue generated by https://github.2rioffice.com/platform/jelease using newreleases.io.",
Expand All @@ -62,7 +62,7 @@ func (release Release) JiraIssue() jira.Issue {
Name: config.DefaultStatus,
},
Labels: labels,
Summary: release.IssueSummary(),
Summary: r.IssueSummary(),
},
}
}
Expand All @@ -87,7 +87,7 @@ func handlePostWebhook(w http.ResponseWriter, r *http.Request) {
err := decoder.Decode(&release)
if err != nil {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
logger.Printf("Couldn't decode request body to json: %v\n error: %v\n", r.Body, err)
logger.Printf("failed to decode request body to json with error: %v\n", err)
return
}

Expand All @@ -98,9 +98,9 @@ func handlePostWebhook(w http.ResponseWriter, r *http.Request) {
body, readErr := io.ReadAll(resp.Body)
errCtx := errors.New("error response from Jira when searching previous issues")
if readErr != nil {
logger.Printf("%v: %v. Failed to decode response body: %v", errCtx, err, string(body))
logger.Println(fmt.Errorf("%v: %w. Failed to decode response body: %v", errCtx, err, readErr).Error())
} else {
logger.Printf("%v: %v. Response body: %v", errCtx, err, string(body))
logger.Println(fmt.Errorf("%v: %w. Response body: %v", errCtx, err, string(body)).Error())
}
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
Expand Down Expand Up @@ -170,7 +170,7 @@ func handlePostWebhook(w http.ResponseWriter, r *http.Request) {
if readErr != nil {
logger.Printf("%v: %v. Failed to decode response body: %v", errCtx, err, readErr)
} else {
logger.Printf("%v: %v. Response body: %v", errCtx, err, body)
logger.Printf("%v: %v. Response body: %v", errCtx, err, string(body))
}
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
Expand Down

0 comments on commit 75f7b88

Please sign in to comment.